Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

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

Open
adhikar-patil opened this issue Jul 15, 2021 · 7 comments
Open

Comments

@adhikar-patil
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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 adhikar-patil reopened this Jul 16, 2021
@adhikar-patil
Copy link
Author

Please help

@darryncampbell
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants