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
- Through local asset
- Through web server (PHP)
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.
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.
- 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
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" />
Add following code in your <project-directory>/ios/Runner/Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key> <true/>
</dict>
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.
- 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
From the command line:
- Enter cd
(Replace
<app dir>
with your application’s directory.) - Run
flutter build apk --split-per-abi
(The flutter build command defaults to --release.)
From the command line:
- Connect your Android device to your computer with a USB cable.
- Enter
cd <app dir>
where<app dir>
is your application directory. - Run
flutter install.
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
└── ...
- 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.
git checkout master
from any folder in your localbkash_pgwclient_demo_flutter
repositorygit pull origin master
to ensure you have the latest main codegit checkout -b the-name-of-my-branch
(replacingthe-name-of-my-branch
with a suitable name) to create a branch
- Change/Add the codes
- Save the files and check the codes if it has successfl build config.
- If possible, test the codes the way you want.
git add -A && git commit -m "My message"
(replacingMy message
with a commit message, such asFixed App Crash
orAdded App Crash 28 Fix
) to stage and commit your changesgit push my-fork-name the-name-of-my-branch
- Go to the
bkash_pgwclient_demo_flutter
and you should see recently pushed branches. - Follow GitHub's instructions and open up a pull request.
- If possible, include screenshots of visual changes.