1. Go to this page and download the library: Download hawkiq/laravel-zaincash library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//Your Controller
use Hawkiq\LaravelZaincash\Services\ZainCash;
public function send()
{
// Now you can use zain cash as API or web just pass the isWeb variable value as boolean or use asApi method
$zaincash = new ZainCash(); // for normal Web version
// OR
$zaincash = (new ZainCash())->asApi(); // for API version
// OR
$zaincash = (new ZainCash())->asWeb(false); // for API version
//The total price of your order in Iraqi Dinar only like 1000 (if in dollar, multiply it by dollar-dinar exchange rate, like 1*1500=1500)
//Please note that it MUST BE MORE THAN 1000 IQD
$amount = 1000;
//Type of service you provide, like 'Books', 'ecommerce cart', 'Hosting services', ...
$service_type="Shirt";
//Order id, you can use it to help you in tagging transactions with your website IDs, if you have no order numbers in your website, leave it 1
$order_id="20222009";
$payload = $zaincash->request($amount, $service_type, $order_id);
return $payload;
}
//get token from request Url
$token = \Request::input('token');
if (isset($token)) {
$zaincash = new ZainCash();
$result = $zaincash->parse($token);
if ($result->status == 'success'){ // success || failed || pending
return 'Thanks for Buying';
// We can do what ever you like , insert transaction into database, send email etc..
}
php artisan vendor:publish --tag="zaincash"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.