PHP code example of rtraselbd / bkash-php

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

    

rtraselbd / bkash-php example snippets


    use RT\bKash\bKash;

    'username'      => 'your-bKash-username',
       'password'      => 'your-bKash-password',
       'app_key'       => 'your-app-key',
       'app_secret'    => 'your-app-secret',
    ];
    $bKash = new bKash($credential);
   

   $requestData = [
       'amount'        => 10,
       'success_url'   => 'https://your-website.com/success.php',
       'brand_name'    => 'YourBrandName',
   ];

   try {
       $bKashURL = $bKash->createPayment($requestData);
       // Redirect the user to the bKash payment URL
       header('Location: ' . $bKashURL);
   } catch (Exception $e) {
       // Handle any exceptions or errors here
       $error = $e->getMessage();
   }
   

   $paymentID = $_GET['paymentID'];

   try {
       $response = $bKash->verifyPayment($paymentID);
   } catch (Exception $e) {
       // Handle any exceptions or errors here
       $error = $e->getMessage();
   }
   
bash
composer