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

ActiveLibrary[Payment Processing](/categories/payments)

itsrafsanjani/laravel-bkash
===========================

Bkash Payment Gateway for Laravel

1.0.0(2y ago)213[1 PRs](https://github.com/itsrafsanjani/laravel-bkash/pulls)MITPHPPHP ^8.1

Since Sep 21Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (9)Versions (3)Used By (0)

Bkash Payment Gateway for Laravel
=================================

[](#bkash-payment-gateway-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cfc70ac4fc6e265024d72f2c7a5e7c8ff29a30c9beefb5c6d9672b209a06c035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69747372616673616e6a616e692f6c61726176656c2d626b6173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsrafsanjani/laravel-bkash)[![GitHub Tests Action Status](https://camo.githubusercontent.com/d94f49ba7c32b5274fa45d4ab7f59ecabda36f24aa9ce79c1159df7acb3c23a8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69747372616673616e6a616e692f6c61726176656c2d626b6173682f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/itsrafsanjani/laravel-bkash/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/892cf1f6003a20168d3d041ef55b84906950721d5620fcda2051b3d558a867d9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69747372616673616e6a616e692f6c61726176656c2d626b6173682f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/itsrafsanjani/laravel-bkash/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6e14361dbba73324d5c7c86ab0353a7be301878bc3df7d2e38fc5c2ee8f85856/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69747372616673616e6a616e692f6c61726176656c2d626b6173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itsrafsanjani/laravel-bkash)

Laravel Bkash is a Laravel package for Bkash Payment Gateway. It uses the Tokenized API of Bkash.

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

[](#installation)

You can install the package via composer:

```
composer require itsrafsanjani/laravel-bkash
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [
    'sandbox' => env('BKASH_SANDBOX', true), // true for testing, false for production

    'app_key' => env('BKASH_APP_KEY', ''),
    'app_secret' => env('BKASH_APP_SECRET', ''),
    'username' => env('BKASH_USERNAME', ''),
    'password' => env('BKASH_PASSWORD', ''),

    // bkash will send data to this url
    'callbackURL' => env('BKASH_CALLBACK_URL', 'http://127.0.0.1:8000/bkash/callback'),
    'timezone' => 'Asia/Dhaka',
];
```

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

[](#configuration)

- Setup `.env`

```
# true for testing, false for production
BKASH_SANDBOX=true
BKASH_APP_KEY=
BKASH_APP_SECRET=
BKASH_USERNAME=
BKASH_PASSWORD=
# bkash will send data to this url
BKASH_CALLBACK_URL=http://127.0.0.1:8000/bkash/callback
```

- Create route for bkash in `routes/web.php`

```
Route::get('/bkash/callback', [PaymentController::class, 'callback']);
```

- Add exception in `app\Http\Middleware\VerifyCsrfToken.php`

```
protected $except = [
    'bkash/*',
];
```

Usage
-----

[](#usage)

### Pay and Callback (Example Code for Controller)

[](#pay-and-callback-example-code-for-controller)

```
use Illuminate\Http\Request;
use ItsRafsanJani\Bkash\Data\CreatePaymentData;
use ItsRafsanJani\Bkash\Facades\Bkash;

class PaymentController extends Controller
{
    public function pay()
    {
        // ..
        // save payment related data in your database or anything
        // ..

        $invoiceId = uniqid(); // could be any string

        $response = Bkash::createPayment(
            new CreatePaymentData(
                amount: 20.50,
                payerReference: $invoiceId,
            )
        );

        // dd($response);

        return redirect()->away($response->bkashURL);
    }

    public function callback(Request $request)
    {
        // first you need to execute
        $executeResponse = Bkash::executePayment($request->paymentID);

        // then query
        $queryResponse =  Bkash::queryPayment($request->paymentID);

        // ..
        // update payment status
        // ..
    }
}
```

Available Methods and Response
------------------------------

[](#available-methods-and-response)

### Create Payment

[](#create-payment)

```
$invoiceId = uniqid(); // could be any string

$response = Bkash::createPayment(
    new CreatePaymentData(
        amount: 20.50,
        payerReference: $invoiceId,
    )
);

return response()->json($response);
```

### Example Response

[](#example-response)

```
{
    "statusCode": "0000",
    "statusMessage": "Successful",
    "paymentID": "TR0011J9EMqSy16948652*****",
    "bkashURL": "https://sandbox.payment.bkash.com/redirect/tokenized/?paymentID=TR0011J9EMqSy16948652*****&hash=4kRP(RZBQ8Xn15a_0x4gW79V0EUZoaJJJv!UJmd10(s1Cl3ciz8aolIOsQ!3vlOno*vkq3jO-76BCoN7f4c8Zfykw1vaPsarABG21694865217269&mode=0011&apiVersion=v1.2.0-beta",
    "callbackURL": "http://localhost:8000/api/bkash-callback",
    "successCallbackURL": "http://localhost:8000/api/bkash-callback?paymentID=TR0011J9EMqSy16948652*****&status=success",
    "failureCallbackURL": "http://localhost:8000/api/bkash-callback?paymentID=TR0011J9EMqSy16948652*****&status=failure",
    "cancelledCallbackURL": "http://localhost:8000/api/bkash-callback?paymentID=TR0011J9EMqSy16948652*****&status=cancel",
    "amount": "10",
    "intent": "sale",
    "currency": "BDT",
    "paymentCreateTime": "2023-09-16T17:53:37:268 GMT+0600",
    "transactionStatus": "Initiated",
    "merchantInvoiceNumber": "65059731*****"
}
```

### Execute Payment

[](#execute-payment)

```
$response = Bkash::executePayment($request->paymentID);

return response()->json($response);
```

### Example Response

[](#example-response-1)

```
{
  "statusCode": "0000",
  "statusMessage": "Successful",
  "paymentID": "TR0011f0CE1zl16944532*****",
  "payerReference": "64ff4dd*****",
  "customerMsisdn": "018777*****",
  "trxID": "AIB10*****",
  "amount": "10",
  "transactionStatus": "Completed",
  "paymentExecuteTime": "2023-09-11T23:31:24:581 GMT+0600",
  "currency": "BDT",
  "intent": "sale",
  "merchantInvoiceNumber": "64ff4dd6*****"
}
```

### Query Payment

[](#query-payment)

```
$response =  Bkash::queryPayment($request->paymentID);

return response()->json($response);
```

### Example Response

[](#example-response-2)

```
{
  "paymentID": "TR0011f0CE1zl16944532*****",
  "mode": "0011",
  "paymentCreateTime": "2023-09-11T23:26:49:676 GMT+0600",
  "paymentExecuteTime": "2023-09-11T23:31:24:581 GMT+0600",
  "amount": "10",
  "currency": "BDT",
  "intent": "sale",
  "merchantInvoice": "64ff4dd6*****",
  "trxID": "AIB10DO2ON",
  "transactionStatus": "Completed",
  "verificationStatus": "Complete",
  "statusCode": "0000",
  "statusMessage": "Successful",
  "payerReference": "64ff4dd*****"
}
```

### Search Transaction

[](#search-transaction)

```
$searchTransactionResponse = Bkash::searchTransaction($response['trxID']);

return response()->json($searchTransactionResponse);
```

### Example Response

[](#example-response-3)

```
{
  "trxID": "AIB10*****",
  "initiationTime": "2023-09-11T23:31:22:000 GMT+0600",
  "completedTime": "2023-09-11T23:31:22:000 GMT+0600",
  "transactionType": "bKash Tokenized Checkout via API",
  "customerMsisdn": "018777*****",
  "transactionStatus": "Completed",
  "amount": "10",
  "currency": "BDT",
  "organizationShortCode": "50***",
  "statusCode": "0000",
  "statusMessage": "Successful"
}
```

Testing
-------

[](#testing)

```
./vendor/bin/pest
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [itsrafsanjani](https://github.com/itsrafsanjani)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.8% 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

Unknown

Total

1

Last Release

964d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef20f3ae3b7ace03f0c1923e51af65f79a8b104b94015d0ea9a81c37e6f71683?d=identicon)[itsrafsanjani](/maintainers/itsrafsanjani)

---

Top Contributors

[![itsrafsanjani](https://avatars.githubusercontent.com/u/48161278?v=4)](https://github.com/itsrafsanjani "itsrafsanjani (25 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravellaravel-bkashitsrafsanjani

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

7812.3k](/packages/danestves-laravel-polar)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[creagia/laravel-redsys

Laravel Redsys Payments Gateway

2013.6k](/packages/creagia-laravel-redsys)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

188.5k](/packages/tarfin-labs-event-machine)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

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