PHP code example of arafatkn / laravel-bkash

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

    

arafatkn / laravel-bkash example snippets


use BkashTokenizedPayment;

$response = BkashTokenizedPayment::createPayment([
    'amount'                => '100',
    'merchantInvoiceNumber' => 'INV-001',
    'callbackURL'           => route('bkash.callback'),
    'payerReference'        => 'user_123',   // optional
    'currency'              => 'BDT',         // optional, defaults to config
    'intent'                => 'sale',        // optional, defaults to config
]);

// Redirect customer to payment page
return redirect($response['bkashURL']);

$paymentID = $request->query('paymentID');

$response = BkashTokenizedPayment::executePayment($paymentID);

if ($response['statusCode'] === '0000') {
    // Payment successful
    $trxID = $response['trxID'];
}

$response = BkashTokenizedPayment::queryPayment($paymentID);

$response = BkashTokenizedPayment::searchTransaction($trxID);

$response = BkashTokenizedPayment::refundPayment(
    'TR0011xxxxxxxxxxx',
    'ADxxxxxxxx',
    [
        'amount' => '100',                           // optional
        'reason' => 'Customer requested refund',     // optional
        'sku'    => 'product-sku',                   // optional, defaults to 'NA'
    ]
);
bash
php artisan vendor:publish --tag=bkash-config