Skip to content

Commit

Permalink
Add network preference for PE default values
Browse files Browse the repository at this point in the history
  • Loading branch information
alexoser-stripe committed Aug 26, 2024
1 parent 945484e commit 8d178d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/types/src/invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ const paymentElement: StripePaymentElement = elements.create('payment', {
postal_code: '94080',
},
},
card: {
network: ['cartes_bancaires', 'visa'],
},
},
fields: {
billingDetails: {
Expand Down
4 changes: 4 additions & 0 deletions types/stripe-js/elements/payment.d.ts
Original file line number Diff line number Diff line change
@@ -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 & {
/**
Expand Down Expand Up @@ -141,6 +142,9 @@ export interface DefaultValuesOption {
line2?: string;
};
};
card?: {
network?: CardNetworkBrand[];
};
}

export type FieldOption = 'auto' | 'never';
Expand Down

0 comments on commit 8d178d6

Please sign in to comment.