capacitor-community / stripe

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

Error handling for the confirmSetupIntent #57

Closed HardikDG closed 2 years ago

HardikDG commented 3 years ago

How to handle the error from the Stripe for the confirmSetupIntent?

I have used this as provided in the documentation

const res = await Stripe.confirmSetupIntent({
  clientSecret,
  card: {
      number: '4000000000009995',
      exp_month: 12,
      exp_year: 25,
      cvc: '224',
  },
  redirectUrl: 'https://app.myapp.com', // Required for Android
});

When I use "4000000000009995" test card as per Stripe documentation it will give me error in the response. In my current implementation it shows unhandled exception and refresh the pages. I am not getting any proper response message from the Stripe.

So my question is how to handle the errors from Stripe from the res object

ihadeed commented 3 years ago

You need to wrap the function call With a try/catch. Alternatively you could use .catch() directly since that function returns a promise

HardikDG commented 3 years ago

I have tried with try/catch still it's having issue with that. Did anyone tried with this type of card which open 3DS pages? For ex: "4000 0082 6000 3178"

In Android,It creates another web view and tries to destroy the web view so you are not having control of the function where you are executing

rdlabo commented 2 years ago

Thanks for issue! Today this plugin of v3 is released. This not compatible with v1. All APIs have been revamped. So I will close this issue. If you still have the same problem, please create a new Issue. Thank you.