PHPackages                             devrkb21/bkash-pgw-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. devrkb21/bkash-pgw-laravel

ActiveLibrary[Payment Processing](/categories/payments)

devrkb21/bkash-pgw-laravel
==========================

Production-ready Laravel integration for bKash Tokenized Checkout V2 (auth, payments, webhooks).

v1.0.1(1mo ago)02↓100%MITPHPPHP ^8.1

Since Apr 20Pushed 1mo agoCompare

[ Source](https://github.com/devrkb21/bkash-pgw-laravel)[ Packagist](https://packagist.org/packages/devrkb21/bkash-pgw-laravel)[ RSS](/packages/devrkb21-bkash-pgw-laravel/feed)WikiDiscussions pub Synced 1w ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

💸 Laravel bKash Payment Gateway (Tokenized Checkout V2)
=======================================================

[](#-laravel-bkash-payment-gateway-tokenized-checkout-v2)

🚀 Production-ready **Laravel bKash package** for integrating **bKash Tokenized Checkout V2 API** with secure webhook, token management, and full payment flow.

> The most complete and secure bKash integration for Laravel.

---

[![PHP](https://camo.githubusercontent.com/6351c44c5acd541a16e8505d9389a2576fb01528ebdbaf6a6b744ac49e401cae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d626c7565)](https://camo.githubusercontent.com/6351c44c5acd541a16e8505d9389a2576fb01528ebdbaf6a6b744ac49e401cae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d626c7565)[![Laravel](https://camo.githubusercontent.com/93554d1ac44e7880097a6bd117e99f90c33ddf03dcf0a37f3047fa50b8aaa4d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532422d726564)](https://camo.githubusercontent.com/93554d1ac44e7880097a6bd117e99f90c33ddf03dcf0a37f3047fa50b8aaa4d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532422d726564)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)

---

🚀 Quick Start (30 seconds)
--------------------------

[](#-quick-start-30-seconds)

```
composer require devrkb21/bkash-pgw-laravel
```

```
use Bkash;

$url = Bkash::payment()->createPayment([
    'payerReference' => 'user_123',
    'callbackURL' => route('bkash.callback'),
    'amount' => '100',
    'currency' => 'BDT',
    'intent' => 'sale',
    'merchantInvoiceNumber' => 'INV123456',
]);

return redirect($url->bkash_url);
```

👉 That’s it. User will be redirected to bKash payment page.

---

⚙️ Configuration
----------------

[](#️-configuration)

Publish config:

```
php artisan vendor:publish --tag=bkash-config
```

Add credentials:

```
BKASH_ENV=sandbox

BKASH_SANDBOX_BASE_URL=https://tokenized.sandbox.bka.sh/v2/tokenized-checkout
BKASH_PRODUCTION_BASE_URL=https://tokenized.pay.bka.sh/v2/tokenized-checkout

BKASH_APP_KEY=
BKASH_APP_SECRET=
BKASH_USERNAME=
BKASH_PASSWORD=

BKASH_TIMEOUT=30
BKASH_CACHE=true
BKASH_TOKEN_CACHE_KEY=bkash.token
BKASH_ENABLE_ROUTES=false
```

---

### Auth APIs

[](#auth-apis)

#### Grant Token - POST /auth/grant-token

[](#grant-token---post-authgrant-token)

Request body keys:

```
{
    "app_key": "{{bkash_app_key}}",
    "app_secret": "{{bkash_app_secret}}"
}
```

Response (normalized by the package, `expires_at` is computed):

```
{
    "id_token": "string",
    "refresh_token": "string",
    "expires_in": 3600,
    "expires_at": 1730999999
}
```

#### Refresh Token - POST /auth/refresh-token

[](#refresh-token---post-authrefresh-token)

Request body keys:

```
{
    "app_key": "{{bkash_app_key}}",
    "app_secret": "{{bkash_app_secret}}",
    "refresh_token": "{{bkash_refresh_token}}"
}
```

Response (normalized by the package, `expires_at` is computed):

```
{
    "id_token": "string",
    "refresh_token": "string",
    "expires_in": 3600,
    "expires_at": 1730999999
}
```

### Payment APIs (Without Agreement)

[](#payment-apis-without-agreement)

#### Create Payment - POST /payment/create

[](#create-payment---post-paymentcreate)

Request body keys:

```
{
    "payerReference": "{{payer_reference}}",
    "callbackURL": "{{callback_url}}",
    "amount": "{{amount}}",
    "currency": "{{currency}}",
    "intent": "{{intent}}",
    "merchantInvoiceNumber": "{{merchant_invoice_number}}",
    "merchantAssociationInfo": "{{merchant_association_info}}"
}
```

Response (package normalizes common fields):

```
{
    "paymentID": "payment_123",
    "paymentId": "payment_123",
    "bkashURL": "https://tokenized.sandbox.bka.sh/checkout/..."
}
```

#### Execute Payment - POST /payment/execute

[](#execute-payment---post-paymentexecute)

Request body keys:

```
{
    "paymentId": "{{payment_id}}"
}
```

Response (package normalizes common fields):

```
{
    "trxID": "trx_123"
}
```

#### Query Payment - POST /query/payment

[](#query-payment---post-querypayment)

Request body keys:

```
{
    "paymentID": "{{payment_id}}"
}
```

Response (raw bKash payload, normalized keys are added when present):

```
{
    "paymentID": "payment_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

#### Capture Payment - POST /payment/capture

[](#capture-payment---post-paymentcapture)

Request body keys:

```
{
    "paymentId": "{{payment_id}}"
}
```

Response (raw bKash payload, normalized keys are added when present):

```
{
    "paymentID": "payment_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

#### Void Payment - POST /payment/void

[](#void-payment---post-paymentvoid)

Request body keys:

```
{
    "paymentId": "{{payment_id}}"
}
```

Response (raw bKash payload, normalized keys are added when present):

```
{
    "paymentID": "payment_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

### Payment APIs (With Agreement)

[](#payment-apis-with-agreement)

#### Create Payment With Agreement - POST /payment-with-agreement/create

[](#create-payment-with-agreement---post-payment-with-agreementcreate)

Request body keys:

```
{
    "agreementId": "{{agreement_id}}",
    "callbackURL": "{{callback_url}}",
    "amount": "{{amount}}",
    "intent": "{{intent}}",
    "currency": "{{currency}}",
    "merchantInvoiceNumber": "{{merchant_invoice_number}}"
}
```

Response (package normalizes common fields):

```
{
    "paymentID": "payment_123",
    "paymentId": "payment_123",
    "agreementID": "agreement_123",
    "agreementId": "agreement_123",
    "bkashURL": "https://tokenized.sandbox.bka.sh/checkout/..."
}
```

#### Execute Payment With Agreement - POST /payment-with-agreement/execute

[](#execute-payment-with-agreement---post-payment-with-agreementexecute)

Request body keys:

```
{
    "paymentId": "{{payment_id}}",
    "agreementId": "{{agreement_id}}"
}
```

Response (package normalizes common fields):

```
{
    "trxID": "trx_123"
}
```

#### Capture Payment With Agreement - POST /payment-with-agreement/capture

[](#capture-payment-with-agreement---post-payment-with-agreementcapture)

Request body keys:

```
{
    "paymentId": "{{payment_id}}",
    "agreementId": "{{agreement_id}}"
}
```

Response (raw bKash payload, normalized keys are added when present):

```
{
    "paymentID": "payment_123",
    "agreementID": "agreement_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

#### Void Payment With Agreement - POST /payment-with-agreement/void

[](#void-payment-with-agreement---post-payment-with-agreementvoid)

Request body keys:

```
{
    "paymentId": "{{payment_id}}",
    "agreementId": "{{agreement_id}}"
}
```

Response (raw bKash payload, normalized keys are added when present):

```
{
    "paymentID": "payment_123",
    "agreementID": "agreement_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

### Agreement APIs

[](#agreement-apis)

#### Create Agreement - POST /agreement/create

[](#create-agreement---post-agreementcreate)

Request body keys:

```
{
    "payerReference": "{{payer_reference}}",
    "callbackURL": "{{agreement_callback_url}}"
}
```

Response (raw bKash payload):

```
{
    "agreementID": "agreement_123",
    "bkashURL": "https://tokenized.sandbox.bka.sh/checkout/...",
    "...": "additional fields may be returned"
}
```

#### Execute Agreement - POST /agreement/execute

[](#execute-agreement---post-agreementexecute)

Request body keys:

```
{
    "agreementId": "{{agreement_id}}"
}
```

Response (raw bKash payload):

```
{
    "agreementID": "agreement_123",
    "...": "additional fields may be returned"
}
```

#### Query Agreement - POST /query/agreement

[](#query-agreement---post-queryagreement)

Request body keys:

```
{
    "agreementId": "{{agreement_id}}"
}
```

Response (raw bKash payload):

```
{
    "agreementID": "agreement_123",
    "...": "additional fields may be returned"
}
```

#### Cancel Agreement - POST /agreement/cancel

[](#cancel-agreement---post-agreementcancel)

Request body keys:

```
{
    "agreementId": "{{agreement_id}}"
}
```

Response (raw bKash payload):

```
{
    "agreementID": "agreement_123",
    "...": "additional fields may be returned"
}
```

### Transaction and Refund APIs

[](#transaction-and-refund-apis)

#### Search Transaction - POST /general/search-transaction

[](#search-transaction---post-generalsearch-transaction)

Request body keys:

```
{
    "trxId": "{{trx_id}}"
}
```

Response (raw bKash payload):

```
{
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

#### Refund Transaction - POST /refund/payment/transaction

[](#refund-transaction---post-refundpaymenttransaction)

Request body keys:

```
{
    "refundAmount": "{{refund_amount}}",
    "paymentId": "{{payment_id}}",
    "trxId": "{{trx_id}}",
    "sku": "{{sku}}",
    "reason": "{{reason}}"
}
```

Response (raw bKash payload):

```
{
    "paymentID": "payment_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

#### Refund Status - POST /refund/payment/status

[](#refund-status---post-refundpaymentstatus)

Request body keys:

```
{
    "paymentId": "{{payment_id}}",
    "trxId": "{{trx_id}}"
}
```

Response (raw bKash payload):

```
{
    "paymentID": "payment_123",
    "trxID": "trx_123",
    "...": "additional fields may be returned"
}
```

### Webhook Events (SNS)

[](#webhook-events-sns)

Enable the built-in route by setting `BKASH_ENABLE_ROUTES=true`.

Webhook endpoint:

```
POST /bkash/webhook

```

#### SubscriptionConfirmation Event

[](#subscriptionconfirmation-event)

Headers:

- Content-Type: application/json
- x-amz-sns-message-type: SubscriptionConfirmation

Request body keys:

```
{
    "Type": "SubscriptionConfirmation",
    "MessageId": "11111111-2222-3333-4444-555555555555",
    "Token": "{{sns_token}}",
    "TopicArn": "{{sns_topic_arn}}",
    "Message": "You have chosen to subscribe to the topic.",
    "SubscribeURL": "{{sns_subscribe_url}}",
    "Timestamp": "2026-04-11T00:00:00.000Z",
    "SignatureVersion": "1",
    "Signature": "{{sns_signature}}",
    "SigningCertURL": "{{sns_signing_cert_url}}"
}
```

Response (from the package webhook service):

```
{
    "success": true,
    "type": "SubscriptionConfirmation",
    "data": {
        "subscriptionConfirmed": true,
        "subscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=ConfirmSubscription"
    }
}
```

#### Notification Event

[](#notification-event)

Headers:

- Content-Type: application/json
- x-amz-sns-message-type: Notification

Request body keys:

```
{
    "Type": "Notification",
    "MessageId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "TopicArn": "{{sns_topic_arn}}",
    "Subject": "bKash Payment Notification",
    "Message": "{\"debitMSISDN\":\"{{debit_msisdn}}\",\"creditShortCode\":\"{{credit_shortcode}}\",\"amount\":\"{{amount}}\",\"trxID\":\"{{trx_id}}\",\"currency\":\"{{currency}}\",\"dateTime\":\"20260411093030\",\"transactionType\":\"{{transaction_type}}\",\"transactionStatus\":\"{{transaction_status}}\"}",
    "Timestamp": "2026-04-11T00:05:00.000Z",
    "SignatureVersion": "1",
    "Signature": "{{sns_signature}}",
    "SigningCertURL": "{{sns_signing_cert_url}}"
}
```

Response (from the package webhook service):

```
{
    "success": true,
    "type": "Notification",
    "data": {
        "trxID": "trx_123",
        "trxId": "trx_123",
        "amount": "100.00",
        "transactionStatus": "Completed"
    }
}
```

### Checkout SDK

[](#checkout-sdk)

#### Checkout Script URL - GET

[](#checkout-script-url---get)

```
https://scripts.{{bkash_sdk_host}}.bka.sh/versions/{{bkash_sdk_version}}/checkout/bKash-checkout{{bkash_sdk_suffix}}.js

```

Response: JavaScript file (200/301/302/304/404).

### Payout

[](#payout)

#### Initiate Payout - POST /payout/initiate

[](#initiate-payout---post-payoutinitiate)

Request body keys:

```
{
    "type": "B2C",
    "Rereference": "{{payer_reference}}"
}
```

Response (raw bKash payload):

```
{
    "paymentID": "payment_123",
    "...": "additional fields may be returned"
}
```

---

💳 Payment Flow
--------------

[](#-payment-flow)

### 1. Create Payment

[](#1-create-payment)

```
Bkash::payment()->createPayment([...]);
```

### 2. Handle Callback

[](#2-handle-callback)

```
Bkash::payment()->handleCallback(request()->all());
```

### 3. Query Payment

[](#3-query-payment)

```
Bkash::payment()->queryPayment($paymentId);
```

### 4. Capture / Void

[](#4-capture--void)

```
Bkash::payment()->capturePayment($paymentId);
Bkash::payment()->voidPayment($paymentId);
```

---

🔄 Agreement (Saved Wallet)
--------------------------

[](#-agreement-saved-wallet)

```
Bkash::agreement()->createAgreement([...]);
Bkash::agreement()->executeAgreement($agreementId);
```

---

💰 Refund API
------------

[](#-refund-api)

```
Bkash::refund()->refundTransaction([
    'paymentId' => $paymentId,
    'trxId' => $trxId,
    'refundAmount' => '10',
    'reason' => 'Customer request',
]);
```

---

🔔 Webhook (Secure &amp; Automatic)
----------------------------------

[](#-webhook-secure--automatic)

Enable in config:

```
'enable_routes' => true,
```

Endpoint:

```
POST /bkash/webhook

```

### Automatically handled:

[](#automatically-handled)

- SNS Subscription confirmation
- Signature verification
- Replay attack protection
- Notification parsing

---

🔐 Why this package?
-------------------

[](#-why-this-package)

Most Laravel bKash packages:

- ❌ No token management
- ❌ No webhook security
- ❌ Only basic API wrappers

This package provides:

- ✅ Automatic token lifecycle (grant + refresh)
- ✅ Secure SNS webhook verification
- ✅ Replay attack protection
- ✅ Retry-safe HTTP client
- ✅ Full payment + agreement + refund APIs
- ✅ Clean Laravel integration (Facade + DI)
- ✅ Test coverage

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

📦 Requirements
--------------

[](#-requirements)

- PHP 8.1+
- Laravel 10 / 11 / 12

---

📈 SEO Keywords
--------------

[](#-seo-keywords)

Laravel bKash payment gateway, bKash Laravel package, Bangladesh payment gateway Laravel, bKash Tokenized Checkout V2, Laravel payment integration bKash

---

🛠 Roadmap
---------

[](#-roadmap)

- Event system (PaymentSuccess, Failed)
- Queue-based webhook handling
- Multi-gateway support (bKash + Nagad + SSLCommerz)

---

🤝 Contributing
--------------

[](#-contributing)

PRs are welcome. Please ensure tests pass.

---

📄 License
---------

[](#-license)

MIT License

---

⭐ Support
---------

[](#-support)

If this package helps you, please give it a star ⭐ It helps others discover the project.

---

☕ Support Development
---------------------

[](#-support-development)

If you find this package useful, you can support ongoing development:

👉

Your support helps maintain and improve this package ❤️ [![Buy Me A Coffee](https://camo.githubusercontent.com/2028cb7adab7f29ef81ef892f082eecda8a1d00dda3b95eb23a475e386aa7542/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275792532304d6525323061253230436f666665652d737570706f72742d79656c6c6f77)](https://buymeacoffee.com/devrkb21)

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

2

Last Release

32d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16e2f5b25c5828182e78315ed084f7648a54be3566b1c464899f610274f1b823?d=identicon)[devrkb21](/maintainers/devrkb21)

---

Top Contributors

[![devrkb21](https://avatars.githubusercontent.com/u/215704528?v=4)](https://github.com/devrkb21 "devrkb21 (8 commits)")

---

Tags

laravelwebhookpayment gatewaybkashbangladeshtokenized-checkouttokenized-v2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devrkb21-bkash-pgw-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/devrkb21-bkash-pgw-laravel/health.svg)](https://phpackages.com/packages/devrkb21-bkash-pgw-laravel)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
