PHP code example of alkhatibdev / laravel-zain

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

    

alkhatibdev / laravel-zain example snippets




return [

    'base_url' => env('ZAIN_SERVER_BASE_API_URL'),

    'product_code' => env('ZAIN_PRODUCT_CODE'),

    'username' => env('ZAIN_USERNAME'),

    'password' => env('ZAIN_PASSWORD'),

    'remember_token' => env('ZAIN_REMEMBER_TOKEN', false),

    'enable_logging' => false,
];


use AlkhatibDev\LaravelZain\Facades\Zain;

// Initiate payment request
$response = Zain::initiate($phone)



$response = Zain::verify($otp, $requestId)



$response = Zain::checkSubscription($phone)



$response = Zain::unsubscribe($phone)

// cacheToken($response['token'])


$token = Zain::token()

// $token = getCachedToken()

$response = Zain::withToken($token)->initiate($phone)
$response = Zain::withToken($token)->verify($phone)
...
shell
php artisan vendor:publish --tag=laravel-zain-config