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 #128

Open adhikar-patil opened 3 years ago

adhikar-patil commented 3 years ago

Hello All, I am using webintent plugin for showing the installed UPI and doing the transaction with that UPI in IONIC 4. But PhonePe and Paytm 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

What should i do for proper response?

What do you expect the proper response to be? I am not familiar with WhatsApp payment

adhikar-patil commented 3 years ago

What should i do for proper response?

What do you expect the proper response to be? I am not familiar with WhatsApp payment

adhikar-patil commented 3 years ago

Hello All, I am using webintent plugin for showing the installed UPI and doing the transaction with that UPI in IONIC 4. But PhonePe and Paytm 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; }

adhikar-patil commented 3 years ago

Please help

darryncampbell commented 3 years ago

What should i do for proper response?

It sounds like you are asking for help understanding the UPI payment API. Is this an issue with this plugin? What is the equivalent native Android code to invoke this API?

adhikar-patil commented 3 years ago

What should i do for proper response?

What do you expect the proper response to be? I am not familiar with WhatsApp payment

When i am doing transaction with PhonePe, Paytm and BHIM app it gives response like that {"extras":{Status:"Success", "isExternalMerchant":true, "txtnRef":"y8H8KY9H3t","resultCode":-1,"TRANSACTION_STATUS":3,"resonse":"txnId=TbNP7mrT01&txnRef=y8H8KY9H3t&Status=Success&&responseCode=00","bleTxId":"T2107161611105787603273","txnId":"TbNPmrT01","requestCode":1, responseCode:"00"},"flags":0} but when i am trying with CRED, Whatsapp and Amazon Pay it gives me response like that {"extras":{"resultCode":0,"requestCode":1},"flags":0} after successful payment. How can i find it is successful or not?

darryncampbell commented 3 years ago

I suggest you contact the UPI development team with that, it would depend on how they have implemented their application which is sending you the response.