Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ class Stripe {
}

/// Initializes the customer sheet with the provided [parameters].
Future<CustomerSheetResult?> initCustomerSheet({
Future<void> initCustomerSheet({
required CustomerSheetInitParams customerSheetInitParams,
}) async {
await _awaitForSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,17 @@ class MethodChannelStripe extends StripePlatform {
}

@override
Future<CustomerSheetResult?> initCustomerSheet(
CustomerSheetInitParams params,
) async {
Future<void> 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<String, dynamic> && result['error'] != null) {
result['runtimeType'] = 'failed';
throw StripeException.fromJson(result);
}
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class StripePlatform extends PlatformInterface {
Future<void> confirmPaymentSheetPayment();

/// Configure the payment sheet using [CustomerSheetInitParams] as config.
Future<CustomerSheetResult?> initCustomerSheet(
Future<void> initCustomerSheet(
CustomerSheetInitParams params,
);

Expand Down
5 changes: 3 additions & 2 deletions packages/stripe_web/lib/src/web_stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -636,7 +637,7 @@ class WebStripe extends StripePlatform {
}

@override
Future<CustomerSheetResult?> initCustomerSheet(
Future<void> initCustomerSheet(
CustomerSheetInitParams params) {
throw WebUnsupportedError.method('initCustomerSheet');
}
Expand Down
Loading