flutter_stripe icon indicating copy to clipboard operation
flutter_stripe copied to clipboard

confirmSetupIntent error handling on web

Open dioseltorre opened this issue 1 year ago • 1 comments

Describe the bug An error occured on Stripe.instance.confirmSetupIntent cannot be caught with StripeException or StripeError.

try {
  final setupIntentResult = await Stripe.instance.confirmSetupIntent(
    paymentIntentClientSecret: setupIntentClientSecret,
    params: PaymentMethodParams.card(
      paymentMethodData: PaymentMethodData(billingDetails: billingDetails),
    ),
    options: PaymentMethodOptions(
      setupFutureUsage: saveCard ? PaymentIntentsFutureUsage.OffSession : null,
    ),
  );
  // success
  // other process
} on StripeException catch (e) {
  print('StripeException ======= ${e.error}');
} on StripeError catch (e) {
  print('StripeError ======= $e');
} catch (e) {
  print('e.runtimeType==== ${e.runtimeType}');
  print('error==== $e');
}

sample error logs with the above code:

# resource_missing
e.runtimeType==== _$36_PaymentElementChangeEvent
error==== StripeError(type: invalid_request_error, code: resource_missing, decline_code: null, message: No such setupintent: 'seti_1Npjd7Q1g6dqCHAL3g9yLFGc', param: intent)

# setup_intent_authentication_failure
e.runtimeType==== _$36_PaymentElementChangeEvent
error==== StripeError(type: invalid_request_error, code: setup_intent_authentication_failure, decline_code: null, message: We are unable to authenticate your payment method. Please choose a different payment method and try again., param: null)

Expected behavior Should be able to catch the exception on StripeException to properly handle the error.

Smartphone / tablet

  • Device: Google Chrome Version 116.0.5845.187 (Official Build) (64-bit)
  • OS: Windows 11
  • Package version: flutter_stripe: ^9.4.0, flutter_stripe_web: ^4.4.0
  • Flutter version: Flutter 3.13.0 • channel stable

dioseltorre avatar Sep 13 '23 04:09 dioseltorre

yes I am also faced this issue

aalokhlink avatar Dec 13 '23 07:12 aalokhlink