Skip to content

Commit 7945339

Browse files
authored
Fix #2064 financial connections bug (#2260)
* fix: fix issue that parses created date incorrectly coming from android * chore: run dart format
1 parent df7dda8 commit 7945339

File tree

10 files changed

+180
-152
lines changed

10 files changed

+180
-152
lines changed

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (flutterVersionName == null) {
2626

2727
android {
2828
namespace 'com.flutter.stripe.example'
29-
compileSdk 35
29+
compileSdk 36
3030

3131
compileOptions {
3232
sourceCompatibility JavaVersion.VERSION_17

packages/stripe/lib/src/model/apple_pay_button.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,4 @@ enum ApplePayButtonType {
2020
}
2121

2222
/// Predefined styles for the Apple pay button.
23-
enum ApplePayButtonStyle {
24-
white,
25-
whiteOutline,
26-
black,
27-
automatic,
28-
}
23+
enum ApplePayButtonStyle { white, whiteOutline, black, automatic }

packages/stripe/lib/src/stripe.dart

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:async';
22

33
import 'package:flutter/foundation.dart';
4-
import 'package:meta/meta.dart';
54
import 'package:stripe_platform_interface/stripe_platform_interface.dart';
65

76
/// [Stripe] is the facade of the library and exposes the operations that can be
@@ -102,13 +101,13 @@ class Stripe {
102101
/// [publishableKey], [merchantIdentifier], [stripeAccountId],
103102
/// [threeDSecureParams], [urlScheme], [setReturnUrlSchemeOnAndroid]
104103
Future<void> applySettings() => _initialise(
105-
publishableKey: publishableKey,
106-
merchantIdentifier: merchantIdentifier,
107-
stripeAccountId: stripeAccountId,
108-
threeDSecureParams: threeDSecureParams,
109-
urlScheme: urlScheme,
110-
setReturnUrlSchemeOnAndroid: setReturnUrlSchemeOnAndroid,
111-
);
104+
publishableKey: publishableKey,
105+
merchantIdentifier: merchantIdentifier,
106+
stripeAccountId: stripeAccountId,
107+
threeDSecureParams: threeDSecureParams,
108+
urlScheme: urlScheme,
109+
setReturnUrlSchemeOnAndroid: setReturnUrlSchemeOnAndroid,
110+
);
112111

113112
/// Exposes a [ValueListenable] whether or not GooglePay (on Android) or Apple Pay (on iOS)
114113
/// is supported for this device.
@@ -133,8 +132,9 @@ class Stripe {
133132
}) async {
134133
await _awaitForSettings();
135134
final isSupported = await _platform.isPlatformPaySupported(
136-
params: googlePay,
137-
paymentRequestOptions: webPaymentRequestCreateOptions);
135+
params: googlePay,
136+
paymentRequestOptions: webPaymentRequestCreateOptions,
137+
);
138138

139139
_isPlatformPaySupported ??= ValueNotifier(false);
140140
_isPlatformPaySupported?.value = isSupported;
@@ -276,8 +276,10 @@ class Stripe {
276276
}) async {
277277
await _awaitForSettings();
278278
try {
279-
final paymentMethod =
280-
await _platform.createPaymentMethod(params, options);
279+
final paymentMethod = await _platform.createPaymentMethod(
280+
params,
281+
options,
282+
);
281283
return paymentMethod;
282284
} on StripeError catch (error) {
283285
throw StripeError(message: error.message, code: error.message);
@@ -370,12 +372,16 @@ class Stripe {
370372
/// several seconds and it is important to not resubmit the form.
371373
///
372374
/// Throws a [StripeException] when confirming the handle card action fails.
373-
Future<PaymentIntent> handleNextAction(String paymentIntentClientSecret,
374-
{String? returnURL}) async {
375+
Future<PaymentIntent> handleNextAction(
376+
String paymentIntentClientSecret, {
377+
String? returnURL,
378+
}) async {
375379
await _awaitForSettings();
376380
try {
377-
final paymentIntent = await _platform
378-
.handleNextAction(paymentIntentClientSecret, returnURL: returnURL);
381+
final paymentIntent = await _platform.handleNextAction(
382+
paymentIntentClientSecret,
383+
returnURL: returnURL,
384+
);
379385
return paymentIntent;
380386
} on StripeError {
381387
//throw StripeError<CardActionError>(error.code, error.message);
@@ -389,13 +395,15 @@ class Stripe {
389395
///
390396
/// Throws a [StripeException] when confirming the handle card action fails.
391397
Future<SetupIntent> handleNextActionForSetupIntent(
392-
String setupIntentClientSecret,
393-
{String? returnURL}) async {
398+
String setupIntentClientSecret, {
399+
String? returnURL,
400+
}) async {
394401
await _awaitForSettings();
395402
try {
396403
final paymentIntent = await _platform.handleNextActionForSetupIntent(
397-
setupIntentClientSecret,
398-
returnURL: returnURL);
404+
setupIntentClientSecret,
405+
returnURL: returnURL,
406+
);
399407
return paymentIntent;
400408
} on StripeError {
401409
rethrow;
@@ -416,7 +424,10 @@ class Stripe {
416424
await _awaitForSettings();
417425
try {
418426
final setupIntent = await _platform.confirmSetupIntent(
419-
paymentIntentClientSecret, params, options);
427+
paymentIntentClientSecret,
428+
params,
429+
options,
430+
);
420431
return setupIntent;
421432
} on StripeException {
422433
rethrow;
@@ -428,14 +439,10 @@ class Stripe {
428439
/// Returns a single-use token.
429440
///
430441
/// Throws [StripeError] in case creating the token fails.
431-
Future<String?> createTokenForCVCUpdate(
432-
String cvc,
433-
) async {
442+
Future<String?> createTokenForCVCUpdate(String cvc) async {
434443
await _awaitForSettings();
435444
try {
436-
final tokenId = await _platform.createTokenForCVCUpdate(
437-
cvc,
438-
);
445+
final tokenId = await _platform.createTokenForCVCUpdate(cvc);
439446
return tokenId;
440447
} on StripeError {
441448
//throw StripeError<CardActionError>(error.code, error.message);
@@ -451,9 +458,10 @@ class Stripe {
451458
required SetupPaymentSheetParameters paymentSheetParameters,
452459
}) async {
453460
assert(
454-
!(paymentSheetParameters.applePay != null &&
455-
instance._merchantIdentifier == null),
456-
'merchantIdentifier must be specified if you are using Apple Pay. Please refer to this article to get a merchant identifier: https://support.stripe.com/questions/enable-apple-pay-on-your-stripe-account');
461+
!(paymentSheetParameters.applePay != null &&
462+
instance._merchantIdentifier == null),
463+
'merchantIdentifier must be specified if you are using Apple Pay. Please refer to this article to get a merchant identifier: https://support.stripe.com/questions/enable-apple-pay-on-your-stripe-account',
464+
);
457465
await _awaitForSettings();
458466
return _platform.initPaymentSheet(paymentSheetParameters);
459467
}
@@ -473,7 +481,8 @@ class Stripe {
473481
/// Method used to confirm to the user that the intent is created successfull
474482
/// or not successfull when using a defferred payment method.
475483
Future<void> intentCreationCallback(
476-
IntentCreationCallbackParams params) async {
484+
IntentCreationCallbackParams params,
485+
) async {
477486
await _awaitForSettings();
478487
return await _platform.intentCreationCallback(params);
479488
}
@@ -506,7 +515,8 @@ class Stripe {
506515

507516
/// Inititialise google pay
508517
@Deprecated(
509-
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent] or [createPlatformPayPaymentMethod] instead.')
518+
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent] or [createPlatformPayPaymentMethod] instead.',
519+
)
510520
Future<void> initGooglePay(GooglePayInitParams params) async {
511521
return await _platform.initGooglePay(params);
512522
}
@@ -515,7 +525,8 @@ class Stripe {
515525
///
516526
/// Throws a [StripeException] in case it is failing
517527
@Deprecated(
518-
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent].')
528+
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent].',
529+
)
519530
Future<void> presentGooglePay(PresentGooglePayParams params) async {
520531
return await _platform.presentGooglePay(params);
521532
}
@@ -525,7 +536,8 @@ class Stripe {
525536
/// Throws a [StripeException] in case it is failing
526537
@Deprecated('Use [createPlatformPayPaymentMethod instead.')
527538
Future<PaymentMethod> createGooglePayPaymentMethod(
528-
CreateGooglePayPaymentParams params) async {
539+
CreateGooglePayPaymentParams params,
540+
) async {
529541
return await _platform.createGooglePayPaymentMethod(params);
530542
}
531543

@@ -566,11 +578,9 @@ class Stripe {
566578
/// iOS at the moment.
567579
Future<PaymentIntent> verifyPaymentIntentWithMicrodeposits({
568580
/// Whether the clientsecret is associated with setup or paymentintent
569-
570581
required bool isPaymentIntent,
571582

572583
/// The clientSecret of the payment and setup intent
573-
574584
required String clientSecret,
575585

576586
/// Parameters to verify the microdeposits.
@@ -596,7 +606,8 @@ class Stripe {
596606
/// on this particular device.
597607
/// Throws [StripeException] in case creating the token fails.
598608
Future<CanAddCardToWalletResult> canAddCardToWallet(
599-
CanAddCardToWalletParams params) async {
609+
CanAddCardToWalletParams params,
610+
) async {
600611
return await _platform.canAddCardToWallet(params);
601612
}
602613

@@ -616,7 +627,8 @@ class Stripe {
616627
617628
Future<FinancialConnectionTokenResult> collectBankAccountToken({
618629
required String clientSecret,
619-
CollectBankAccountTokenParams? params,
630+
CollectBankAccountTokenParams params =
631+
const CollectBankAccountTokenParams(),
620632
}) async {
621633
try {
622634
return _platform.collectBankAccountToken(
@@ -637,7 +649,8 @@ class Stripe {
637649
638650
Future<FinancialConnectionSessionResult> collectFinancialConnectionsAccounts({
639651
required String clientSecret,
640-
CollectFinancialConnectionsAccountsParams? params,
652+
CollectFinancialConnectionsAccountsParams params =
653+
const CollectFinancialConnectionsAccountsParams(),
641654
}) async {
642655
try {
643656
return _platform.collectFinancialConnectionsAccounts(
@@ -650,8 +663,9 @@ class Stripe {
650663
}
651664

652665
/// Initializes the customer sheet with the provided [parameters].
653-
Future<CustomerSheetResult?> initCustomerSheet(
654-
{required CustomerSheetInitParams customerSheetInitParams}) async {
666+
Future<CustomerSheetResult?> initCustomerSheet({
667+
required CustomerSheetInitParams customerSheetInitParams,
668+
}) async {
655669
await _awaitForSettings();
656670
return _platform.initCustomerSheet(customerSheetInitParams);
657671
}
@@ -666,7 +680,7 @@ class Stripe {
666680

667681
/// Retrieve the customer sheet payment option selection.
668682
Future<CustomerSheetResult?>
669-
retrieveCustomerSheetPaymentOptionSelection() async {
683+
retrieveCustomerSheetPaymentOptionSelection() async {
670684
await _awaitForSettings();
671685

672686
return _platform.retrieveCustomerSheetPaymentOptionSelection();
@@ -711,13 +725,14 @@ class Stripe {
711725
}
712726
}
713727

714-
Future<void> _initialise(
715-
{required String publishableKey,
716-
String? stripeAccountId,
717-
ThreeDSecureConfigurationParams? threeDSecureParams,
718-
String? merchantIdentifier,
719-
String? urlScheme,
720-
bool? setReturnUrlSchemeOnAndroid}) async {
728+
Future<void> _initialise({
729+
required String publishableKey,
730+
String? stripeAccountId,
731+
ThreeDSecureConfigurationParams? threeDSecureParams,
732+
String? merchantIdentifier,
733+
String? urlScheme,
734+
bool? setReturnUrlSchemeOnAndroid,
735+
}) async {
721736
_needsSettings = false;
722737
await _platform.initialise(
723738
publishableKey: publishableKey,

packages/stripe/lib/src/widgets/adress_sheet.dart

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ class _AddressSheetState extends State<_AddressSheet> {
5858
_methodChannel?.setMethodCallHandler((call) async {
5959
if (call.method == 'onSubmitAction') {
6060
try {
61-
final tmp =
62-
Map<String, dynamic>.from(call.arguments as Map)['result'];
61+
final tmp = Map<String, dynamic>.from(
62+
call.arguments as Map,
63+
)['result'];
6364
final tmpAdress = Map<String, dynamic>.from(tmp['address'] as Map);
6465

6566
widget.onSubmit(
@@ -70,15 +71,18 @@ class _AddressSheetState extends State<_AddressSheet> {
7071
),
7172
);
7273
} catch (e) {
73-
log('An error ocurred while while parsing card arguments, this should not happen, please consider creating an issue at https://github.com/flutter-stripe/flutter_stripe/issues/new');
74+
log(
75+
'An error ocurred while while parsing card arguments, this should not happen, please consider creating an issue at https://github.com/flutter-stripe/flutter_stripe/issues/new',
76+
);
7477
rethrow;
7578
}
7679
} else if (call.method == 'onErrorAction') {
7780
final tmp = Map<String, dynamic>.from(call.arguments as Map);
7881
final foo = Map<String, dynamic>.from(tmp['error'] as Map);
7982

8083
widget.onError(
81-
StripeException(error: LocalizedErrorMessage.fromJson(foo)));
84+
StripeException(error: LocalizedErrorMessage.fromJson(foo)),
85+
);
8286
}
8387
});
8488
}
@@ -99,21 +103,22 @@ class _AddressSheetState extends State<_AddressSheet> {
99103
return AndroidViewSurface(
100104
controller: controller as AndroidViewController,
101105
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
102-
gestureRecognizers: const <Factory<
103-
OneSequenceGestureRecognizer>>{},
106+
gestureRecognizers:
107+
const <Factory<OneSequenceGestureRecognizer>>{},
104108
);
105109
},
106110
onCreatePlatformView: (params) {
107111
onPlatformViewCreated(params.id);
108112
return PlatformViewsService.initExpensiveAndroidView(
109-
id: params.id,
110-
viewType: _viewType,
111-
layoutDirection: TextDirection.ltr,
112-
creationParams: widget.addressSheetParams.toJson(),
113-
creationParamsCodec: const StandardMessageCodec(),
114-
)
113+
id: params.id,
114+
viewType: _viewType,
115+
layoutDirection: TextDirection.ltr,
116+
creationParams: widget.addressSheetParams.toJson(),
117+
creationParamsCodec: const StandardMessageCodec(),
118+
)
115119
..addOnPlatformViewCreatedListener(
116-
params.onPlatformViewCreated)
120+
params.onPlatformViewCreated,
121+
)
117122
..create();
118123
},
119124
viewType: _viewType,

0 commit comments

Comments
 (0)