capacitor-community / stripe

Stripe Mobile SDK wrapper for Capacitor
MIT License
185 stars 75 forks source link

The client_secret provided does not match the client_secret associated with the PaymentIntent. #348

Open divyesh-savaliya opened 2 months ago

divyesh-savaliya commented 2 months ago

Platform

Describe the bug If a previous request failed due to an error, attempting to make a payment again result in the following message: "The client_secret provided does not match the client_secret associated with the PaymentIntent."

To Reproduce

  1. Make a payment using a real card while keeping the Stripe key in test mode.
  2. This should result in a failed payment due to the mismatch between the live card and the test environment.
  3. After the failed payment, attempt to call collectPaymentMethod with a new payment intent ID.
  4. You should encounter an error message indicating that the client secret provided does not match the client secret associated with the PaymentIntent.

    Another way to reproduce

  5. Connect to tap to pay
  6. Put app in background and then open the app
  7. Now try to make the payment
  8. It throws the error

Expected behavior It should open new payment sheet with new payment intent id.

Additional context Clear previous payment intent info if its failed.

Using Function:

rdlabo commented 2 months ago

After the failed payment, attempt to call collectPaymentMethod with a new payment intent ID.

If failed, another card can be tried in succession. If change collectPaymentMethod with PaymentIntent, you should run cancelCollectPaymentMethod before collectPaymentMethod.

rdlabo commented 2 months ago

Another way to reproduce

There does not appear to be a problem at this time. For longer periods of time, the Secret Key is likely to change and a revert algorithm will be required.

https://github.com/capacitor-community/stripe/assets/9690024/361e2ee1-c0c6-47d3-a029-5ced917d6c2d

rdlabo commented 2 months ago

@divyesh-savaliya Has this solved the problem? If so, close the Issue.