FlutterUPI Plugin #
A flutter plugin to invoke UPI apps on the phone for Android and get the transaction information in response. This plugin supports only Android as of now.
Getting Started #
Simply import the plugin
And then use the
initiateTransaction method as shown in the code below.
String response = await FlutterUpi.initiateTransaction( app: FlutterUpiApps.PayTM, pa: "receiver@upi", pn: "Receiver Name", tr: "UniqueTransactionId", tn: "This is a transaction Note", am: "5.01", mc: "YourMerchantId", // optional cu: "INR", url: "https://www.google.com", ); print(response);
response is a
String that contains all the relevant information. Here is how the String looks like.
Please note that some parameters in the response can be undefined when using different apps.
Parsing the Response #
You can write your own logic to parse the response string or you can use the
FlutterUpiResponse class to create a
Map out of it.
FlutterUpiResponse flutterUpiResponse = FlutterUpiResponse(response); print(flutterUpiResponse.txnId); // prints transaction id print(flutterUpiResponse.txnRef); //prints transaction ref print(flutterUpiResponse.Status); //prints transaction status print(flutterUpiResponse.approvalRefNo); //prints approval reference number print(flutterUpiResponse.responseCode); //prints the response code
Supported Apps and Platforms #
As of now the plugin only supports Android. Since I am not an iOS developer, I have only been able to write the code for Android. If you are interested, feel free to get in touch or create PR if you can do this for iOS as well.
The plugins supports three apps as of now which I have tested this plugin with. You can use the predefined constants in the
FlutterUpiApps class and pass it to the
app named argument in the
FlutterUpiApps.BHIMUPI will launch the BHIM UPI App
FlutterUpiApps.GooglePay will launch the GooglePay App
FlutterUpiApps.PayTM will launch the PayTM App
FlutterUpiApps.PhonePe will launch the PhonePe App
FlutterUpiApps.MiPay will launch the MiPay App
FlutterUpiApps.AmazonPay will launch the AmazonPay App
FlutterUpiApps.TrueCallerUPI will launch the TrueCallerUPI App
FlutterUpiApps.MyAirtelUPI will launch the MyAirtelUPI App
Error Responses #
response String can contain any of the following strings as well.
app_not_installed : Application not installed.
invalid_params : Request parameters are wrong.
user_canceled : User canceled the flow.
null_response : No data received.
You need to write your own code to handle these responses in your app. Check out the example folder for more implementation details.
Report any issues if you face any or drop me an email at email@example.com #
- Added UPI Invocation with PhonePe, MyAirtelUPI, MiPay, TrueCallerUPI, AmazonPay Apps
- Added UPI Invocation with PayTM, BHIMUPI and GooglePay Apps
Demonstrates how to use the flutter_upi plugin.
Getting Started #
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: flutter_upi: ^0.0.2
2. Install it
You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Nov 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.0
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.6
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Health issues and suggestions
Document public APIs. (-1 points)
26 out of 26 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
lib/flutter_upi.dart. (-1 points)
lib/flutter_upi.dart reported 2 hints:
line 20 col 10: Name non-constant identifiers using lowerCamelCase.
line 21 col 10: Name non-constant identifiers using lowerCamelCase.
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of
0.0.*, it might mean that the author is still experimenting with the general direction of the API.