PHP code example of thejano / zaincash-laravel

1. Go to this page and download the library: Download thejano/zaincash-laravel 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/ */

    

thejano / zaincash-laravel example snippets


use TheJano\ZainCash\Facades\ZainCashPayment;

$response = ZainCashPayment::initiatePayment(
    orderId: '12345',
    amount: 1000.00,
    serviceType: 'purchase',
    redirectUrl: 'https://yourdomain.com/payment/success'
);

$transactionId = $response['id'];
$paymentUrl = ZainCashPayment::getPaymentUrl($transactionId);

return redirect($paymentUrl);

use TheJano\ZainCash\Facades\ZainCashPayment;

$token = request('token');
$paymentData = ZainCashPayment::verifyPayment($token);

if ($paymentData) {
    // Payment is successful
} else {
    // Payment failed
}

use TheJano\ZainCash\Facades\ZainCashPayment;

$transactionId = 'some_transaction_id';
$transactionStatus = ZainCashPayment::checkTransaction($transactionId);
sh
php artisan vendor:publish --provider="TheJano\ZainCash\Providers\ZainCashPaymentServiceProvider"