devrkb21/bkash-pgw-laravel

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

Maintainers

Package info

github.com/devrkb21/bkash-pgw-laravel

pkg:composer/devrkb21/bkash-pgw-laravel

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-19 23:15 UTC

This package is auto-updated.

Last update: 2026-04-19 23:29:25 UTC


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.

PHP Laravel License

πŸš€ 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:

πŸ‘‰ https://buymeacoffee.com/devrkb21

Your support helps maintain and improve this package ❀️ Buy Me A Coffee