How to check that UPI ID is working in real time or not in flutter?

Viewed 53

I have set validation to check valid format of UPI.

String validateUpiID(String value) {
  String pattern = '[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}';
  RegExp regExp = RegExp(pattern);
  if (value.isEmpty) {
    return 'Please Enter UPI ID';
  } else if (!regExp.hasMatch(value)) {
    return 'Please Enter valid UPI ID';
  }
  return "";
}

But Now I'm stuck there, How do I check that entered UPI is exist or in working mode ?

1 Answers

Use package upi_pay: https://pub.dev/packages/upi_pay

After calling the method initiateTransaction, you can get the status of the transaction

Future doUpiTransation(ApplicationMeta appMeta) {
  final UpiTransactionResponse response = await UpiPay.initiateTransaction(
    amount: '100.00',
    app: appMeta.application,
    receiverName: 'John Doe',
    receiverUpiAddress: 'john@doe',
    transactionRef: 'UPITXREF0001',
    transactionNote: 'A UPI Transaction',
  );
  print(response.status);
}
Related