PHPackages                             arafatkn/laravel-bkash - 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. arafatkn/laravel-bkash

ActiveLibrary[Payment Processing](/categories/payments)

arafatkn/laravel-bkash
======================

bKash Tokenized Payment Gateway Implementation for Laravel

0.0.2(3mo ago)04MITPHPPHP ^8.0

Since Apr 13Pushed 3mo agoCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel bKash
=============

[](#laravel-bkash)

Laravel package for bKash Tokenized Payment Gateway integration.

Requirements
------------

[](#requirements)

- PHP ^8.0
- Laravel ^8.0

Installation
------------

[](#installation)

```
composer require arafatkn/laravel-bkash
```

The service provider and facade are registered automatically via Laravel's package auto-discovery.

Configuration
-------------

[](#configuration)

Publish the config file:

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

Add the following variables to your `.env` file:

```
BKASH_SANDBOX=true
BKASH_APP_KEY=your_app_key
BKASH_APP_SECRET=your_app_secret
BKASH_USERNAME=your_username
BKASH_PASSWORD=your_password
```

### Config Options

[](#config-options)

KeyDefaultDescription`sandbox``true`Use sandbox or live environment`debug``APP_DEBUG`Log all requests and responses`app_key``''`bKash app key`app_secret``''`bKash app secret`username``''`bKash username`password``''`bKash password`cache.refresh_token_lifetime``604800`Refresh token cache lifetime in seconds (7 days)`default_currency``BDT`Default payment currency`default_intent``sale`Default payment intentUsage
-----

[](#usage)

Use the `BkashTokenizedPayment` facade or resolve `Arafatkn\LaravelBkash\Tokenized\Payment` from the container.

### Create Payment

[](#create-payment)

Initiates a tokenized payment and returns a `bkashURL` to redirect the customer to.

```
use BkashTokenizedPayment;

$response = BkashTokenizedPayment::createPayment([
    'amount'                => '100',
    'merchantInvoiceNumber' => 'INV-001',
    'callbackURL'           => route('bkash.callback'),
    'payerReference'        => 'user_123',   // optional
    'currency'              => 'BDT',         // optional, defaults to config
    'intent'                => 'sale',        // optional, defaults to config
]);

// Redirect customer to payment page
return redirect($response['bkashURL']);
```

### Execute Payment

[](#execute-payment)

Called from your callback URL after the customer approves the payment.

```
$paymentID = $request->query('paymentID');

$response = BkashTokenizedPayment::executePayment($paymentID);

if ($response['statusCode'] === '0000') {
    // Payment successful
    $trxID = $response['trxID'];
}
```

### Query Payment

[](#query-payment)

Check the status of a payment by `paymentID`.

```
$response = BkashTokenizedPayment::queryPayment($paymentID);
```

### Search Transaction

[](#search-transaction)

Look up a transaction by bKash transaction ID.

```
$response = BkashTokenizedPayment::searchTransaction($trxID);
```

### Refund Transaction

[](#refund-transaction)

Initiate a refund for a completed payment.

```
$response = BkashTokenizedPayment::refundPayment(
    'TR0011xxxxxxxxxxx',
    'ADxxxxxxxx',
    [
        'amount' => '100',                           // optional
        'reason' => 'Customer requested refund',     // optional
        'sku'    => 'product-sku',                   // optional, defaults to 'NA'
    ]
);
```

Token Management
----------------

[](#token-management)

Token management is handled automatically. The package:

- Grants a new token on first use
- Caches the `id_token` based on the API-reported `expires_in` (minus 10 seconds as a safety buffer)
- Caches the `refresh_token` for 7 days
- Automatically uses the cached `refresh_token` to obtain a new `id_token` when it expires, avoiding a full re-authentication

Debugging
---------

[](#debugging)

To log all bKash API requests and responses, set in your `.env`:

```
BKASH_DEBUG=true
```

Or it will follow `APP_DEBUG` by default. Logs are written at the `debug` level via Laravel's Log facade.

Typical Payment Flow
--------------------

[](#typical-payment-flow)

```
1. createPayment()  → redirect customer to bkashURL
2. Customer approves on bKash
3. bKash redirects to your callbackURL with paymentID
4. executePayment() → confirm the payment
5. searchTransaction() or queryPayment() → verify if needed

```

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance81

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

102d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/80309866?v=4)[Arafat Islam](/maintainers/arafatkn)[@arafatkn](https://github.com/arafatkn)

---

Top Contributors

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

---

Tags

laravelpaymentgatewaybkash

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3518.3k](/packages/duncanmcclean-statamic-cargo)[evryn/laravel-toman

A simple stable Laravel package to handle popular payment gateways in Iran including ZarinPal and IDPay.

10710.5k](/packages/evryn-laravel-toman)

PHPackages © 2026

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