stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

Android 3D secure payment incorrectly fails with 'user canceled' if user has previously closed the payment sheet

Open zakgogiBH opened this issue 1 year ago • 2 comments

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:

  1. On an android device, open the stripe payment sheet
  2. Close the payment sheet manually
  3. Reopen the sheet, and pay with a card that triggers 3d secure (we've been using 4000000000003220 from this section of the docs)
  4. Authenticate the payment properly
  5. Payment will show as complete
  6. { error } from presentPaymentSheet will return user canceled error instead of success
  7. Attempting to reopen the sheet now will throw No payment sheet has been initialised error

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-native version 0.37.3 & 0.37.1

zakgogiBH avatar Apr 30 '24 16:04 zakgogiBH

+1 same problem on version 0.38.0 for example using the paymentMethode Paypal:

  1. Opening paymentsheet after initializing it, selecting Paypal and loading the webview
  2. Closing the Webview before anything presed
  3. 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}
  4. opening the paymentsheet again and paying successfully with paypal
  5. paymentsheet shows green tick but closes with the same error as seen before

jonxssc avatar Jun 21 '24 09:06 jonxssc

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

jonxssc avatar Jun 21 '24 10:06 jonxssc