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.
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.
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
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
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.
Demonstrates how to use the flutter_upi plugin.
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.
Add this to your package's pubspec.yaml file:
dependencies: flutter_upi: ^0.0.2
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.
Now in your Dart code, you can use:
|0.0.2||May 20, 2019|
|0.0.1||May 13, 2019|
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 Jun 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
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.
Support latest dependencies. (-5 points)
The version constraint in
pubspec.yaml does not support the latest published versions for 1 dependency.
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.