darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 130 forks source link

How to do the person to merchant transaction in ionic 4 using UPI #129

Closed adhikar-patil closed 3 years ago

adhikar-patil commented 3 years ago

Hello @darryncampbell , I am using com-darryncampbell-cordova-plugin-intent plugin for showing the installed UPI payment app and doing the transaction with that UPI in IONIC 4. But PhonePe, BHIM and Paytm payment applications working fine as well as it gives proper response. But when i am trying with Whatsapp Payment and CRED Payment it gives me response like that {"extras":{"resultCode":0,"requestCode":1},"flags":0}. What should i do for proper response? Below is my code in IONIC 4. Please provide me the proper solution.

payWithUPI() { const tid = this.getRandomString(); const orderId = this.getRandomString(); const totalPrice = 1.00; const UPI_ID = '9960777572@okbizaxis'; const UPI_NAME = 'Adhikar Patil'; const UPI_TXN_NOTE = 'TEST TXN';
let uri = upi://pay?pa=${UPI_ID}&pn=${UPI_NAME}&tid=${tid}&am=${totalPrice}&cu=INR&tn=${UPI_TXN_NOTE}&tr=${orderId}; // uri = uri.replace(' ', '+'); (window as any).plugins.intentShim.startActivity( { action: this.webIntent.ACTION_VIEW, url: uri,
requestCode: 1 }, intent => { if (intent.extras.requestCode === 1 && intent.extras.resultCode === (window as any).plugins.intentShim.RESULT_OK && intent.extras.Status && (((intent.extras.Status as string).toLowerCase()) === ('success'))) {
alert("Payment Success");
} else (intent.extras.requestCode === 1 && intent.extras.resultCode === (window as any).plugins.intentShim.RESULT_OK && intent.extras.Status && (((intent.extras.Status as string).toLowerCase()) === ('failed'))) { alert("Payment Failed ") ;
}
}, err => { alert('error ' + err); }); }

getRandomString() { const len = 10; const arr = '1234567890asdfghjklqwertyuiopzxcvbnmASDFGHJKLQWERTYUIOPZXCVBNM'; let ans = ''; for (let i = len; i > 0; i--) { ans += arr[Math.floor(Math.random() * arr.length)]; } return ans; }

darryncampbell commented 3 years ago

Is this a duplicate of https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/issues/128?

adhikar-patil commented 3 years ago

Is this a duplicate of #128?

Yes