upi_connect 0.0.1-dev.1

SDKflutter
Platformandroid

A Flutter plugin designed to execute UPI transactions seamlessly using intent on Android devices.

UPI Connect

pub package

upi_connect is a Flutter plugin designed to execute UPI transactions seamlessly using an intent URL on Android devices. This plugin supports executing UPI transactions with various UPI apps installed on the device and provides a structured response back to the application, enabling easy handling of transaction results.

Table of Contents


Features

  • Executes UPI transactions using a URL intent on Android.
  • Supports handling responses after UPI transactions.
  • Currently supports Android only.

Installation

Add upi_connect as a dependency in your pubspec.yaml:

dependencies:
  upi_connect: latest_version

Run the following command:

flutter pub get

Examples

1. List All UPI Apps

Retrieve a list of UPI apps installed on the device.

List<UPIApp> upiApps = await UpiConnect.getAllApps();
upiApps.forEach((app) {
  print("UPI App: ${app.name}, Package: ${app.packageName}");
});
ParameterTypeDescription
nameStringApp's name
iconList<int>Icon as a list of bytes
packageNameStringPackage name for the app

2. Make UPI Transaction Using Intent URL

UPITransaction upiTransaction = UPITransaction.fromUrl(
  upiUrl: "upi://pay?pa=test@ybl&pn=test&am=1.00&tr=1210374251828217008&tn=Getupiapps&cu=INR&mode=04",
  onResponse: (UPITransactionResponse response) {
    _onResult(response.toString());
  },
  upiApp: upiApp,
);
Map? response = await upiTransaction.initiate();
print(response);
ParameterTypeDescription
upiUrlStringUPI intent URL string
onResponseFunction(UPITransactionResponse)Callback that receives the UPITransactionResponse
upiAppUPIApp?[Optional] UPI app to initiate the transaction

3. Make UPI Transaction by Passing Required Arguments

UPITransaction upiTransaction = UPITransaction(
  amount: 50.0,
  receiverName: "TestUser",
  receiverUpiId: "test@ybl",
  transactionId: "1234567890",
  transactionNote: "Test Transaction",
  onResponse: (UPITransactionResponse response) {
    _onResult(response.toString());
  },
  upiApp: upiApp,
);
Map? response = await upiTransaction.initiate();
print(response);
ParameterTypeDescription
amountdoubleTransaction amount
receiverNameStringReceiver's name
receiverUpiIdStringUPI ID of the receiver
transactionIdStringUnique ID for the transaction
transactionNoteStringOptional note for the transaction
onResponseFunction(UPITransactionResponse)Callback that receives the UPITransactionResponse
upiAppUPIApp?[Optional] UPI app to initiate the transaction

The upiTransaction.initiate() method returns a Map? as the response from the native layer. The response contains a key named status, which indicates the result of the transaction initiation:

  • "SUCCESS": The transaction was successfully initiated.
  • "ERROR": The transaction initiation failed.

API

Methods

UpiConnect.getAllApps()

Returns a list of installed UPI apps.

UPITransaction.fromUrl

Initializes a UPI transaction using a UPI intent URL.

UPITransaction

Configures a UPI transaction with specified parameters.

Response Format

The UPITransactionResponse model includes:

FieldTypeDescription
transactionIdStringTransaction's unique ID
responseCodeStringCode for the transaction's result
referenceIdStringReference ID of the transaction
statusTRANSACTIONSTATUSTransaction status (success, failure, other)
statusMessageStringMessage describing the transaction result
rawResponsedynamicOriginal response from the UPI app

Status Enum

  • TRANSACTIONSTATUS.success: Successful transaction.
  • TRANSACTIONSTATUS.failure: Failed transaction.
  • TRANSACTIONSTATUS.other: No response or unknown status.

Platform Support

  • Android: Supported
  • iOS: Not supported yet

Contributing

Feel free to submit issues and pull requests! Contributions help improve this plugin's functionality.

Support

For questions, open an issue or reach out directly.

License

This project is licensed under the MIT License - see the LICENSE file for details.