1. Go to this page and download the library: Download sindibad/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/ */
sindibad / zaincash example snippets
// In your providers array.
'providers' => [
...
sindibad\zaincash\provider\ZaincashServiceProvider::class,
],
// In your aliases array.
'aliases' => [
...
'ZainCash' => Zaincash\Payment\facades\ZainCash::class,
],
"eloquent_storage" => true, // Once enabled, package will create transaction_zaincash table(through zaincash:migrate command) and fill it's values when new transaction is submitted
"callback_url" => "default", // default, <your website domain>/[your custom segment] for callback response
"merchant_id" => "",
"token" => '', //Secret key for jwt encode
"msisdn" => "",
"lang" => "en", //ar,en
"production" => false,//Once set to true production url's will be used otherwise test url's are consumed
...
]
php artisan zaincash:migrate
// At the top of the file.
use sindibad\zaincash\facades\ZainCash;
...
// Create new invoice.
$invoice = new Invoice;
// Set invoice amount.
$invoice->amount(1000);
// Set orderId if available, so you can get the value back on callback
$invoice->setOrderId($request->orderid);
// Set additional description or project type
$invoice->setServiceType("mydescription");
// As mentioned this can be set either in config file or directly in Invoice accessor
// !Note that once you set it here this will be priority and not the config file values
$invoice->setLang("en");
// Callback url for callback response you can also set it to `default` for testing etc.
$invoice->setCallbackUrl("http://localhost:8000/customcallback");
// As mentioned before enabling EloquentStorage will create transaction_zaincash table inside your main db with transaction records
$invoice->setEnableElequentStorage(true);
// This parameter is set for main zaincash view files. it will set back button text
$invoice->setBackBtnText("back");
// Redirect url for main views back button
$invoice->setBackBtnUrl("http://localhost:8000/");
// you could also add extra parameters to invoice and get them back in callback response
//you need to define a key for your Extra,note that you will use this key to receive your extra in callback
$invoice->appendExtra("key" , "value");
//Finally, use pay to initialize your transaction
$pay = $invoice->pay();
//You can access redirect url for payment within ['url'] index
$redirect_url=$pay['url'];
//Get error messages
$invoice->getErrors();
$payment= ZainCash::callBackResponse();
$payment= ZainCash::callBackResponse();
$payment->getStatus();
//when you're using getExtra method remember to pass default value as second parameter even tough it is optional
$response->getExtra("user_id" , -1);
public function handle($event)
{
$event->getPayment();
//Logic
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.