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

When using GooglePay for confirming setup or payment intent, MissingPluginException gets thrown. #1470

Closed
elvinasn opened this issue Nov 2, 2023 · 11 comments
Labels
needs triage Needs triage

Comments

@elvinasn
Copy link

elvinasn commented Nov 2, 2023

Describe the bug
When using google pay with custom button(instead of using PlatformPayButton, since it does not work with Flutter 3.13 version) the methods confirmPlatformPaySetupIntent and confirmPlatformPayPaymentIntent throws MissingPluginException(No implementation found for method confirmPlatformPay on channel flutter.stripe/payments).

Also, this gets printed:

E/DartMessenger(24014): Uncaught exception in binary message listener
E/DartMessenger(24014): org.json.JSONException: No value for amount
E/DartMessenger(24014): 	at org.json.JSONObject.get(JSONObject.java:399)
E/DartMessenger(24014): 	at org.json.JSONObject.getInt(JSONObject.java:488)
E/DartMessenger(24014): 	at com.facebook.react.bridge.ReadableMap.getInt(ReadableMap.java:49)
E/DartMessenger(24014): 	at com.reactnativestripesdk.GooglePayLauncherFragment.presentGooglePaySheet(GooglePayLauncherFragment.kt:52)
E/DartMessenger(24014): 	at com.reactnativestripesdk.StripeSdkModule.confirmPlatformPay(StripeSdkModule.kt:584)
E/DartMessenger(24014): 	at com.flutter.stripe.StripeAndroidPlugin.onMethodCall(StripeAndroidPlugin.kt:197)
E/DartMessenger(24014): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/DartMessenger(24014): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/DartMessenger(24014): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/DartMessenger(24014): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/DartMessenger(24014): 	at android.os.Handler.handleCallback(Handler.java:900)
E/DartMessenger(24014): 	at android.os.Handler.dispatchMessage(Handler.java:103)
E/DartMessenger(24014): 	at android.os.Looper.loop(Looper.java:219)
E/DartMessenger(24014): 	at android.app.ActivityThread.main(ActivityThread.java:8668)
E/DartMessenger(24014): 	at java.lang.reflect.Method.invoke(Native Method)
E/DartMessenger(24014): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/DartMessenger(24014): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

To Reproduce
Steps to reproduce the behavior:

  1. Create setup/payment intent in the backend
  2. Use created intent client secret with confirmPlatformPaySetupIntent or confirmPlatformPayPaymentIntent.
  3. Get error described.
    Expected behavior
    I expect that the methods work and i get bottom sheet so I can confirm.

Smartphone / tablet

  • Device: Huawei P30 Lite
  • OS: Android 11
  • Package version: 9.5.0+1
  • Flutter version 3.13.6
    Additional context

This is the method I call for confirming setup intent:

Future<bool> confirmPlatfromSetupIntent(String clientSecret) async {
    try {
      if (Platform.isAndroid) {
        await _read(stripeProvider).confirmPlatformPaySetupIntent(
          clientSecret: clientSecret,
          confirmParams: const PlatformPayConfirmParams.googlePay(
            googlePay: GooglePayParams(
              merchantName: 'Meetelp',
              allowCreditCards: true,
              isEmailRequired: false,
              testEnv: kDebugMode,
              currencyCode: 'eur',
              merchantCountryCode: 'lt',
            ),
          ),
        );
        return true;
      }
      await _read(stripeProvider).confirmPlatformPaySetupIntent(
        clientSecret: clientSecret,
        confirmParams: const PlatformPayConfirmParams.applePay(
          applePay: ApplePayParams(
            cartItems: [
              ApplePayCartSummaryItem.immediate(
                label: 'Meetelp',
                amount: '0',
              ),
            ],
            merchantCountryCode: 'lt',
            currencyCode: 'eur',
          ),
        ),
      );
      return true;
    } catch (e) {
      log('error: $e');
      return false;
    }
  }

Code for confirming payment intent:

 if (Platform.isIOS) {
        paymentIntent =
            await _read(stripeProvider).confirmPlatformPayPaymentIntent(
          clientSecret: paymentSecret,
          confirmParams: PlatformPayConfirmParams.applePay(
            applePay: ApplePayParams(
              cartItems: [
                ApplePayCartSummaryItem.immediate(
                  label: '$psychologistFullName(via Meetelp)',
                  amount: amount.toString(),
                ),
              ],
              merchantCountryCode: countryCode,
              currencyCode: currency,
            ),
          ),
        );
      } else {

        paymentIntent =
            await _read(stripeProvider).confirmPlatformPayPaymentIntent(
          clientSecret: paymentSecret,
          confirmParams: PlatformPayConfirmParams.googlePay(
            googlePay: GooglePayParams(
              merchantName: '$psychologistFullName(via Meetelp)',
              allowCreditCards: true,
              isEmailRequired: false,
              testEnv: kDebugMode,
              merchantCountryCode: countryCode,
              currencyCode: countryCode,
            ),
          ),
        );
      }
@elvinasn elvinasn added the needs triage Needs triage label Nov 2, 2023
@Rimantovas
Copy link

Did you manage to solve this?

@perkuns
Copy link

perkuns commented Nov 3, 2023

Also having this issue with my side project

@Moyout
Copy link

Moyout commented Nov 7, 2023

I also encountered the same problem

@favazHF
Copy link

favazHF commented Nov 7, 2023

Same problem.

Devices: NE2213 | SM-A127F | SM-G988B | Pixel 6a | TECNO KG8, etc!
OSs: Android 9, 11, 12, 13.

Any update?

@HatsuneMikuV
Copy link

Same issue.

MissingPluginException(No implementation found for method confirmPlatformPay on channel flutter.stripe/payments)

@DavidEcclesPH
Copy link

DavidEcclesPH commented Nov 10, 2023

same:

I/flutter ( 4807): ---------------- CAUGHT EXCEPTION! ----------------
I/flutter ( 4807): MissingPluginException(No implementation found for method confirmPlatformPay on channel flutter.stripe/payments)
I/flutter ( 4807): --------------------------------------------------------

@Rimantovas
Copy link

@Moyout Could you tell how you solved the issue? I see you left a thumbs up

@remonh87
Copy link
Member

A custom button does not work because there is a lot of internal android code linked to it. I would use the https://github.com/flutter-stripe/flutter_stripe/blob/main/example/lib/screens/wallets/google_pay_screen.dart for now . I will ask the stripe android team for help to debug the issue on flutter.

Let's continue the discussion on #1393 which is the original problem

@elvinasn
Copy link
Author

The custom button works with flutter_stripe version 9.3.0.

@Mik77o
Copy link

Mik77o commented Nov 17, 2023

We encounter same issue (9.5.0)

@akrameev-rhino
Copy link

akrameev-rhino commented May 24, 2024

The issue is in GooglePayLauncherFragment.kt function presentGooglePaySheet. It tries to get integer value for amount (this.amount = googlePayParams.getInt("amount")) and fails as there is no amount in googlePayParams. Sync from React Native is not always correct (it has amount String value in googlePayParams as it is stated here)

This line is replaced with this.amount = getIntOrNull(googlePayParams, "amount") and should not be a problem in future

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

10 participants