diff --git a/packages/stripe/lib/src/stripe.dart b/packages/stripe/lib/src/stripe.dart index 0fc810cb..5232b268 100644 --- a/packages/stripe/lib/src/stripe.dart +++ b/packages/stripe/lib/src/stripe.dart @@ -679,7 +679,7 @@ class Stripe { } /// Initializes the customer sheet with the provided [parameters]. - Future initCustomerSheet({ + Future initCustomerSheet({ required CustomerSheetInitParams customerSheetInitParams, }) async { await _awaitForSettings(); 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 c7b4f939..cbb9c037 100644 --- a/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart +++ b/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart @@ -291,18 +291,17 @@ class MethodChannelStripe extends StripePlatform { } @override - Future initCustomerSheet( - CustomerSheetInitParams params, - ) async { + Future initCustomerSheet(CustomerSheetInitParams params) async { final result = await _methodChannel.invokeMethod('initCustomerSheet', { 'params': params.toJson(), 'customerAdapterOverrides': {}, }); - if (result is List) { - return null; - } else { - return _parseCustomerSheetResult(result); + // Check for errors only + // iOS returns empty array, Android returns empty map on success - both are fine + if (result is Map && result['error'] != null) { + result['runtimeType'] = 'failed'; + throw StripeException.fromJson(result); } } @@ -602,9 +601,9 @@ class MethodChannelStripe extends StripePlatform { } // workaround for fact that created is parsed as string from Stripe android - final created = result?['token']['created']; + final created = result['token']['created']; if (created != null && created is String) { - result?['token']['created'] = int.tryParse(created); + result['token']['created'] = int.tryParse(created); } return FinancialConnectionTokenResult.fromJson(result); diff --git a/packages/stripe_platform_interface/lib/src/stripe_platform_interface.dart b/packages/stripe_platform_interface/lib/src/stripe_platform_interface.dart index d5ba8f28..5b93e6dc 100644 --- a/packages/stripe_platform_interface/lib/src/stripe_platform_interface.dart +++ b/packages/stripe_platform_interface/lib/src/stripe_platform_interface.dart @@ -75,7 +75,7 @@ abstract class StripePlatform extends PlatformInterface { Future confirmPaymentSheetPayment(); /// Configure the payment sheet using [CustomerSheetInitParams] as config. - Future initCustomerSheet( + Future initCustomerSheet( CustomerSheetInitParams params, ); diff --git a/packages/stripe_web/lib/src/web_stripe.dart b/packages/stripe_web/lib/src/web_stripe.dart index dc707d74..7818533f 100644 --- a/packages/stripe_web/lib/src/web_stripe.dart +++ b/packages/stripe_web/lib/src/web_stripe.dart @@ -58,7 +58,8 @@ class WebStripe extends StripePlatform { if (__stripe != null) { // Check if the new stripeAccountId or locale is different - if (__stripe!.stripeAccount != stripeAccountId || __stripe!.locale != locale) { + if (__stripe!.stripeAccount != stripeAccountId || + __stripe!.locale != locale) { // Re-initialize with new stripeAccountId or locale await stripe_js.loadStripe(); var stripeOption = stripe_js.StripeOptions(); @@ -636,7 +637,7 @@ class WebStripe extends StripePlatform { } @override - Future initCustomerSheet( + Future initCustomerSheet( CustomerSheetInitParams params) { throw WebUnsupportedError.method('initCustomerSheet'); }