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

ActiveLibrary[Payment Processing](/categories/payments)

karim007/laravel-bkash
======================

This is bKash payment gateway for laravel

v2.0.0(3y ago)5818↓50%3[1 issues](https://github.com/karim-007/laravel-bkash/issues)MITPHPPHP ^7.4|^8.0|^8.1|^8.2

Since Dec 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/karim-007/laravel-bkash)[ Packagist](https://packagist.org/packages/karim007/laravel-bkash)[ RSS](/packages/karim007-laravel-bkash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Bkash Payment Gateway for PHP/Laravel Framework
===============================================

[](#bkash-payment-gateway-for-phplaravel-framework)

[![Downloads](https://camo.githubusercontent.com/58452a949a987f4a27e47e341ef923035ba5b2aa0ac7c4d9912170379ae19f70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6172696d3030372f6c61726176656c2d626b617368)](https://packagist.org/packages/karim007/laravel-bkash)[![Starts](https://camo.githubusercontent.com/0593c83de4cd85095b2bf0fbed6e1b4125168bd8196d3b9210771649259c05ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6b6172696d3030372f6c61726176656c2d626b617368)](https://packagist.org/packages/karim007/laravel-bkash)

Features
--------

[](#features)

This is a php/laravel wrapper package for [Bkash](https://developer.bka.sh/)

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

[](#requirements)

- PHP &gt;=7.4
- Laravel &gt;= 6

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

[](#installation)

```
composer require karim007/laravel-bkash
```

### vendor publish (config)

[](#vendor-publish-config)

```
php artisan vendor:publish --provider="Karim007\LaravelBkash\BkashServiceProvider"
```

After publish config file setup your credential. you can see this in your config directory bkash.php file

```
"sandbox"         => env("BKASH_SANDBOX", true),
"bkash_app_key"     => env("BKASH_APP_KEY", "5nej5keguopj928ekcj3dne8p"),
"bkash_app_secret" => env("BKASH_APP_SECRET", "1honf6u1c56mqcivtc9ffl960slp4v2756jle5925nbooa46ch62"),
"bkash_username"      => env("BKASH_USERNAME", "testdemo"),
"bkash_password"     => env("BKASH_PASSWORD", "test%#de23@msdao"),
"callbackURL"     => env("BKASH_CALLBACK_URL", "http://127.0.0.1:8000"),
'timezone'        => 'Asia/Dhaka',

```

### Set .env configuration

[](#set-env-configuration)

```
BKASH_SANDBOX=true  #for production use false
BKASH_APP_KEY=""
BKASH_APP_SECRET=""
BKASH_USERNAME=""
BKASH_PASSWORD=""
BKASH_CALLBACK_URL=""

```

Usage
-----

[](#usage)

### 1. create a controller

[](#1-create-a-controller)

```
php artisan make:controller BkashPaymentController

```

### 2. you can override the routes (routes must be in authenticate bkash prefer it)

[](#2-you-can-override-the-routes-routes-must-be-in-authenticate-bkash-prefer-it)

```
Route::group(['middleware' => ['auth']], function () {

    // Payment Routes for bKash
    Route::get('/bkash/payment', [BkashPaymentController::class,'index']);
    Route::post('/bkash/get-token', [BkashPaymentController::class,'getToken'])->name('bkash-get-token');
    Route::post('/bkash/create-payment', [BkashPaymentController::class,'createPayment'])->name('bkash-create-payment');
    Route::post('/bkash/execute-payment', [BkashPaymentController::class,'executePayment'])->name('bkash-execute-payment');
    Route::get('/bkash/query-payment', [BkashPaymentController::class,'queryPayment'])->name('bkash-query-payment');
    Route::post('/bkash/success', [BkashPaymentController::class,'bkashSuccess'])->name('bkash-success');

    // Refund Routes for bKash
    Route::get('/bkash/refund', [BkashPaymentController::class,'refundPage'])->name('bkash-refund');
    Route::post('/bkash/refund', [BkashPaymentController::class,'refund'])->name('bkash-refund');

});

```

### 3. you can also override the methods

[](#3-you-can-also-override-the-methods)

\#must be included in your controller

```
use Karim007\LaravelBkash\Facade\BkashPayment;
use Karim007\LaravelBkash\Facade\BkashRefund;

```

### 4. payment page

[](#4-payment-page)

```
public function index()
{
    return view('bkash::bkash-payment');
}

```

### 4. grand token get

[](#4-grand-token-get)

```
public function getToken()
{
    session()->put('invoice_amount',100);
    return BkashPayment::getToken();
}

```

### 4. create payment

[](#4-create-payment)

```
public function createPayment(Request $request)
{
    $request['intent'] = 'sale';
    $request['currency'] = 'BDT';
    $request['amount'] = session()->get('invoice_amount') ??100;
    $request['merchantInvoiceNumber'] = rand();
    $request['callbackURL'] = config("bkash.callbackURL");;

    $request_data_json = json_encode($request->all());

    return BkashPayment::cPayment($request_data_json);
}

```

### 5. execute payment

[](#5-execute-payment)

```
public function executePayment(Request $request)
{
    $paymentID = $request->paymentID;
    return BkashPayment::executePayment($paymentID);
}

```

### 6. query payment

[](#6-query-payment)

```
public function queryPayment(Request $request)
{
    $paymentID = $request->payment_info['payment_id'];
    return BkashPayment::queryPayment($paymentID);
}

```

### 7. success

[](#7-success)

```
public function bkashSuccess(Request $request)
{
    $pay_success = $request->payment_info['transactionStatus'];
    return BkashPayment::bkashSuccess($pay_success);
}

```

### 8. refundPage

[](#8-refundpage)

```
public function refundPage()
{
    return BkashRefund::index();
}

```

### 9. refund

[](#9-refund)

```
public function refund(Request $request)
{
    $this->validate($request, [
        'payment_id' => 'required',
        'amount' => 'required',
        'trx_id' => 'required',
        'sku' => 'required|max:255',
        'reason' => 'required|max:255'
    ]);

    $post_fields = [
        'paymentID' => $request->payment_id,
        'amount' => $request->amount,
        'trxID' => $request->trx_id,
        'sku' => $request->sku,
        'reason' => $request->reason,
    ];
    return BkashRefund::refund($post_fields);
}

```

#### Required APIs

[](#required-apis)

1. **Developer Portal** (detail Product, workflow, API information):
2. **Grant Token :**
3. **Create Payment :**
4. **Execute Payment :**
5. **Query Payment :**
6. **Search Transaction Details :**

### Checkout Demo

[](#checkout-demo)

1. Go to
2. **Wallet Number:** 01770618575
3. **OTP:** 123456
4. **Pin:** 12121

Contributions to the Bkash Payment Gateway package are welcome. Please note the following guidelines before submitting your pull request.

- Follow [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.
- Read Nagad API documentations first. Please contact with Nagad for their api documentation and sandbox access.

License
-------

[](#license)

This repository is licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright 2022 [md abdul karim](https://github.com/karim-007). We are not affiliated with Nagad and don't give any guarantee.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~39 days

Total

6

Last Release

1097d ago

Major Versions

v0.0.3 → v1.0.02022-12-15

v1.0.0.1 → v2.0.02023-05-18

PHP version history (2 changes)v0.0.1PHP ^7.4|^8.0|^8.1

v2.0.0PHP ^7.4|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1628a1636c45e8e246f880d1f2401497d66af3f657dba80a0f189b102e4b4ce7?d=identicon)[karim.cse007](/maintainers/karim.cse007)

---

Top Contributors

[![karim-007](https://avatars.githubusercontent.com/u/54572884?v=4)](https://github.com/karim-007 "karim-007 (11 commits)")

---

Tags

bkashbkash-payment-gatewaybkash-paymentlaravel-bkashlaravel-bkash-payment

### Embed Badge

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

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

###  Alternatives

[karim007/laravel-bkash-tokenize

This is bKash tokenize payment gateway for laravel

2221.1k](/packages/karim007-laravel-bkash-tokenize)[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)

PHPackages © 2026

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