bKash Payment Gateway API for Laravel Framework.
- PHP >=7.4
- Laravel >= 6
Install msilabs/bkash
via the Composer package manager:
composer require msilabs/bkash
Optionally, publish the configuration file
php artisan vendor:publish --provider="Msilabs\Bkash\BkashServiceProvider"
Set .env configuration
BKASH_SANDBOX=true #for production use false
BKASH_APP_KEY=""
BKASH_APP_SECRET=""
BKASH_USERNAME=""
BKASH_PASSWORD=""
BKASH_CALLBACK_URL=""
Start local server.
php artisan serve
To get create-payment data visit /bkash-sandbox/create-payment
url
http://127.0.0.1:8000/bkash-sandbox/create-payment
To get execute-payment data visit /bkash-sandbox/execute-payment
url
http://127.0.0.1:8000/bkash-sandbox/execute-payment
included BkashPayment trait in your controller. like:
use Msilabs\Bkash\BkashPayment;
class BkashController extends Controller
{
use BkashPayment;
//
}
create payment
public function payment()
{
// your code
$response = $this->createPayment($amount, $invoice_id = null, $dynamic_callback_url = null);
if($response->bkashURL) {
return redirect($response->bkashURL);
}
}
execute payment
public function callback(Request $request)
{
$payment_id = $request->paymentID;
$status = $request->status;
if($paymentID && $status == 'success') {
$response = $this->executePayment($paymentID);
if($response->transactionStatus == 'Completed') {
$order_id = $response['merchantInvoiceNumber'];
$trxID = $response['trxID'];
// your code
}
}
// your code
}
set Live Credentials in .env
BKASH_SANDBOX=false
BKASH_APP_KEY=""
BKASH_APP_SECRET=""
BKASH_USERNAME=""
BKASH_PASSWORD=""
BKASH_CALLBACK_URL=""