I am trying to create a merchant app which will generate a url based on NPCI's guidelines. This url will be shared as intent and the PSP app (Any registered bank app) should be able to listen to that url and get invoked.
I have formed a url like this:-
upi://pay?pa=icici/name&pn=USER_NAME&tid=422d97c1-f0fc-4bea-b24a-511ffa85e86f&am=442.87&tn=Test%transaction
Now I am sending the intent like this :-
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, UPI);
sendIntent.setType("text/plain");
startActivity(sendIntent);
Icici bank app is not being shown in the receiver apps. Am I creating the url correctly?
UPI being released quite recently, I am unable to get good resource over the internet.
Note - In the url, the tid(transaction id) is a random uuid being generated in my app.
Found the correct way to do that. You need to frame the URL in the proper way as mentioned in the question. After that, this URL has to be converted to URI and sent as data to the intent.
Intent intent = new Intent();
intent.setData(Uri.parse(UPI));
Intent chooser = Intent.createChooser(intent, "Pay with...");
startActivityForResult(chooser, 1, null);
After that, in your onActivityResult, check for the requestCode and id received intend data is null. If not, then the data will contain a stringExtra as response. This response will contain the status, transaction reference, transactionId and the response code.
Also, spaces in the url should be replaced with a '+' and not with '%'.
For an App to show up as the UPI intent receiver it needs to register this UPI uri in its Manifest file so that it can listen to this type of broadcast intent thrown by other Applications . Tried this via web and i was able to bring up "Phone Pe" app to pay for that particular Application . I have Bhim and Icici installed as well in my phone but they did not show up and "Phone Pe" was brought up by default, so i am assuming that they did not have the UPI uri Intent registered with them .
Edit : Android App to App I can open Phone Pe and BHIM , ICICI app i guess doesn't have this intent Registered so it did not show up.
来源:https://stackoverflow.com/questions/39384561/invoke-psp-app-with-upi-url