flutter_bkash 0.2.0 copy "flutter_bkash: ^0.2.0" to clipboard
flutter_bkash: ^0.2.0 copied to clipboard

Flutter package for payment gateway service bKash (Bangladesh). bKash payment easy to implement through this package on your flutter project.

bKash(BD) Mobile Finance Payment Gateway Flutter Package

Pub License PRs Welcome Maintenance Open Source Love svg1

This is a Flutter package for bKash BD Payment Gateway. This package can be used in flutter project. We created this package while working for a project and thought to release for all so that it helps.

⚠️ Please note that, you have to contact with bKash sales team for any kind of dev or production access keys or tokens. We don't provide any test account or access keys or don't contact us for such

Check the package in github and also available in flutter/dart package

How to use: #

Depend on it, Run this command With Flutter:

$ flutter pub add flutter_bkash
copied to clipboard

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
    flutter_bkash: ^0.2.0
copied to clipboard

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more. Import it, Now in your Dart code, you can use:

import 'package:flutter_bkash/flutter_bkash.dart';
copied to clipboard

Features #

  • Pay using bKash without an agreement
  • Create a bKash agreement for future payments
  • Pay using bKash with an agreement

Usage #

Official Link for API documentation and demo checkout

Initialize the FlutterBkash instance: #

Sandbox

final flutterBkash = FlutterBkash();
copied to clipboard

Production

final flutterBkash = FlutterBkash(
	credentials: BkashCredentials(
    username: "app_username",
    password: "app_password",
    appKey: "app_key",
    appSecret: "app_secret",
    isSandbox: false,
  ),
);
copied to clipboard

Make sure to replace the provided credentials with your own bKash sandbox or production credentials depending on your development environment.

Pay without Agreement #

To make a payment without an agreement, use the pay method:

Request

final result = await flutterBkash.pay(
      context: context, // BuildContext context
      amount: 100.0, // amount as double
      merchantInvoiceNumber: "invoice123",
);
copied to clipboard

Response

BkashPaymentResponse(
	trxId: AFI60BAC94, 
	payerReference:  , 
	paymentId: TR0011fd4uZMS1687062024354, 
	customerMsisdn: 01877722345, 
	merchantInvoiceNumber: tranId, 
	_executeTime: 2023-06-18T10:22:31:623 GMT+0600
)
copied to clipboard

Create Agreement #

To create a new agreement, use the createAgreement method:

Request

final result = await flutterBkash.createAgreement(context: context);
copied to clipboard

Response

BkashAgreementResponse(
	payerReference:  , 
	paymentId: TR0000RCHQGmX1687063332607, 
	customerMsisdn: 01877722345, 
	agreementId: TokenizedMerchant02P1AIJ7G1687063381235, 
	_executeTime: 2023-06-18T10:43:01:235 GMT+0600
)
copied to clipboard

Pay with Agreement #

To make a payment with an existing agreement, use the payWithAgreement method:

Request

final result = await flutterBkash.payWithAgreement(
  context: context, // BuildContext context
  amount: 100.0, // type as double
  agreementId: "agreement123",
  merchantInvoiceNumber: "invoice123",
);
copied to clipboard

Response

BkashPaymentResponse(
	trxId: AFI60BAC94, 
	payerReference:  , 
	paymentId: TR0011fd4uZMS1687062024354, 
	customerMsisdn: 01877722345, 
	merchantInvoiceNumber: tranId, 
	_executeTime: 2023-06-18T10:22:31:623 GMT+0600
)
copied to clipboard

Error Handling #

The methods mentioned above may throw a BkashFailure exception in case of an error. You can catch and handle the exception using a try-catch block:

try {
  // Make a payment or create an agreement
} on BkashFailure catch (e) {
  // Handle the error
  print(e.message);
}
copied to clipboard

Examples for see the /example folder.

Here is the example code link

Importance Notes #

Contributing #

Core Maintainer

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

  • Follow Effective Dart: Style coding standards.
  • Read bKash API documentations first.Please contact with bKash for their api documentation and sandbox access.

License #

flutter_bkash package is licensed under the BSD 3-Clause License.

Copyright 2023 Codeboxr.com Team. We are not affiliated with bKash and don't give any guarantee.

46
likes
140
points
143
downloads

Publisher

verified publishercodeboxr.com

Weekly Downloads

2024.09.08 - 2025.03.23

Flutter package for payment gateway service bKash (Bangladesh). bKash payment easy to implement through this package on your flutter project.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, fpdart, http, webview_flutter

More

Packages that depend on flutter_bkash