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

ActiveLibrary[Payment Processing](/categories/payments)

abdursoft/laravel-bkash
=======================

This package or Library for Bkash, developed by abdursoft. This library come with MIT license, so you can easily change anything what ever your needs.This package will work for bkash tokenized payment system. If they are updated their version and the library couldn't work properly, please contact with abdursoft@gmail.com

0.0.4(1y ago)022MITPHP

Since Nov 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/abdursoft/laravel-bkash)[ Packagist](https://packagist.org/packages/abdursoft/laravel-bkash)[ RSS](/packages/abdursoft-laravel-bkash/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

Bkash tokenized payment gateway integration for PHP and Laravel applicaation
============================================================================

[](#bkash-tokenized-payment-gateway-integration-for-php-and-laravel-applicaation)

Now you can easily integrate bkash tokenized payment gateway into your PHP and laravel application. Just follow up the below process. Hope you will integrate the Bkash payment gateway successfully in your PHP or Laravel application

Now let's start with abdursoft/laravel-bkash. Run the below command to install the package.

```
composer require abdursoft/laravel-bkash
```

After installing the package you have to update `.env` file from your root folder with the below code.

```
BKASH_USERNAME=017xxxxxxx
BKASH_PASSWORD=D7xxxxxxxx
BKASH_APP_KEY=APKxxxxxxxx
BKASH_APP_SECRET=APSxxxxxxx
```

\[Note\] Remember you have to update these variable with your credentials.

If the package/library successfully installed on your project then make a controller in your laravel project.

```
php artisan make:controller BkashController
```

If your controller has been successfully created, open with your text editor and replace all code with below code.

```
namespace App\Http\Controllers;

use Abdursoft\LaravelBkash\Bkash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Validator;

class BkashController extends Controller
{

    protected $bkash;
    public function __construct()
    {

        $this->bkash = new Bkash(env('BKASH_USERNAME'),env('BKASH_PASSWORD'),env('BKASH_APP_KEY'),env('BKASH_APP_SECRET'),'sandbox',"http://127.0.0.1:8000/bkash/callback"); //use sandbox for sandbox testing and production for production service
    }

    /**
     * Create payment
     */
    public function createPayment(Request $request){
        $validator = Validator::make($request->all(),[
            'amount' => 'required',
            'reference' => 'required',
        ]);

        if($validator->fails()){
            return response()->json($validator->errors());
        }

        $payment = $this->bkash->paymentCreate($request->reference,$request->amount,uniqid());
        return redirect()->away($payment['bkashURL']);
    }

    /**
     * Refund payment
     */
    public function refundPayment(Request $request){
        $refund = $this->bkash->refund($request->id,$request->txn,$request->amount,$request->sku,$request->reason);
        if($refund['statusCode'] === '0000'){
            return redirect('/')->with('success',"Refund process has been completed");
        }else{
            return redirect('/')->with('error',"Refund process has been faild");
        }
    }

    /**
     * Bkash callback
     */
    public function callbackResponse(Request $request){
        if($request->query('status') == 'success'){
            $execute = $this->bkash->paymentExecute($request->query('paymentID'));
            Session::put(['paymentExecution' => $execute]);
            if($execute['statusCode'] == '0000'){
                return redirect('/')->with('success','Payment has been completed');
            }elseif($execute['statusCode'] == '2062'){
                return redirect('/')->with('success','Payment has already been compeled');
            }
        }elseif($request->query('status') == 'cancel'){
            return redirect('/')->with('error','Payment has been canceled');
        }elseif($request->query('status') == 'failure'){
            return redirect('/')->with('error','Payment has been faild');
        }else{
            return redirect('/')->with('error','Payment couldn\'t completed');
        }
    }
}
```

At this stage you have to initalize the payment routes for baksh gateway. You can put the below routes or You can create your owns.

```
Route::prefix('bkash')->group(function(){
    Route::post('payment', [BkashController::class, 'createPayment']);
    Route::post('refund', [BkashController::class, 'refundPayment']);
    Route::get('cancel', [BkashController::class, 'callbackResponse']);
    Route::get('callback', [BkashController::class, 'callbackResponse']);
});
```

Don't forget to add `use App\Http\Controllers\BkashController;` in your route page.

To create a payment, you have to pass some data such as `amount` `reference` `merchant_invoice_number` `callback_url`.

```
``amount`` for the payable amount.
```

```
``reference`` for the payment reference.
```

```
``merchant_invoice_number`` for futrue tracking the payment and remember it shuold be unique.
```

```
``callback_url`` bkash will redirect the user after payment processcing and you have to execute payment with this route's response.
```

To create a refund, you have to pass some data such as `transactionID` `paymentID` `amount` `reason` `sku`

```
``transactionID`` use from a completed transaction.
```

```
``paymentID`` use the paymentID from above transaction.
```

```
``amount`` use a valid amount for refund and make sure the amount not bigger than above transaction.
```

```
``reason`` for refund the transaction.
```

```
``sku`` for the transaction processing.
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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

4

Last Release

596d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/152814459?v=4)[Abdur Rahim](/maintainers/abdursoft)[@abdursoft](https://github.com/abdursoft)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.2k](/packages/msilabs-bkash)

PHPackages © 2026

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