Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
edb793c
feat(flutter): return payment result from EmbeddedPaymentElement.conf…
programmeraditya Oct 13, 2025
90f3750
feat(android): return payment result from confirm() method channel
programmeraditya Oct 13, 2025
5e8ce5e
fix(android): remove unused updateConfiguration methods causing type …
programmeraditya Oct 13, 2025
15915bc
fix(android): add missing Jetpack Compose dependencies and update Kotlin
programmeraditya Oct 13, 2025
f9d132c
feat(android): mirror React Native SDK Kotlin 2.0 detection
programmeraditya Oct 14, 2025
496ce52
fix(android): fix Kotlin type mismatches and array size calls
programmeraditya Oct 14, 2025
76b86e4
Fix Android crash when using embedded payment element
programmeraditya Oct 14, 2025
2213418
Fix Android compilation errors and upgrade Gradle
programmeraditya Oct 14, 2025
f8f2bf2
Fix Android color parsing when values are strings
programmeraditya Oct 14, 2025
8784de2
Fix Bundle type check to avoid ClassCastException warnings
programmeraditya Oct 14, 2025
145e5d4
Fix Android shimmer not hiding in embedded payment element
programmeraditya Oct 14, 2025
f32ddb1
fix: fix height, component overflow
programmeraditya Oct 16, 2025
9ef8006
chore: add paymentMethodConfigurationId Payment Method Configuration …
programmeraditya Oct 20, 2025
2b2bca7
fix: avoid embedded element height reentry on iOS simulator
programmeraditya Oct 20, 2025
1d52b72
fix: avoid embedded element height reentry on iOS simulator
programmeraditya Oct 20, 2025
28d16d8
chore: improve error handling and return data
programmeraditya Nov 14, 2025
6fea095
fix: nonobjc error
programmeraditya Nov 15, 2025
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: 2 additions & 0 deletions packages/stripe/lib/flutter_stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ export 'src/widgets/adress_sheet.dart';
export 'src/widgets/aubecs_debit_form.dart';
export 'src/widgets/card_field.dart';
export 'src/widgets/card_form_field.dart';
export 'src/widgets/embedded_payment_element.dart';
export 'src/widgets/embedded_payment_element_controller.dart';
// export 'src/widgets/google_pay_button.dart';
export 'src/widgets/platform_pay_button.dart';
7 changes: 1 addition & 6 deletions packages/stripe/lib/src/model/apple_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@ enum ApplePayButtonType {
}

/// Predefined styles for the Apple pay button.
enum ApplePayButtonStyle {
white,
whiteOutline,
black,
automatic,
}
enum ApplePayButtonStyle { white, whiteOutline, black, automatic }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What command did you run for dart format?

Looks like quite some changes were made due formatter

113 changes: 66 additions & 47 deletions packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:meta/meta.dart';
import 'package:stripe_platform_interface/stripe_platform_interface.dart';

/// [Stripe] is the facade of the library and exposes the operations that can be
Expand Down Expand Up @@ -102,13 +101,13 @@ class Stripe {
/// [publishableKey], [merchantIdentifier], [stripeAccountId],
/// [threeDSecureParams], [urlScheme], [setReturnUrlSchemeOnAndroid]
Future<void> applySettings() => _initialise(
publishableKey: publishableKey,
merchantIdentifier: merchantIdentifier,
stripeAccountId: stripeAccountId,
threeDSecureParams: threeDSecureParams,
urlScheme: urlScheme,
setReturnUrlSchemeOnAndroid: setReturnUrlSchemeOnAndroid,
);
publishableKey: publishableKey,
merchantIdentifier: merchantIdentifier,
stripeAccountId: stripeAccountId,
threeDSecureParams: threeDSecureParams,
urlScheme: urlScheme,
setReturnUrlSchemeOnAndroid: setReturnUrlSchemeOnAndroid,
);

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

_isPlatformPaySupported ??= ValueNotifier(false);
_isPlatformPaySupported?.value = isSupported;
Expand Down Expand Up @@ -276,8 +276,10 @@ class Stripe {
}) async {
await _awaitForSettings();
try {
final paymentMethod =
await _platform.createPaymentMethod(params, options);
final paymentMethod = await _platform.createPaymentMethod(
params,
options,
);
return paymentMethod;
} on StripeError catch (error) {
throw StripeError(message: error.message, code: error.message);
Expand Down Expand Up @@ -370,12 +372,16 @@ class Stripe {
/// several seconds and it is important to not resubmit the form.
///
/// Throws a [StripeException] when confirming the handle card action fails.
Future<PaymentIntent> handleNextAction(String paymentIntentClientSecret,
{String? returnURL}) async {
Future<PaymentIntent> handleNextAction(
String paymentIntentClientSecret, {
String? returnURL,
}) async {
await _awaitForSettings();
try {
final paymentIntent = await _platform
.handleNextAction(paymentIntentClientSecret, returnURL: returnURL);
final paymentIntent = await _platform.handleNextAction(
paymentIntentClientSecret,
returnURL: returnURL,
);
return paymentIntent;
} on StripeError {
//throw StripeError<CardActionError>(error.code, error.message);
Expand All @@ -389,13 +395,15 @@ class Stripe {
///
/// Throws a [StripeException] when confirming the handle card action fails.
Future<SetupIntent> handleNextActionForSetupIntent(
String setupIntentClientSecret,
{String? returnURL}) async {
String setupIntentClientSecret, {
String? returnURL,
}) async {
await _awaitForSettings();
try {
final paymentIntent = await _platform.handleNextActionForSetupIntent(
setupIntentClientSecret,
returnURL: returnURL);
setupIntentClientSecret,
returnURL: returnURL,
);
return paymentIntent;
} on StripeError {
rethrow;
Expand All @@ -416,7 +424,10 @@ class Stripe {
await _awaitForSettings();
try {
final setupIntent = await _platform.confirmSetupIntent(
paymentIntentClientSecret, params, options);
paymentIntentClientSecret,
params,
options,
);
return setupIntent;
} on StripeException {
rethrow;
Expand All @@ -428,14 +439,10 @@ class Stripe {
/// Returns a single-use token.
///
/// Throws [StripeError] in case creating the token fails.
Future<String?> createTokenForCVCUpdate(
String cvc,
) async {
Future<String?> createTokenForCVCUpdate(String cvc) async {
await _awaitForSettings();
try {
final tokenId = await _platform.createTokenForCVCUpdate(
cvc,
);
final tokenId = await _platform.createTokenForCVCUpdate(cvc);
return tokenId;
} on StripeError {
//throw StripeError<CardActionError>(error.code, error.message);
Expand All @@ -451,9 +458,10 @@ class Stripe {
required SetupPaymentSheetParameters paymentSheetParameters,
}) async {
assert(
!(paymentSheetParameters.applePay != null &&
instance._merchantIdentifier == null),
'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');
!(paymentSheetParameters.applePay != null &&
instance._merchantIdentifier == null),
'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',
);
await _awaitForSettings();
return _platform.initPaymentSheet(paymentSheetParameters);
}
Expand All @@ -473,11 +481,18 @@ class Stripe {
/// Method used to confirm to the user that the intent is created successfull
/// or not successfull when using a defferred payment method.
Future<void> intentCreationCallback(
IntentCreationCallbackParams params) async {
IntentCreationCallbackParams params,
) async {
await _awaitForSettings();
return await _platform.intentCreationCallback(params);
}

/// Registers a callback that the native embedded element invokes when it
/// needs the app to create an intent client secret.
void setConfirmHandler(ConfirmHandler? handler) {
_platform.setConfirmHandler(handler);
}

/// Call this method when the user logs out from your app.
///
/// This will ensure that any persisted authentication state in the
Expand Down Expand Up @@ -506,7 +521,8 @@ class Stripe {

/// Inititialise google pay
@Deprecated(
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent] or [createPlatformPayPaymentMethod] instead.')
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent] or [createPlatformPayPaymentMethod] instead.',
)
Future<void> initGooglePay(GooglePayInitParams params) async {
return await _platform.initGooglePay(params);
}
Expand All @@ -515,7 +531,8 @@ class Stripe {
///
/// Throws a [StripeException] in case it is failing
@Deprecated(
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent].')
'Use [confirmPlatformPaySetupIntent] or [confirmPlatformPayPaymentIntent].',
)
Future<void> presentGooglePay(PresentGooglePayParams params) async {
return await _platform.presentGooglePay(params);
}
Expand All @@ -525,7 +542,8 @@ class Stripe {
/// Throws a [StripeException] in case it is failing
@Deprecated('Use [createPlatformPayPaymentMethod instead.')
Future<PaymentMethod> createGooglePayPaymentMethod(
CreateGooglePayPaymentParams params) async {
CreateGooglePayPaymentParams params,
) async {
return await _platform.createGooglePayPaymentMethod(params);
}

Expand Down Expand Up @@ -566,11 +584,9 @@ class Stripe {
/// iOS at the moment.
Future<PaymentIntent> verifyPaymentIntentWithMicrodeposits({
/// Whether the clientsecret is associated with setup or paymentintent

required bool isPaymentIntent,

/// The clientSecret of the payment and setup intent

required String clientSecret,

/// Parameters to verify the microdeposits.
Expand All @@ -596,7 +612,8 @@ class Stripe {
/// on this particular device.
/// Throws [StripeException] in case creating the token fails.
Future<CanAddCardToWalletResult> canAddCardToWallet(
CanAddCardToWalletParams params) async {
CanAddCardToWalletParams params,
) async {
return await _platform.canAddCardToWallet(params);
}

Expand Down Expand Up @@ -650,8 +667,9 @@ class Stripe {
}

/// Initializes the customer sheet with the provided [parameters].
Future<CustomerSheetResult?> initCustomerSheet(
{required CustomerSheetInitParams customerSheetInitParams}) async {
Future<CustomerSheetResult?> initCustomerSheet({
required CustomerSheetInitParams customerSheetInitParams,
}) async {
await _awaitForSettings();
return _platform.initCustomerSheet(customerSheetInitParams);
}
Expand All @@ -666,7 +684,7 @@ class Stripe {

/// Retrieve the customer sheet payment option selection.
Future<CustomerSheetResult?>
retrieveCustomerSheetPaymentOptionSelection() async {
retrieveCustomerSheetPaymentOptionSelection() async {
await _awaitForSettings();

return _platform.retrieveCustomerSheetPaymentOptionSelection();
Expand Down Expand Up @@ -711,13 +729,14 @@ class Stripe {
}
}

Future<void> _initialise(
{required String publishableKey,
String? stripeAccountId,
ThreeDSecureConfigurationParams? threeDSecureParams,
String? merchantIdentifier,
String? urlScheme,
bool? setReturnUrlSchemeOnAndroid}) async {
Future<void> _initialise({
required String publishableKey,
String? stripeAccountId,
ThreeDSecureConfigurationParams? threeDSecureParams,
String? merchantIdentifier,
String? urlScheme,
bool? setReturnUrlSchemeOnAndroid,
}) async {
_needsSettings = false;
await _platform.initialise(
publishableKey: publishableKey,
Expand Down
31 changes: 18 additions & 13 deletions packages/stripe/lib/src/widgets/adress_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ class _AddressSheetState extends State<_AddressSheet> {
_methodChannel?.setMethodCallHandler((call) async {
if (call.method == 'onSubmitAction') {
try {
final tmp =
Map<String, dynamic>.from(call.arguments as Map)['result'];
final tmp = Map<String, dynamic>.from(
call.arguments as Map,
)['result'];
final tmpAdress = Map<String, dynamic>.from(tmp['address'] as Map);

widget.onSubmit(
Expand All @@ -70,15 +71,18 @@ class _AddressSheetState extends State<_AddressSheet> {
),
);
} catch (e) {
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');
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',
);
rethrow;
}
} else if (call.method == 'onErrorAction') {
final tmp = Map<String, dynamic>.from(call.arguments as Map);
final foo = Map<String, dynamic>.from(tmp['error'] as Map);

widget.onError(
StripeException(error: LocalizedErrorMessage.fromJson(foo)));
StripeException(error: LocalizedErrorMessage.fromJson(foo)),
);
}
});
}
Expand All @@ -99,21 +103,22 @@ class _AddressSheetState extends State<_AddressSheet> {
return AndroidViewSurface(
controller: controller as AndroidViewController,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
gestureRecognizers: const <Factory<
OneSequenceGestureRecognizer>>{},
gestureRecognizers:
const <Factory<OneSequenceGestureRecognizer>>{},
);
},
onCreatePlatformView: (params) {
onPlatformViewCreated(params.id);
return PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: _viewType,
layoutDirection: TextDirection.ltr,
creationParams: widget.addressSheetParams.toJson(),
creationParamsCodec: const StandardMessageCodec(),
)
id: params.id,
viewType: _viewType,
layoutDirection: TextDirection.ltr,
creationParams: widget.addressSheetParams.toJson(),
creationParamsCodec: const StandardMessageCodec(),
)
..addOnPlatformViewCreatedListener(
params.onPlatformViewCreated)
params.onPlatformViewCreated,
)
..create();
},
viewType: _viewType,
Expand Down
Loading