Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
547 views
in Technique[技术] by (71.8m points)

android - UPI App Deep linking using Intent - inconsistent and buggy behavior

I have deeplinked UPI apps from my android native app using intent. I have tested this with various UPI apps like BHIM, PhonePe, AXIS, UnionBank, Pockets etc.

I created push payment URI. I am able to launch various UPI apps. However behaviour is quite inconsistent.

"upi://pay?pa=xxxxx@upi&pn=payee&am=5.00&tn=Test_Transaction"

  1. Most apps are responding when intent is onvoked. They get launched.
  2. few apps displayed the payment page correctly with amount. Rest apps did not display the page at all. PhonePe, Axis displayed. BHIM did not display payment page
  3. Payment completed successfully b y PhonePay and Axis ONLY
  4. After UPI payment was completed successfully, the UPI app is closed and control comes back to my app. However the response data is always NULL. NONE of the app is providing response data when payment is successful
  5. If payment fails or I cancel the payment in UPI app or I do not enter right PIN and close UPI app, most of the apps do not return response data.
  6. Only AXISPay returned response data : Intent { (has extras) }

Anyone - any comments? Why such inconsistent bahaviour?

Surprising is deeplinking not working with BHIM app.

I can share android code if someone want want to try.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It really works for the BHIM application also. Use this Code it works like a charm for every PSP enabled applications.

Note: Instead of using the "%" better to use "+" to replace the white space from the URL. That works better.

private String getUPIString(String payeeAddress, String payeeName, String payeeMCC, String trxnID, String trxnRefId,
                            String trxnNote, String payeeAmount, String currencyCode, String refUrl) {
    String UPI = "upi://pay?pa=" + payeeAddress + "&pn=" + payeeName
            + "&mc=" + payeeMCC + "&tid=" + trxnID + "&tr=" + trxnRefId
            + "&tn=" + trxnNote + "&am=" + payeeAmount + "&cu=" + currencyCode
            + "&refUrl=" + refUrl;
    return UPI.replace(" ", "+");
}

Then pass the parameters in the method and pass the string to the Intent in this way:

Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(UPI));
            Intent chooser = Intent.createChooser(intent, "Pay with...");
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                startActivityForResult(chooser, 1, null);
            }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...