Closed
Description
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:
- Create setup/payment intent in the backend
- Use created intent client secret with confirmPlatformPaySetupIntent or confirmPlatformPayPaymentIntent.
- 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,
),
),
);
}