问题
We have developed an IONIC based mobile app to perform In-App payment using UPI. It uses IONIC Native Web Intent plugin. a. b. "@ionic-native/web-intent": "^4.14.0",
This is shim layer for the Android intent mechanism and makes web intent call to BHIM/PhonePe/GooglePay
It works well with all UPI apps like BHIM, PhonePe. But does not work with GooglePay, For some reason with same code , Google Pay returns NULL Intent to OnActivityResult() even though the UPI Payment is successful.
I wrote similar functionality in a sample Native Android app and tried payment with GooglePay and it works
So I am baffled. I did debug my IONIC app and that is where I found that after GooglePay payment is successful, the call back returns to Android and then to Cordova and then to my application. It seems either Intent code of Android or GooglePay code is sending null Intent to caller app.
Appreciate any feedback on this.
Thank you and warm regards
Haresh Gujarathi
回答1:
Below is the code i'm using in my Ionic project for UPI payment in Android. I'm able to get response from Google pay. I have tested this with Paytm, Whatsapp and Google pay.
// I'm using this to open the app user has choosen to pay with
private packages = {
'paytm': 'net.one97.paytm',
'google': 'com.google.android.apps.nbu.paisa.user',
'whatsapp': 'com.whatsapp'
};
// Deep link URL
const url = 'upi://pay?pa=<UPI ID>&pn=<Payee name>&tr=<Transaction ID>&tn=<id>&am=<amount>&cu=INR';
// Deep link options
const options = {
action: this.webIntent.ACTION_VIEW,
url,
package: this.packages[serviceName]
};
// Open the intent with options
this.webIntent.startActivityForResult(options).then(console.log, console.error);
来源:https://stackoverflow.com/questions/52453686/upi-deeplinking-from-ionic-to-googlepay-does-not-work-as-expected