stripe-react-native
stripe-react-native copied to clipboard
Android 3D secure payment incorrectly fails with 'user canceled' if user has previously closed the payment sheet
Describe the bug
If the user closes the payment sheet once, reopens the payment sheet, and then attempts to pay with a card that requires 3d secure authentication, the presentPaymentSheet function incorrectly returns a user canceled error. Visually, the payment sheet still provides positive feedback with a green tick, and the success web hooks fire as expected.
Trying to reopen the payment sheet again after this error then fails because the paymentIntent has been used, with No payment sheet has been initialised.
We've reproduced this in our own app with an android emulator as well as in the example repo.
To Reproduce
Steps to reproduce the behavior:
- On an android device, open the stripe payment sheet
- Close the payment sheet manually
- Reopen the sheet, and pay with a card that triggers 3d secure (we've been using
4000000000003220from this section of the docs) - Authenticate the payment properly
- Payment will show as complete
{ error }frompresentPaymentSheetwill returnuser cancelederror instead of success- Attempting to reopen the sheet now will throw
No payment sheet has been initialisederror
Expected behavior
We expect presentPaymentSheet to not return an error after successful payment with 3d secure in the scenario described above.
Smartphone (please complete the following information):
- Device: Pixel 5
- OS: Api 34
Additional context
- Tried on both
@stripe/stripe-react-nativeversion0.37.3&0.37.1
+1 same problem on version 0.38.0
for example using the paymentMethode Paypal:
- Opening paymentsheet after initializing it, selecting Paypal and loading the webview
- Closing the Webview before anything presed
- getting the correct error:
{"code": "Canceled", "declineCode": null, "localizedMessage": "The payment flow has been canceled", "message": "The payment flow has been canceled", "stripeErrorCode": null, "type": null} - opening the paymentsheet again and paying successfully with paypal
- paymentsheet shows green tick but closes with the same error as seen before
i made an workaround by just calling the same initPaymentSheet again after an error:
const {error} = await presentPaymentSheet();
if (error) {
console.log(error)
await initPaymentSheet({ ... }});
i dont think it is ment to do like this, but that works for me for now, would appreciate an better solution