diff --git a/tests/types/src/invalid.ts b/tests/types/src/invalid.ts index 67d2ce55..8acb9cf1 100644 --- a/tests/types/src/invalid.ts +++ b/tests/types/src/invalid.ts @@ -88,6 +88,18 @@ cardNumberElement.update({ preferredNetwork: ['cartes_bancaires'], }); +// invalid preferred network +// @ts-expect-error: No overload matches this call +elements.create('payment', { + defaultValues: {card: {network: ['invalid_network']}}, +}); + +// invalid type for preferred network +// @ts-expect-error: No overload matches this call +elements.create('payment', { + defaultValues: {card: {network: 'invalid_network'}}, +}); + paymentElement.on('change', (e) => { // @ts-expect-error: `error` is not present on PaymentElement "change" event. if (e.error) { diff --git a/tests/types/src/valid.ts b/tests/types/src/valid.ts index d0da8a76..7bd9a523 100644 --- a/tests/types/src/valid.ts +++ b/tests/types/src/valid.ts @@ -392,6 +392,9 @@ const paymentElement: StripePaymentElement = elements.create('payment', { postal_code: '94080', }, }, + card: { + network: ['cartes_bancaires', 'visa'], + }, }, fields: { billingDetails: { diff --git a/types/stripe-js/elements/payment.d.ts b/types/stripe-js/elements/payment.d.ts index 499d74d3..e16c9e05 100644 --- a/types/stripe-js/elements/payment.d.ts +++ b/types/stripe-js/elements/payment.d.ts @@ -1,6 +1,7 @@ import {StripeElementBase} from './base'; import {StripeError} from '../stripe'; import {ApplePayOption} from './apple-pay'; +import {CardNetworkBrand} from '../elements-group'; export type StripePaymentElement = StripeElementBase & { /** @@ -141,6 +142,9 @@ export interface DefaultValuesOption { line2?: string; }; }; + card?: { + network?: CardNetworkBrand[]; + }; } export type FieldOption = 'auto' | 'never';