diff --git a/tests/types/src/invalid.ts b/tests/types/src/invalid.ts index 851b545c..1f12a16b 100644 --- a/tests/types/src/invalid.ts +++ b/tests/types/src/invalid.ts @@ -166,6 +166,22 @@ elements.create('payment', { }, }); +// invalid type for walletOptions.emailRequired +// @ts-expect-error: No overload matches this call +elements.create('payment', { + walletOptions: { + emailRequired: 'yes', + }, +}); + +// invalid type for walletOptions.phoneNumberRequired +// @ts-expect-error: No overload matches this call +elements.create('payment', { + walletOptions: { + phoneNumberRequired: 'yes', + }, +}); + paymentElement.on('change', (e) => { // @ts-expect-error: `error` is not present on PaymentElement "change" event. if (e.error) { @@ -649,6 +665,22 @@ checkoutElementsSdk.createShippingAddressElement({ }, }); +// invalid type for walletOptions.emailRequired in EwCS +checkoutElementsSdk.createPaymentElement({ + walletOptions: { + // @ts-expect-error: Type 'string' is not assignable to type 'boolean | undefined' + emailRequired: 'yes', + }, +}); + +// invalid type for walletOptions.phoneNumberRequired in EwCS +checkoutElementsSdk.createPaymentElement({ + walletOptions: { + // @ts-expect-error: Type 'string' is not assignable to type 'boolean | undefined' + phoneNumberRequired: 'yes', + }, +}); + const checkoutFormSdk = stripe.initCheckoutFormSdk({ clientSecret: 'cs_test_foo', }); diff --git a/tests/types/src/valid.ts b/tests/types/src/valid.ts index b5ed70eb..65d7b3f2 100644 --- a/tests/types/src/valid.ts +++ b/tests/types/src/valid.ts @@ -541,6 +541,10 @@ const paymentElement: StripePaymentElement = elements.create('payment', { googlePay: 'auto', link: 'auto', }, + walletOptions: { + emailRequired: true, + phoneNumberRequired: true, + }, layout: { type: 'accordion', visibleAccordionItemsCount: 2, @@ -581,6 +585,13 @@ paymentElement.update({ }, }); +paymentElement.update({ + walletOptions: { + emailRequired: true, + phoneNumberRequired: false, + }, +}); + let paymentElementDefaults: StripePaymentElement = elements.create('payment'); paymentElementDefaults = elements.create('payment', {}); @@ -3693,6 +3704,12 @@ const checkoutElementsSdk = stripe.initCheckoutElementsSdk({ clientSecret: 'cs_test_foo', }); const checkoutPaymentElement: StripePaymentElement = checkoutElementsSdk.createPaymentElement(); +checkoutElementsSdk.createPaymentElement({ + walletOptions: { + emailRequired: true, + phoneNumberRequired: true, + }, +}); checkoutElementsSdk.getPaymentElement(); const checkoutAddressElement: StripeAddressElement = checkoutElementsSdk.createBillingAddressElement(); checkoutElementsSdk.getBillingAddressElement(); diff --git a/types/stripe-js/checkout.d.ts b/types/stripe-js/checkout.d.ts index c5e05152..d13722cc 100644 --- a/types/stripe-js/checkout.d.ts +++ b/types/stripe-js/checkout.d.ts @@ -3,6 +3,7 @@ import { Layout, TermsOption, StripePaymentElement, + PaymentWalletOptionsOption, } from './elements/payment'; import {ContactOption, StripeAddressElement} from './elements/address'; import {Appearance, CssFontSource, CustomFontSource} from './elements-group'; @@ -405,6 +406,7 @@ export type StripeCheckoutPaymentElementOptions = { terms?: TermsOption; fields?: FieldsOption; wallets?: PaymentWalletsOption; + walletOptions?: PaymentWalletOptionsOption; }; export type StripeCheckoutAddressElementOptions = { diff --git a/types/stripe-js/elements/payment.d.ts b/types/stripe-js/elements/payment.d.ts index 252ebeaa..0669cc73 100644 --- a/types/stripe-js/elements/payment.d.ts +++ b/types/stripe-js/elements/payment.d.ts @@ -334,6 +334,11 @@ export interface PaymentWalletsOption { link?: PaymentWalletOption; } +export interface PaymentWalletOptionsOption { + emailRequired?: boolean; + phoneNumberRequired?: boolean; +} + export type Layout = 'tabs' | 'accordion' | 'auto'; type RadiosOption = 'auto' | 'never' | 'always' | 'if_multiple'; @@ -390,6 +395,11 @@ export interface StripePaymentElementOptions { */ wallets?: PaymentWalletsOption; + /** + * Control wallet behavior options in the Payment Element. + */ + walletOptions?: PaymentWalletOptionsOption; + /** * Specify a layout to use when rendering a Payment Element. */