Skip to content

Commit f2c0ae7

Browse files
author
Eduard Dumitrescu
committed
different constructors for payment element widget
1 parent 85eca7c commit f2c0ae7

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PlatformPaymentElement extends StatelessWidget {
2121

2222
@override
2323
Widget build(BuildContext context) {
24-
return PaymentElement(
24+
return PaymentElement.withIntent(
2525
autofocus: true,
2626
enablePostalCode: true,
2727
onCardChanged: (_) {},

example/lib/screens/setup_future_payments/add_payment_method_screen_loader_web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _AddPaymentMethodScreenPlatformState
7272
SizedBox(height: 12),
7373
Padding(
7474
padding: const EdgeInsets.all(24),
75-
child: PaymentElement(
75+
child: PaymentElement.withIntent(
7676
clientSecret: widget.setupKeys.clientSecret,
7777
onCardChanged: (c) {
7878
setState(() => isComplete = c?.complete ?? false);

packages/stripe_web/lib/src/widgets/payment_element.dart

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ class PaymentElement extends StatefulWidget {
5656
final js.PaymentElementApplePayOptions? applePay;
5757
final String? locale;
5858

59-
const PaymentElement({
59+
const PaymentElement.withoutIntent({
6060
super.key,
61-
this.clientSecret,
62-
this.customerSessionClientSecret,
63-
this.amount,
64-
this.currency,
65-
this.mode,
61+
required this.amount,
62+
required this.currency,
63+
required this.mode,
64+
required this.onCardChanged,
6665
this.paymentMethodTypes,
6766
this.paymentMethodCreation,
6867
this.width,
@@ -73,7 +72,35 @@ class PaymentElement extends StatefulWidget {
7372
this.autofocus = false,
7473
this.focusNode,
7574
this.onFocus,
75+
this.layout = PaymentElementLayout.accordion,
76+
this.appearance,
77+
this.locale,
78+
this.defaultValues,
79+
this.business,
80+
this.paymentMethodOrder,
81+
this.fields,
82+
this.readOnly,
83+
this.terms,
84+
this.wallets,
85+
this.applePay,
86+
}) : clientSecret = null,
87+
customerSessionClientSecret = null;
88+
89+
const PaymentElement.withIntent({
90+
super.key,
91+
required this.clientSecret,
7692
required this.onCardChanged,
93+
this.customerSessionClientSecret,
94+
this.paymentMethodTypes,
95+
this.paymentMethodCreation,
96+
this.width,
97+
this.height,
98+
this.style,
99+
this.placeholder,
100+
this.enablePostalCode = false,
101+
this.autofocus = false,
102+
this.focusNode,
103+
this.onFocus,
77104
this.layout = PaymentElementLayout.accordion,
78105
this.appearance,
79106
this.locale,
@@ -85,7 +112,9 @@ class PaymentElement extends StatefulWidget {
85112
this.terms,
86113
this.wallets,
87114
this.applePay,
88-
});
115+
}) : amount = null,
116+
currency = null,
117+
mode = null;
89118

90119
@override
91120
State<PaymentElement> createState() => PaymentElementState();

0 commit comments

Comments
 (0)