If you want to setup Bkash Payment Gateway you need to follow some steps. Below I am giving a step by step guide on how you can integrate Bkash Payment Gateway. For this we will use Bkash's Merchant API.
1. Essentials for Bkash API Integration
Bkash Merchant Account: You must have a Bkash Merchant Account. If not you can apply for Bkash Merchant.
API Credentials: Bkash will provide you API Username, API Password, App Key, and App Secret after Merchant Account setup.
SSL Certificate: An SSL certificate is mandatory for Bkash payment gateway.
Webhook URL: You need to set a Webhook URL to receive payment notifications.
2. Payment Gateway Integration Process
Step 1: Environment Setup
First setup your PHP environment or any other server-side environment.
composer.json file (if using PHP)
json
Copy code
{
"require": {
"guzzlehttp/guzzle": "^7.0"
}
}
Then run composer install.
ধাপ ২: ফাইল এবং ডিরেক্টরি স্ট্রাকচার
plaintext
Copy code
project-root/
├── index.php
├── bkash/
│ ├── config.php
│ ├── token.php
│ ├── create_payment.php
│ ├── execute_payment.php
│ └── query_payment.php
└── success.php
ধাপ ৩: Bkash API Configuration (bkash/config.php)
php
Copy code
return [
'base_url' => 'https://checkout.sandbox.bka.sh/v1.2.0-beta',
'username' => 'YOUR_BKASH_USERNAME',
'password' => 'YOUR_BKASH_PASSWORD',
'app_key' => 'YOUR_APP_KEY',
'app_secret' => 'YOUR_APP_SECRET',
'callback_url' => 'https://fqrhost.com/success.php'
];
?>
ধাপ ৪: Access Token Generate (bkash/token.php)
php
Copy code
$config = include('config.php');
function generateToken() {
global $config;
$url = $config['base_url'] . '/checkout/token/grant';
$headers = [
'Content-Type:application/json',
'username:' . $config['username'],
'password:' . $config['password']
];
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
}
if (isset($_GET['paymentID'])) {
$response = executePayment($_GET['paymentID']);
echo '
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|