devrkb21 / bkash-pgw-laravel
Production-ready Laravel integration for bKash Tokenized Checkout V2 (auth, payments, webhooks).
Requires
- php: ^8.1
- illuminate/cache: ^10.0|^11.0|^12.0
- illuminate/http: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.0
README
π 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.
π 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
Publish config:
php artisan vendor:publish --tag=bkash-config
Add credentials:
BKASH_ENV=sandbox BKASH_APP_KEY= BKASH_APP_SECRET= BKASH_USERNAME= BKASH_PASSWORD=
π³ Payment Flow
1. Create Payment
Bkash::payment()->createPayment([...]);
2. Handle Callback
Bkash::payment()->handleCallback(request()->all());
3. Query Payment
Bkash::payment()->queryPayment($paymentId);
4. Capture / Void
Bkash::payment()->capturePayment($paymentId); Bkash::payment()->voidPayment($paymentId);
π Agreement (Saved Wallet)
Bkash::agreement()->createAgreement([...]); Bkash::agreement()->executeAgreement($agreementId);
π° Refund API
Bkash::refund()->refundTransaction([ 'paymentId' => $paymentId, 'trxId' => $trxId, 'refundAmount' => '10', 'reason' => 'Customer request', ]);
π Webhook (Secure & Automatic)
Enable in config:
'enable_routes' => true,
Endpoint:
POST /bkash/webhook
Automatically handled:
- SNS Subscription confirmation
- Signature verification
- Replay attack protection
- Notification parsing
π 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
composer test
π¦ Requirements
- PHP 8.1+
- Laravel 10 / 11 / 12
π SEO Keywords
Laravel bKash payment gateway, bKash Laravel package, Bangladesh payment gateway Laravel, bKash Tokenized Checkout V2, Laravel payment integration bKash
π Roadmap
- Event system (PaymentSuccess, Failed)
- Queue-based webhook handling
- Multi-gateway support (bKash + Nagad + SSLCommerz)
π€ Contributing
PRs are welcome. Please ensure tests pass.
π License
MIT License
β Support
If this package helps you, please give it a star β It helps others discover the project.
β Support Development
If you find this package useful, you can support ongoing development: