Is there any working sample to integrate UPI payment gateway using Android Deep Link. I went through NPCI specifications and implemented it with no success. Transaction is n
You can the list of all UPI apps on the device and use any app to initiate the transaction.
This is the function that you can use to fetch all the UPI apps.
private fun upiApps(context: Context): MutableList {
val upiOptions = mutableListOf()
// Set Parameters for UPI
val payUri = Uri.Builder()
payUri.scheme("upi").authority("pay")
payUri.appendQueryParameter("pa", "")
payUri.appendQueryParameter("pn", "")
payUri.appendQueryParameter("tid", "")
payUri.appendQueryParameter("mc", "")
payUri.appendQueryParameter("tr", "")
payUri.appendQueryParameter("tn", "")
payUri.appendQueryParameter("am", "")
payUri.appendQueryParameter("cu", "")
val paymentIntent = Intent(Intent.ACTION_VIEW)
paymentIntent.data = payUri.build()
val appList = context.packageManager.queryIntentActivities(paymentIntent, 0)
for (i in appList) {
// this is a custom model class
val paymentUpiOption = PaymentUpiOption(
i.loadLabel(context.packageManager).toString(),
i.activityInfo.packageName,
i.loadIcon(context.packageManager),
"upiTxn",
"UPI"
)
upiOptions.add(paymentUpiOption)
}
return upiOptions
}