I have written this code for accepting payments through UPI apps installed on user's phone. Everything seems fine until user tries to make the payment it fails in weird ways.
Google Pay -> "You have exceeded maximum transaction amount set by your bank".
Also Google Pay -> "Oops something went wrong".
Phonepe -> " Could not initiate transaction. Please try again.."
I did try searching on internet but couldn't find anything.
private fun payWithUPI() {
val uri: Uri = Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "my_vpa")
.appendQueryParameter("pn", "name")
.appendQueryParameter("mc", "merchant_id")
.appendQueryParameter("tr", "123456789")
.appendQueryParameter("am", "5.00")
.appendQueryParameter("cu", "INR")
.build()
val upiPayIntent = Intent(Intent.ACTION_VIEW)
upiPayIntent.data = uri
val chooser = Intent.createChooser(upiPayIntent, "Pay with")
if(null != chooser.resolveActivity(getPackageManager())) {
startActivityForResult(chooser, UPI_PAYMENT);
} else {
Toast.makeText(
this,
"No UPI app found, please install one to continue",
Toast.LENGTH_SHORT
).show()
}
}
PS : I have registered as a merchant in bhim sbi and using that vpa.