diff --git a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeAndroidPlugin.kt b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeAndroidPlugin.kt index a0a89a2dc..67412317a 100644 --- a/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeAndroidPlugin.kt +++ b/packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeAndroidPlugin.kt @@ -238,10 +238,13 @@ If you continue to have trouble, follow this discussion to get some support http } private inline fun MethodCall.optionalArgument(key: String): T? { + val value = argument(key) + if (value == JSONObject.NULL) + return null if (T::class.java == ReadableMap::class.java) { return ReadableMap(argument(key) ?: JSONObject()) as T } - return argument(key) + return value } private inline fun MethodCall.requiredArgument(key: String): T { diff --git a/packages/stripe_ios/ios/Classes/StripePlugin.swift b/packages/stripe_ios/ios/Classes/StripePlugin.swift index 7c40750fe..bf12add8f 100644 --- a/packages/stripe_ios/ios/Classes/StripePlugin.swift +++ b/packages/stripe_ios/ios/Classes/StripePlugin.swift @@ -378,12 +378,12 @@ extension StripePlugin { func confirmPayment(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, - let paymentIntentClientSecret = arguments["paymentIntentClientSecret"] as? String, - let params = arguments["params"] as? NSDictionary, - let options = arguments["options"] as? NSDictionary else { + let paymentIntentClientSecret = arguments["paymentIntentClientSecret"] as? String, + let options = arguments["options"] as? NSDictionary else { result(FlutterError.invalidParams) return } + let params = arguments["params"] as? NSDictionary confirmPayment( paymentIntentClientSecret: paymentIntentClientSecret, params: params, diff --git a/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart b/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart index 4bebca438..c93592b9a 100644 --- a/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart +++ b/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart @@ -95,7 +95,7 @@ class MethodChannelStripe extends StripePlatform { final result = await _methodChannel .invokeMapMethod('confirmPayment', { 'paymentIntentClientSecret': paymentIntentClientSecret, - 'params': params?.toJson() ?? {}, + 'params': params?.toJson(), 'options': options?.toJson() ?? {}, });