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

PaymentSheetError: Unknown result this is likely a problem in the plugin {paymentOption: null} #1465

Closed
hibbert-de opened this issue Oct 31, 2023 · 4 comments
Labels
needs triage Needs triage
Milestone

Comments

@hibbert-de
Copy link

Describe the bug
When i want to create a custom flow on iOS, the PaymentSheet won't open. I have initialized the Sheet with paymentIntentClientSecret customerEphemeralKeySecret and customerId. This is working on Android as it should, I only have this problem with iOS.

Full error message

flutter: StripeError<PaymentSheetError>(message: Unknown result this is likely a problem in the plugin {paymentOption: null}, code: PaymentSheetError.unknown)

To Reproduce
Download the flutter_stripe Package, enter your keys in the example for Frontend and Backend, run the local server.
I have a screen recording with breakpoints in the flutter Package. The device i not a simulator, i have mirrored my iPhone to my mac.
https://www.youtube.com/watch?v=D5FXbxylJ1I
this is my init of the PaymentSheet

await Stripe.instance.initPaymentSheet(
        paymentSheetParameters: SetupPaymentSheetParameters(
          customFlow: true,
          merchantDisplayName: 'myTest',
          setupIntentClientSecret: paymentIntentClientSecret,
          paymentIntentClientSecret: paymentIntentClientSecret,
          customerEphemeralKeySecret: customerEphemeralKeySecret,
          customerId: customerId,
          allowsDelayedPaymentMethods: true,
          billingDetails: BillingDetails(
            address: Address(
                city: state.currentBasket?.shippingAddress?.city,
                country: state.currentBasket?.shippingAddress?.country,
                line1: state.currentBasket?.shippingAddress?.address1,
                line2: state.currentBasket?.shippingAddress?.address2,
                postalCode: state.currentBasket?.shippingAddress?.zip,
                state: state.currentBasket?.shippingAddress?.state),
            name:
                "${state.currentBasket?.shippingAddress?.firstName} ${state.currentBasket?.shippingAddress?.lastName}",
            email: state.currentBasket?.shippingAddress?.email,
            phone: state.currentBasket?.shippingAddress?.phone,
          ),
          applePay: const PaymentSheetApplePay(
            merchantCountryCode: 'IN',
          ),
          googlePay: const PaymentSheetGooglePay(merchantCountryCode: 'IN'),
          style: ThemeMode.dark,
        ),
      );

and when i call await Stripe.instance.presentPaymentSheet(); this exception is thrown:
flutter: StripeError<PaymentSheetError>(message: Unknown result this is likely a problem in the plugin {paymentOption: null}, code: PaymentSheetError.unknown)

Expected behavior
The Payment sheet should open and the Payment should be successfully shown in the dashboard, like on Android.

Smartphone / tablet

  • Device: iPhone 12
  • OS: 16.61
  • Package version: flutter_stripe: 9.5.0+1
  • Flutter version: stable, 3.13.0

Additional context

[✓] Flutter (Channel stable, 3.13.0, on macOS 13.4 22F66 darwin-arm64, locale
    de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
@hibbert-de hibbert-de added the needs triage Needs triage label Oct 31, 2023
@PierluigiNetrise
Copy link

PierluigiNetrise commented Nov 16, 2023

i have the same issue, someone solved it?

@ahsi1999
Copy link

I am having the same issue in iOS in Android it is working fine.

@hibbert-de
Copy link
Author

hibbert-de commented Nov 21, 2023

i have found a solution:
i have forked the flutter_stripe plugin, and modified this file:
https://github.com/flutter-stripe/flutter_stripe/blob/main/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart

 @override
  Future<PaymentSheetPaymentOption?> initPaymentSheet(
      SetupPaymentSheetParameters params) async {
    final result = await _methodChannel.invokeMethod(
      'initPaymentSheet',
      {'params': params.toJson()},
    );
    if (params.intentConfiguration?.confirmHandler != null) {
      _addListenerForDeffered();
      _confirmHandler = params.intentConfiguration?.confirmHandler;
    }
    // iOS workaround for no paymentOptions
    if (result['paymentOption'] == null) {
      return null; // just return null
    } else if (result is List) {
      return null;
    } else {
      return _parsePaymentSheetResult(result);
    }
  }

i do not know if this is the correct way, but it is working, for now.

@ChristineWasike
Copy link

Great, how did you go about linking this to your project?

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
Development

No branches or pull requests

5 participants