laravel-bkash-pgw maintained by mrcarb0n
laravel-bkash-pgw
bKash PGW (Tokenized Checkout) integration for Laravel — payments, refunds, agreements, payouts, webhooks.
Features
- Payments — create, execute (idempotent), query, search
- Refunds — full or partial, up to 10 per transaction, with status lookup
- Agreements — saved-wallet mandates for PIN-only recurring charges
- Payouts — B2C disbursement and B2B merchant transfers (initiate/disburse/query)
- Webhooks — AWS SNS signature verification, auto-subscription, event dispatch
- Callbacks — redirect handler executes the payment and fires events
- Token cache — one grant per account, auto-refresh, lock against duplicate grants
- Error codes — 150+ bKash codes mapped to readable messages
Requirements
- PHP 7.4+
- Laravel 6+
- Guzzle 7+
- bKash merchant account (developer.bka.sh)
Installation
composer require mrcarb0n/laravel-bkash-pgw
php artisan bkash:install
Copy the variables from .env.example into your app's .env and fill in your sandbox credentials — see docs/installation.md.
Verify connectivity:
php artisan bkash:test-sandbox
Quick start
use Tiash\LaravelBkash\Facades\Bkash;
$response = Bkash::payment()->create([
'mode' => '0011',
'payerReference' => 'ORDER_123',
'callbackURL' => route('bkash.callback'),
'amount' => 100.00,
'currency' => 'BDT',
'intent' => 'sale',
'merchantInvoiceNumber' => 'INV_123',
]);
return redirect($response['bkashURL']);
Fulfil orders by listening for PaymentCompleted — full flow in docs/payments.md.
Documentation
| Doc | Contents |
|---|---|
| Installation | install, config, multi-account, cache store |
| Payments | create/execute/query/search, callback flow, events |
| Refunds | full/partial refunds, status, error codes |
| Agreements | saved-wallet mandate lifecycle |
| Payouts | B2C disbursement, B2B initiate/disburse/query |
| Webhooks | SNS verification, events, transaction types |
| Error handling | exceptions, error code map, retry behavior |
| Going live | production checklist |
Testing
composer test # 42 tests
vendor/bin/phpstan analyse --no-progress # static analysis
php artisan bkash:test-sandbox # live sandbox smoke test
Changelog
See CHANGELOG.md.
Security
If you find a vulnerability, open a private security advisory instead of a public issue.
License
MIT — see LICENSE.