PHP code example of jeishanul / nagad

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

    

jeishanul / nagad example snippets


return [
    'sandbox_mode' => env('NAGAD_MODE'),
    'merchant_id' => env('NAGAD_MERCHANT_ID'),
    'merchant_number' => env('NAGAD_MERCHANT_NUMBER'),
    'callback_url' => env('NAGAD_CALLBACK_URL'),
    'public_key' => env('NAGAD_PUBLIC_KEY'),
    'private_key' => env('NAGAD_PRIVATE_KEY')
];

use Jeishanul\Nagad\Nagad;

$tnxID = 1;
$amount = 99;
$redirectUrl = Nagad::getRedirectUrl($tnxID,$amount);;
return redirect($redirectUrl);

use Jeishanul\Nagad\Nagad;
$verify = Nagad::verify();
if($verify->status === 'Success'){
    $order = json_decode($verify->additionalMerchantInfo);
    $order_id = $order->tnx_id;
    // your functional task with order_id
}
if ($verify->status === 'Aborted') {
    // redirect or other what you want
}


use Jeishanul\Nagad\Nagad;
// It's provide you a "support ID"
$tnxID = 1;
$sid = Nagad::getSupportID($tnxID);
return $sid;
bash
php artisan vendor:publish --provider="Jeishanul\Nagad\NagadServiceProvider" --tag=config