react-native-upi
react-native-upi copied to clipboard
TypeError: undefined is not an object (evaluating 'responseString.split')
TypeError: undefined is not an object (evaluating 'responseString.split') on google pay
Just make convertStringToObject method in node_modules/react-native-upi-payment/android/src/main/java/com/upi/payment/UpiPaymentModule.java like,
convertStringToObject(responseString: string) {
let object = {};
const stringArray = responseString?.split('&');
object = stringArray?.reduce((accumulator, current) => {
const currentArray = current?.split('=');
accumulator[currentArray[0]] = currentArray[1];
return accumulator;
}, {});
return object;
},
Can you please tell me what responseString you are getting
To anyone facing this issue in the future, please note that @jaiminbhut's answer is correct but the file that you should edit is: node_modules/react-native-upi-payment/lib/UpiPayment.js
I think this has been done already.. Else you can give me a PR and will update a version
Replace your fucntion with this
convertStringToObject(responseString: string) { if(responseString === undefined){ return "" } else{ let object = {}; const stringArray = responseString.split('&'); object = stringArray.reduce((accumulator, current) => { const currentArray = current.split('='); accumulator[currentArray[0]] = currentArray[1]; return accumulator; }, {});
return object;
}},
it's worked for me !!
But why are you getting undefined from the responseString in the first place..
Also thanks for the suggestion. You can make a PR if youd want to
But why are you getting undefined from the responseString in the first place..
in my case if i don't set this thing and click on Gpay form chooser then app will crash and show the "TypeError: undefined is not an object (evaluating 'responseString.split') "