mkharibalaji / react-native-adyen-payment

React Native Adyen Payment
https://mkharibalaji.github.io/react-native-adyen-payment/
MIT License
35 stars 35 forks source link

`Promise.reject()` not running on iOS #9

Open murrple-1 opened 4 years ago

murrple-1 commented 4 years ago

During testing around the behaviour noted in #8, I noted unexpected behaviour on iOS.

When calling startPayment() with onError set, cancelling the payment by pressing Cancel calls the listener with code = "ERROR_CANCELLED" and error = "Transaction Cancelled".

However, calling startPaymentPromise() in this way:

(async () => {
    try {
        const response = await AdyenPayment.startPaymentPromise(AdyenPayment.SCHEME, componentData, paymentDetails);
        console.log('Success', response);
    } catch (e) {
        console.log('Error', e);
    }
})();

does not cause the catch block to be run. This is unexpected, as I would expect console.log('Error', e) to output something like:

Error { "code": "ERROR_CANCELLED", "error": "Transaction Cancelled" }
mkharibalaji commented 4 years ago

That's Weird.Let me check...

mkharibalaji commented 4 years ago

Hi @murrple-1 , It works as expected,

(async () => {
try{
        let response = await AdyenPayment.startPaymentPromise(AdyenPayment.SCHEME,componentData,paymentDetails)
        console.log(response);
      }catch(err){
        console.log("Error Code : ",err.code);
        console.log("Error Message ",err.message);
      }
})();

The only difference is you get the error object as

{code : "ERROR_CANCELLED", "message": "Transaction Cancelled"}

A Quick check - Did you remove the listener when switched testing to Promise way of catching the error ?

murrple-1 commented 4 years ago

Further testing incoming