Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After confirm payment it throw a exception #1321

Closed
EliaTolin opened this issue Jul 19, 2023 · 12 comments · Fixed by #1333
Closed

After confirm payment it throw a exception #1321

EliaTolin opened this issue Jul 19, 2023 · 12 comments · Fixed by #1333
Labels
needs triage Needs triage

Comments

@EliaTolin
Copy link
Contributor

Describe the bug
After complete payment stripe throw a Exception

To Reproduce
Steps to reproduce the behavior:

  1. Entering number 4242 4242 4242 4242 into the cardfield.
  2. Tapping the confirm button.
  3. Observe a failure with exception (including the part of the stack trace, belonging to this package) …

Smartphone / tablet

  • Device: iPhone14 Simulator
  • OS: 16.4
  • Package version: 9.3.0

Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (7 giorni fa) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

Additional context
Code:

 Future<void> initStripe() async {
    if (paymentDataKey != null) {
      await Stripe.instance.initPaymentSheet(
        paymentSheetParameters: SetupPaymentSheetParameters(
          // Main params
          merchantDisplayName: PaymentConstants.merchantDisplayName,
          paymentIntentClientSecret: paymentDataKey?.clientSecret,
        ),
      );
    } else {
      throw Exception();
    }
  }

  Future<bool> openPaymentSheet() async {
    try {
      await Stripe.instance.presentPaymentSheet();
      return true;
    } catch (error, stacktrace) {
      if (error is StripeException) {
        if (error.error.code == FailureCode.Canceled) {
          return false;
        }
      }
      log(error.toString());
      log(stacktrace.toString());
      throw Exception();
    }
  }

Exception:
type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>?'

Stacktrace:

MethodChannelStripe.presentPaymentSheet (package:stripe_platform_interface/src/method_channel_stripe.dart:263:37)
      <asynchronous suspension>
      #1      Stripe.presentPaymentSheet (package:flutter_stripe/src/stripe.dart:517:12)
      <asynchronous suspension>
      #2      SlotPaymentController.openPaymentSheet (package: foo/controller/payment/slot_payment_controller.dart:40:7)
      <asynchronous suspension>
      #3      _SlotPaymentPageState.openPayment (package:foo/pages/payment/slot_payment_page.dart:164:11)
      <asynchronous suspension>

@EliaTolin EliaTolin added the needs triage Needs triage label Jul 19, 2023
@jorger5
Copy link

jorger5 commented Jul 20, 2023

This happened to me to, on v9.3.0. Reverted back to v9.2.2 as a workaround and

dependency_overrides: 
  stripe_platform_interface: 9.2.2

@EliaTolin
Copy link
Contributor Author

This happened to me to, on v9.3.0. Reverted back to v9.2.2 as a workaround and

dependency_overrides: 
  stripe_platform_interface: 9.2.2

Have you find where is the problem? We make a PR if we fix it.

@jorger5
Copy link

jorger5 commented Jul 20, 2023

I guess the problem is in this file method_channel_stripe.dart specifically in the method _parsePaymentSheetResult.

From what the error says, there's a type error as _parsePaymentSheetResult expects a Map<String,dynamic>? and it's receiving a List<dynamic>.

Not sure about this change from Map to List but that comes from iOS method channel (haven't testing in Android if it happens).

@EliaTolin
Copy link
Contributor Author

I guess the problem is in this file method_channel_stripe.dart specifically in the method _parsePaymentSheetResult.

From what the error says, there's a type error as _parsePaymentSheetResult expects a Map<String,dynamic>? and it's receiving a List<dynamic>.

Not sure about this change but that result comes from iOS method channel (haven't testing in Android if it happens).

In Android devices it works fine.
I'm not a native developer, but here the function confirmPaymentSheetPayment resolve the function with [], maybe is it this the problem?

StripeSdk.swift

@jorger5
Copy link

jorger5 commented Jul 20, 2023

I'll check it out to see if I can make a quick fix / PR

@EliaTolin
Copy link
Contributor Author

Yes, you can add me to co-author to your PR.

@jorger5
Copy link

jorger5 commented Jul 20, 2023

Here's the quick fix #1325 !

@EliaTolin
Copy link
Contributor Author

Here's the quick fix #1325 !

Please add me co-authored

@jorger5
Copy link

jorger5 commented Jul 20, 2023

Here's the quick fix #1325 !

Please add me co-authored

Ups, done now! Give it a try whenever you can, it should work now

@RRosalia
Copy link

When will it be published and available for install through pubspec?

@tbuczkowski
Copy link
Contributor

Any updates on releasing a fix to this issue? Frankly it's ridiculous, that a fix has been ready for over a month and hasn't been released yet, given this issue is pretty much a blocker.

@lucagiordano-visia
Copy link

lucagiordano-visia commented Aug 31, 2023

Any updates on releasing a fix to this issue? Frankly it's ridiculous, that a fix has been ready for over a month and hasn't been released yet, given this issue is pretty much a blocker.

I had to import both on my pubspec.yaml
flutter_stripe: ^9.3.0 stripe_ios: ^9.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Needs triage
Projects
None yet
5 participants