6

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.

Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81
deep
  • 1,586
  • 1
  • 18
  • 29

2 Answers2

7

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 '%'.

deep
  • 1,586
  • 1
  • 18
  • 29
  • what is UPI in intent.setData(Uri.parse(UPI)); – Aman Verma Jan 20 '17 at 19:31
  • It is the url which is needed to be created and then used to invoke a PSP app. – deep Jan 22 '17 at 13:21
  • Thanks for the answer. I have got one more query.. As specified in the UPI docs any merchant can generate the URL like above and send it to user via mail or any chat application.. So I tried to send the URL via mail but it is not clickable...hence the chooser dialog of all the UPI apps in my device don't pop up ... However scanning the qr code of the same URL gives the desired result.. So I am asking is how to make those URL clickable in the mail or social messaging app – Aman Verma Jan 22 '17 at 17:49
  • Do u have any answers @deep – Aman Verma Feb 04 '17 at 19:21
  • Sorry mate. Never tried it. I am working on the backend side now and super busy :( if I find the answer, i'll make sure to post it. But I believe u'll be able to find that. Let us know :) – deep Feb 06 '17 at 12:37
  • Certainly...@deep – Aman Verma Feb 06 '17 at 12:39
  • @deep I am invoking PSP apps through UPI url on my web application. Is there a way to capture the response from the PSP apps? I am creating an api for my web app but not sure how to capture or listen to the response from PSP app. is it possible for a web app? if so, can you tell me how? Thank you! – RL Shyam Apr 04 '17 at 11:10
  • @RLShyam i know how to listen to the response from PSP app in android but not in Web. – deep Apr 04 '17 at 14:24
  • Doing the same described in your answer but getting response url like this txnId=undefined&responseCode=undefined&Status=undefined&txnRef=undefined everything is undefined. don't know why. – Rajdeep Paliwal Apr 11 '17 at 06:43
  • @RLShyam how do i invoke PSP app from web app? – Nobody Nov 30 '19 at 09:26
  • Hi @deep I am also facing same issue - Have you found any answers ? – KCN Sep 26 '20 at 07:18
0

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.

Aakash Uniyal
  • 1,519
  • 4
  • 17
  • 32
  • How do you get the response back after the transaction if you use the hyperlink in the web to launch an app like BHIM or Phone Pe? – Samarth Agarwal May 06 '19 at 22:24
  • generally your web app would wait and as soon as your server receives a callback HIT from the PSP that payment is done , it would notify the front end that payment is done and do whatever is necessary now. – Aakash Uniyal May 08 '19 at 09:12
  • Thank you for your answer but how do we define that url where I intend to receive the hit from PSP? – Samarth Agarwal May 09 '19 at 06:34
  • @SamarthAgarwal how to invoke a upi app from a desktop website? – Nobody Nov 30 '19 at 09:24