initiateTransaction static method

Future<UpiTransactionResponse> initiateTransaction(
  1. {required UpiApplication app,
  2. required String receiverUpiAddress,
  3. required String receiverName,
  4. required String transactionRef,
  5. required String amount,
  6. String? url,
  7. String? transactionNote}
)

Start a UPI Transaction.

The parameters correspond to respective parameters in the UPI Linking Specification. Their names as appearing in the specification have been mentioned.

app represents a UPI payment app. One of the static members of UpiApplication.

receiverUpiAddress is recipient UPI VPA. An invalid value will result in InvalidUpiAddressException. See pa in UPI Linking Specification.

receiverName is the name of the recipient. See pn in specification.

transactionRef is an ID (typically unique if you need to identify each payment) for the UPI transaction. On Android its value is copied back in the response from the UPI payment app. See tr in UPI Linking Specification.

amount must be a string form of payment amount and must be valid currency (no more than 2 digits after decimal). The package also limits it to be <=1,00,000. An unacceptable value leads to InvalidAmountException. Some UPI payment apps or your payer account may have their own permanent or daily limits, which this package cannot control towards ensuring payment. See am in UPI Linking Specification.

transactionNote is a short description of the transaction. See tn in UPI Linking Specification.

url: See url parameter in UPI Linking Specification

Implementation

static Future<UpiTransactionResponse> initiateTransaction({
  required UpiApplication app,
  required String receiverUpiAddress,
  required String receiverName,
  required String transactionRef,
  required String amount,
  String? url,
  String? transactionNote,
}) async {
  final transactionDetails = TransactionDetails(
    upiApplication: app,
    payeeAddress: receiverUpiAddress,
    payeeName: receiverName,
    transactionRef: transactionRef,
    amount: amount,
    url: url,
    transactionNote: transactionNote,
  );
  return await _transactionHelper.transact(_channel, transactionDetails);
}