Flutter/dart package for payment gateway bKash (Bangladesh)

Overview

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

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

dependencies:
    flutter_bkash: ^0.1.3

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

Usage

Official Link for API documentation and demo checkout

Examples for see the /example folder.

Here is the example code

BkashPayment(  
    // depend isSandbox (true/false)
    isSandbox: true,
    // amount of your bkash payment
    amount: '20',
    /// intent would be (sale / authorization)
    intent: 'sale',
    // accessToken: '', /// if the user have own access token for verify payment
    // currency: 'BDT',
    /// bkash url for create payment, when you implement on you project then it be change as your production create url, [when you send it on sandbox mode, send it as empty string '' or anything]
    createBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/create',
    /// bkash url for execute payment, , when you implement on you project then it be change as your production create url, [when you send it on sandbox mode, send it as empty string '' or anything]
    executeBKashUrl: 'https://merchantserver.sandbox.bka.sh/api/checkout/v1.2.0-beta/payment/execute',
    /// for script url, when you implement on production the set it live script js (https://scripts.pay.bka.sh/versions/1.2.0-beta/checkout/bKash-checkout-pay.js)
    scriptUrl: 'https://scripts.sandbox.bka.sh/versions/1.2.0-beta/checkout/bKash-checkout-sandbox.js',
    /// the return value from the package
    /// status => 'paymentSuccess', 'paymentFailed', 'paymentError', 'paymentClose'
    /// data => return value of response
     
    paymentStatus: (status, data) {
    dev.log('return status => $status');  
    dev.log('return data => $data');

    /// when payment success  
    if (status == 'paymentSuccess') {
        if (data['transactionStatus'] == 'Completed') {
            Style.basicToast('Payment Success');  
        }
    }  
      
    /// when payment failed  
    else if (status == 'paymentFailed') {
        if (data.isEmpty) {
            Style.errorToast('Payment Failed');
        } else if (data[0]['errorMessage'].toString() != 'null'){
            Style.errorToast("Payment Failed ${data[0]['errorMessage']}");
        } else {  
            Style.errorToast("Payment Failed");
        }
    }  
      
    /// when payment on error  
    else if (status == 'paymentError') {
        Style.errorToast(jsonDecode(data['responseText'])['error']);
    }  
      
    /// when payment close on demand closed the windows  
    else if (status == 'paymentClose') {
        if (data == 'closedWindow') {
            Style.errorToast('Failed to payment, closed screen');
        } else if (data == 'scriptLoadedFailed') {
            Style.errorToast('Payment screen loading failed');
        }
    }
    /// back to screen to pop()
    Navigator.of(context).pop();
    },
)

Importance Notes

  • Read the comments in the example of code
  • See the documents and demo checkout bKash API Specifications, bKash Payment Checkout Demo
  • intent - it would be 'sale' or 'authorization'
  • Payment status return as 'paymentSuccess', 'paymentFailed', 'paymentError', 'paymentClose', find on this keyword of the payment status, then you get the data of response on specific status.

Contributing

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 2022 Codeboxr.com Team. We are not affiliated with bKash and don't give any guarantee.

You might also like...

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Jan 1, 2023

A Dart/Flutter package to register/query/remove URI Schemes without hassle.

protocol_registry Register/query/remove URI Schemes without hassle. Available for Windows and Linux. Installation flutter pub add protocol_registry Us

Oct 25, 2022

Dynamic Text Highlighting (DTH) package for Dart & Flutter.

Dynamic Text Highlighting (DTH) package for Dart & Flutter.

Dynamic Text Highlighting (DTH) This package is used to highlight, in a completely dynamic way, keywords, or phrases, wherever they are present in a s

Oct 3, 2022

This Dart package will utilize the plugin, google_mobile_ads, so to quickly and easily implement ads into a Flutter app.

This Dart package will utilize the plugin, google_mobile_ads, so to quickly and easily implement ads into a Flutter app.

Ads to your App in a Snap! This Dart package will utilize the plugin, google_mobile_ads, so to quickly and easily implement ads into a Flutter app

Sep 11, 2022

Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects

Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects

Dart/Flutter package for using Elastic App Search through a simple API returning easy to handle objects This package is a ready-to-use API for Elastic

Nov 16, 2022

A Dart FFI package to send 💬 toasts on Windows. Written in C++, based on WinToast.

A Dart FFI package to send 💬 toasts on Windows. Written in C++, based on WinToast.

desktoasts A Dart package to send native 💬 toasts on Windows. Installation For Flutter dependencies: ... desktoasts: ^0.0.2 For Dart CLI here Sup

Mar 7, 2022

Dart package to rank proposals according to Majority Judgment, using a score-based algorithm for performance and scalability

Majority Judgment for Dart This Dart package helps to resolve polls using Majority Judgment. Features Efficient Majority Judgment algorithm, scales we

Oct 18, 2021

Actor model implementation in Dart. This package makes it easier to work with isolates, create clusters of isolates.

Actor model implementation in Dart. This package makes it easier to work with isolates, create clusters of isolates.

Actor model implementation in Dart Languages: Introduction About Theater Installing What is Actor Notes about the actors Actor system Actor tree Using

Nov 14, 2022

Tools for Dart package maintainers

Tools for Dart package maintainers

Cider (CI for Dart. Efficient Release) A command-line utility to automate package maintenance. Manipulates the changelog and pubspec.yaml. This tool a

Dec 14, 2022
Comments
  • use enum instead of string for payment status

    use enum instead of string for payment status

    Using String

    status == 'paymentSuccess'
    status == 'paymentFailed'
    status == 'paymentError'
    status == 'paymentClose'
    

    Enum

    enum PaymentStatus {
      Success,
      Failed,
      Error,
      Close
    }
    

    Using enum

    switch (status) {
        case PaymentStatus.Success:
          // do something
          break;
        case PaymentStatus.Failed:
          // do something
          break;
        case PaymentStatus.Error:
          // do something
          break;
        case PaymentStatus.Close:
          // do something
          break;
      }
    
    
    enhancement 
    opened by Musfick 1
Releases(v0.1.3)
Owner
Codeboxr CodeHub
Open source contribution from codeboxr.com
Codeboxr CodeHub
A flutter plugin for integrating razorpay payment gateway. Supports Android and iOS.

Flutter Razorpay Plugin A flutter plugin for razorpay integration for both android and ios. If you use this library in your app, please let me know an

Chetan Kaushik 28 Dec 13, 2022
Integrate Razorpay payment gateway flutter in just 15 minutes

How to Integrate Flutter Payments with Razorpay Payment Gateway Learn how to integrate payment gateway with Razorpay in less than 15 minutes, other ti

Sanskar Tiwari 25 Nov 25, 2022
Zaincash payment gateway integration for flutter

zaincash_flutter A none offical Zaincash payment gateway integration for flutter INSTALL in your project terminal enter dart pub add zaincash USE F

Karrar S. Honi 1 May 20, 2022
A shopping cart application that lets the user create an account, select items, save the items in the cart, pay using the payment gateway, change account details and check order history.

Shopping Cart A new Flutter application. The main code file has all the code required for the mobile application. Getting Started This project is a st

null 1 Oct 14, 2021
Item selling mobile app with secure payments with Payhere payment gateway. Auto APK generation with github actions CI/CD.

payhere_demo A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Shihara Dilshan 2 Jan 20, 2022
Lightweight SMS Misr gateway implementation in dart (unofficial).

palestine_sms_misr (unofficial) Part of PalestineDevelopers Lightweight SMS Misr gateway implementation in dart (unofficial). Table Of Contents Featur

Palestine Developers 3 Mar 10, 2022
P2P payment solution using Stream's Flutter SDK and Rapyd's Wallet API

Peer-to-peer payment integration to a messaging app using Flutter ?? This project shows how to integrate a peer-to-peer payment solution to your Strea

Souvik Biswas 15 Dec 8, 2022
Official Flutter SDK for Khalti Payment systems

Khalti Payment Gateway for Flutter Use Khalti Payment Gateway solution in your app or website to simplify payment for your customers. You do not need

Khalti 16 Oct 13, 2022
Attendance and Payment manager

Manage Me Application A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Rohit Karnawat 1 Oct 16, 2021
Online wallet app for money transfer and bill payment.

shapshapcoins Payment Platform Getting Started This project is a starting point for a Flutter application. A few

Ndoye Philip Ndula 1 Nov 14, 2021