Reputation: 381
Trying to connect the UPI payment using deeplink for my Android application, but every-time it fails at the last step.
The code fragment for the UPI payment call is below:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
URI_URL = getUPIString("xxx@upi", "xxx xxx", "test_101", "Test Transaction", "10", "INR");
//Creating an intent for the UPI APP
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(URI_URL));
Intent chooser = Intent.createChooser(intent, "Pay the MSME by");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
startActivityForResult(chooser, 1, null);
}
}
});
To frame the UPI String using this function:
private String getUPIString(String payeeAddress, String payeeName, String trxnRefId,
String trxnNote, String payeeAmount, String currencyCode) {
String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
+ "&tr=" + trxnRefId
+ "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode;
return UPI.replace(" ", "+");
}
What could be the possible reasons of failure? Any suggestion or help is welcome.
Upvotes: 0
Views: 3561
Reputation: 584
I have worked on UPI and integrate it into my Android project. I have also created a GitHub repository which can be useful for you.
Using deep linking, You will get mostly UPI supporting app but the problem is all app doesn't return value properly. I have tested Paytm, Google pay and freecharge and many more. But These app return value very well. Due to this problem, I have created custom intent chooser so that exclude those apps who don't return value after payment. Along with this, you will get code of QR code to generate and scan UPI QR code.
Want to know more, here is a document.
Do check it and let me know, it helps you or not. Problem ask me.
Upvotes: 2
Reputation: 411
The error is T04 meaning the refId should be alphanumeric with minlength 1 and maxlength 35. instead of test_101 use test101.
Upvotes: 2