flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
927 stars 511 forks source link

Can't catch error code from flutter_stripe_web #1297

Open mminhlequang opened 1 year ago

mminhlequang commented 1 year ago

https://stripe.com/docs/testing?testing-method=card-numbers#declined-payments I try catch error code and follow this docs to show clean message for user but can't get it from flutter web app, it was throw js object. Someone can help? Thanks!

remonh87 commented 1 year ago

Can you give us more information? Which method are you calling from our sdk, reproduction code, which flutter version, version of our sdk etc.

mminhlequang commented 1 year ago

Hi i using latest version flutter_stripe_web: ^4.2.0

my method: WebStripe.instance.confirmPaymentElement WebStripe.instance.confirmPayment

mminhlequang commented 1 year ago
   await WebStripe.instance.confirmPayment(
        payOrderResult!.stripeClientSecret!,
        const PaymentMethodParams.card(
            paymentMethodData: PaymentMethodData(),
        ),
    );

    appDebugPrint('[Payment debug] done');

    } on StripeException catch (e) {
      appDebugPrint('[Payment debug] StripeException: ${e.error}');
    } on StripeError catch (e) {
      appDebugPrint('[Payment debug] StripeError: ${e.code}');
    } catch (e) {
      appDebugPrint(
          '[Payment debug] error: ${e.runtimeType}\n${stringify(e)}');
      //Always here        }
mminhlequang commented 1 year ago

and it always go last catch

remonh87 commented 1 year ago

@jamesblasco can you check this? I think we should still provide similar error objects from the JS library correct?

mminhlequang commented 1 year ago

any update @jamesblasco ?

garylevansjr commented 6 months ago

@mminhlequang did you every find a way to handle errors?