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

`onError()` listener and `Promise.reject()` not running on Android #8

Closed murrple-1 closed 4 years ago

murrple-1 commented 4 years ago

After applying the pull request #7 manually to bypass the crash, I am seeing unexpected behaviour on Android.

When calling startPayment() with onError set, cancelling the payment by clicking off the overlay does not call the onError listener. This is different from how it's behaving on iOS, where pressing Cancel calls the listener with code = "ERROR_CANCELLED" and error = "Transaction Cancelled".

Similarly, 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 (though this is consistent with iOS, second issue incoming).

mkharibalaji commented 4 years ago

Is this happening only for "Cancelling" Action ?

Possibly removing the DropInRequestCode check should make it work under AdyenPaymentModule.kt in line 564,

if (requestCode == DropIn.DROP_IN_REQUEST_CODE && resultCode == Activity.RESULT_CANCELED)

Let me also run it and update you soon. Just giving a hint on the issue if it is just cancelling action.

murrple-1 commented 4 years ago

On Android, there is not a "Cancel" button like on iOS. You either drag the pop-over off the screen, or you click off it to make it cancel. I have supplied a GIF to show behaviour.

mkharibalaji commented 4 years ago

I just sticked with the dropIn modal of adyen and had plans for customizing the ui where i thought of adding cancel button.

mkharibalaji commented 4 years ago

The BottomSheet State needs to be tracked to make the cancelling behaviour work.

mkharibalaji commented 4 years ago

Issue Fixed. Please test and let me know.

murrple-1 commented 4 years ago

I haven't fully tested this due to some issues around the project in general, but initially this looks good. I will post back with an update further, hopefully soon.