Coder Social home page Coder Social logo

habiburrahman30 / bkash-pgwclient-demo-flutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chayanforyou/bkash-pgwclient-demo-flutter

0.0 0.0 0.0 2.42 MB

Quick Starter Flutter Boilerplate for Easy bKash Integration

Home Page: https://github.com/chayanforyou/bkash-pgwclient-demo-flutter

Java 25.63% HTML 6.40% CSS 0.52% Swift 0.19% Objective-C 16.44% Dart 50.29% Ruby 0.54%

bkash-pgwclient-demo-flutter's Introduction

Quick Starter Flutter Boilerplate for Easy bKash Integration

GitHub license PRs Welcome Maintenance Open Source Love svg1 made-with-love

An app with a simple easy-to-start boilerplate codebase for integrating bKash with ease. The whole app is developed using flutter with layers-by-features packaging & other standard practices. Here, I've implemented 2 way to Integrate bKash payment gateway with flutter

  1. Through local asset
  2. Through web server (PHP)

local Asset

No need to change anything for local testing purpose.

You must have to use patched version of webview_flutter (details discussion bellow), or can use flutter_inappwebview I'm working on flutter_inappwebview bKash payment integration.

Web Server

For server side implementation, Keep bKash_api_sandbox.zip files on your hosting & change the config.json with sandbox credential (Not work with live credential) app_key, app_secret, username & password. Nothing else needs to change. Then change the initialUrl of bkash_payment.dart in line initialUrl: 'http://your.hosting.com/bkash/payment.php' with your api host or localhost (for testing) link.

Note: You can use default webview_flutter plugin. Patched version not required.

Features

  • A Simple App with a button to Checkout
  • Pressing the button initiates bKash payment dialogs
  • Returns a screen with success & payment status if the mock payment is successful

Now you need to put the following implementations in Android and iOS respectively.

Android

Make sure to add this line android:usesCleartextTraffic="true" in your <project-directory>/android/app/src/main/AndroidManifest.xml under application like this.

<application
       android:usesCleartextTraffic="true">
</application>

Required Permissions are:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

iOS

Add following code in your <project-directory>/ios/Runner/Info.plist

<key>NSAppTransportSecurity</key>
  <dict>
    <key>NSAllowsArbitraryLoads</key> <true/>
  </dict>

Build Instructions

This project uses the flutter tool. Flutter and Dart plugins have to install in your machine. To run this project, use the flutter run command or use "Open Project" in Android Studio.

Prerequisites

  • Android Studio 3.5+. The latest version can be downloaded from here
  • Flutter 1.22.6
  • Dart 2.10.5
  • Build gradle 3.5.0+
  • Android SDK 29

Build an APK

From the command line:

  1. Enter cd (Replace <app dir> with your application’s directory.)
  2. Run flutter build apk --split-per-abi (The flutter build command defaults to --release.)

Install an APK on a device

From the command line:

  1. Connect your Android device to your computer with a USB cable.
  2. Enter cd <app dir> where <app dir> is your application directory.
  3. Run flutter install.

App Screenshots

Contributing

Directory Structure

The following is a high level overview of relevant files and folders.

bkash-pgwClient-demo-flutter/
├── android/
│   └── ...
├── assets/
│   └── www/
│       └── css, fonts, js & html files
├── ios/
│   └── ...
├── build/
│   └── ...
├── lib/
│   ├── model/
│   │   └── payment_request.dart
│   ├── pages/
│   │   ├── bkash_payment.dart
│   │   └── home_page.dart
│   ├── utility/
│   │   └── js_interface.dart
│   └── main.dart
├── test/
│   └── widget_test.dart
├── screenshots/
│   └── ...
├── webview_flutter/ (Patched WebView)
│   ├── android/
│   ├── ios/
│   ├── lib/
│   └── pubspec.yaml
├── bKash_api_sandbox.zip
├── local.properties
├── pubspec.lock
├── pubspec.yaml
├── README.md
└── ...

Patched WebView

  • The Flutter WebView plugin is in preview and at the moment it only loads URIs. It’d be nice if we can load local html (along with Javascript and CSS) files from local assets.
  • I followed this blog post made minimal changes to the plugin to provide a way to load asset files.

Create a branch

  1. git checkout master from any folder in your local bkash_pgwclient_demo_flutter repository
  2. git pull origin master to ensure you have the latest main code
  3. git checkout -b the-name-of-my-branch (replacing the-name-of-my-branch with a suitable name) to create a branch

Make the change

  1. Change/Add the codes
  2. Save the files and check the codes if it has successfl build config.

Test the change

  1. If possible, test the codes the way you want.

Push it

  1. git add -A && git commit -m "My message" (replacing My message with a commit message, such as Fixed App Crash or Added App Crash 28 Fix) to stage and commit your changes
  2. git push my-fork-name the-name-of-my-branch
  3. Go to the bkash_pgwclient_demo_flutter and you should see recently pushed branches.
  4. Follow GitHub's instructions and open up a pull request.
  5. If possible, include screenshots of visual changes.

bkash-pgwclient-demo-flutter's People

Contributors

chayanforyou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.