Skip to content

Commit

Permalink
Add defaultValues to StripePaymentElementOptions interface (#332)
Browse files Browse the repository at this point in the history
* Add `defaultValues` to `StripePaymentElementOptions`

* Run prettier

* Use 🐍 case for postal code
  • Loading branch information
starsirius committed Jun 16, 2022
1 parent 19cdc3e commit d5d45f6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ const afterpayClearpayMessageElement = elements.create(
);

const paymentElement: StripePaymentElement = elements.create('payment', {
defaultValues: {
billingDetails: {
name: 'Jane Doe',
email: 'jane.doe@example.com',
phone: '8004444444',
address: {
line1: '354 Oyster Point Blvd',
line2: '',
city: 'South San Francisco',
state: 'CA',
country: 'US',
postal_code: '94080',
},
},
},
fields: {
billingDetails: {
email: 'never',
Expand Down
21 changes: 21 additions & 0 deletions types/stripe-js/elements/payment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ export type StripePaymentElement = StripeElementBase & {
collapse(): StripePaymentElement;
};

export interface DefaultValuesOption {
billingDetails?: {
name?: string;
email?: string;
phone?: string;
address?: {
country?: string;
postal_code?: string;
state?: string;
city?: string;
line1?: string;
line2?: string;
};
};
}

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

export interface FieldsOption {
Expand Down Expand Up @@ -152,6 +168,11 @@ export interface WalletsOption {
}

export interface StripePaymentElementOptions {
/**
* Provide initial customer information that will be displayed in the Payment Element.
*/
defaultValues?: DefaultValuesOption;

/**
* Override the business name displayed in the Payment Element.
* By default the PaymentElement will use your Stripe account or business name.
Expand Down

0 comments on commit d5d45f6

Please sign in to comment.