搜索插件、代码仓与 APP 分类

插件详情v1.0.1

flutter_bkash

用于支付网关服务 bKash(孟加拉国)的 Flutter 包。通过此包,您可以在 Flutter 项目中轻松实现 bKash 支付。

AndroidiOSmacOS
近 30 天下载
331
喜欢数
54
Pub 分数
160

安装插件

flutter pub add flutter_bkash

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_bkash 包是一个 Flutter 插件,可将孟加拉国领先的移动支付网关 bKash 无缝集成到 Flutter 应用程序中。它通过提供一个简单的 API 来启动交易、处理回调和管理支付状态,简化了实现 bKash 支付的过程。该包专为面向孟加拉国市场的开发者设计,支持 Android、iOS 和 macOS 平台。适用于电子商务应用、数字服务以及任何需要本地支付解决方案的应用程序。

适合场景

  • 孟加拉国的电子商务应用
  • 数字服务付款
  • 移动钱包集成
  • 在线账单支付
  • 应用内购买

主要特点

  • 轻松启动 bKash 交易
  • 支持 Android、iOS 和 macOS
  • 支付状态的回调处理
  • 安全支付处理
  • 使用 pub add 命令进行简单设置

适合对象

  • 面向孟加拉国的Flutter开发者
  • 需要本地支付方式的应用
  • 使用 bKash 作为支付选项的企业
  • 在孟加拉国构建金融服务的初创公司

使用建议

  • 需要 bKash 商家账户
  • 需要正确的 API 密钥配置
  • 仅限孟加拉国地区
  • 取决于 bKash 后端的可用性
  • 可能需要额外的服务器端验证

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

:warning: 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

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

dependencies:
    flutter_bkash: ^1.0.1

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';

Features

  • Pay using bKash without an agreement
  • Create a bKash agreement for future payments
  • Pay using bKash with an agreement
  • Refund a completed payment, fully or partially
  • Query the status of a refund

Usage

Official Link for API documentation and demo checkout

Initialize the FlutterBkash instance:

Sandbox

final flutterBkash = FlutterBkash();

Production

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

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",
);

Response

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

To create a new agreement, use the createAgreement method:

Request

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

Response

BkashAgreementResponse(
	payerReference:  , 
	paymentId: TR0000RCHQGmX1687063332607, 
	customerMsisdn: 01877722345, 
	agreementId: TokenizedMerchant02P1AIJ7G1687063381235, 
	_executeTime: 2023-06-18T10:43:01:235 GMT+0600
)
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",
);

Response

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

To refund a completed payment (full or partial), use the refund method. paymentId and trxId come from the pay/payWithAgreement response you're refunding. sku and reason are documented by bKash as optional, but the API rejects the request without them — pass both:

Request

final result = await flutterBkash.refund(
  paymentId: "TR0011fd4uZMS1687062024354",
  trxId: "AFI60BAC94",
  refundAmount: 50.0, // amount as double
  sku: "order-1234",
  reason: "customer requested refund",
);

Response

BkashRefundResponse(
	originalTrxId: AFI60BAC94, 
	refundTrxId: AFI60BAC95, 
	refundTransactionStatus: Completed, 
	originalTrxAmount: 100, 
	refundAmount: 50, 
	currency: BDT, 
	sku: order-1234, 
	reason: customer requested refund, 
	_completedTime: 2023-06-18T10:45:12:623 GMT+0600
)
Check Refund Status

To look up the refund(s) issued against a payment, use the refundStatus method:

Request

final result = await flutterBkash.refundStatus(
  paymentId: "TR0011fd4uZMS1687062024354",
  trxId: "AFI60BAC94",
);

Response

BkashRefundStatusResponse(
	originalTrxId: AFI60BAC94, 
	originalTrxAmount: 100, 
	originalTrxCompletedTime: 2023-06-18T10:22:31:623 GMT+0600, 
	refundTransactions: [BkashRefundStatusItem(refundTrxId: AFI60BAC95, refundTransactionStatus: Completed, refundAmount: 50, _completedTime: 2023-06-18T10:45:12:623 GMT+0600)]
)
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);
}

e.message carries bKash's actual error text when the API returns one (e.g. a specific refund rejection reason), falling back to a generic message (e.g. "Bad Request") only when the response has no parseable error body.

Examples for see the /example folder. The demo app also saves every payment/agreement/refund locally (History screen) so you can copy an ID or chain follow-up calls (e.g. pay with a saved agreement, refund a saved payment), and ships a Sandbox Info page with bKash's test wallet numbers, OTP and PIN.

Here is the example code link

Example Demo

flutter_bkash example demo
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.

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。