Skip to content

Commit

Permalink
Update types for Saved Payment Methods (#625)
Browse files Browse the repository at this point in the history
* Add spm types

* Fix comment

* Fix lint

* Add tests
  • Loading branch information
cskillingstad-stripe authored Jun 20, 2024
1 parent 35cbeab commit 8c14042
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
25 changes: 24 additions & 1 deletion tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ const elementsPMCProvided = stripe.elements({

const elementsNoOptions: StripeElements = stripe.elements();

const elementsCustomerSessionClientSecret = stripe.elements({
customerSessionClientSecret: 'test_123',
});

const MY_STYLE: StripeElementStyle = {
base: {
iconColor: '#c4f0ff',
Expand Down Expand Up @@ -459,7 +463,26 @@ paymentElement
'change',
(e: {
elementType: 'payment';
value: {type: string};
value: {
type: string;
payment_method?: {
id: string;
type: string;
billing_details: {
address: {
city: null | string;
country: null | string;
line1: null | string;
line2: null | string;
postal_code: null | string;
state: null | string;
};
name: null | string;
email: null | string;
phone: null | string;
};
};
};
collapsed: boolean;
complete: boolean;
empty: boolean;
Expand Down
5 changes: 5 additions & 0 deletions types/stripe-js/elements-group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ interface BaseStripeElementsOptions {
* Supported for the `payment`, `shippingAddress`, and `linkAuthentication` Elements.
*/
customerOptions?: CustomerOptions;

/**
* Display saved PaymentMethods and Customer information.
*/
customerSessionClientSecret?: string;
}

export interface StripeElementsOptionsClientSecret
Expand Down
22 changes: 21 additions & 1 deletion types/stripe-js/elements/payment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ export interface StripePaymentElementChangeEvent {

/**
* An object containing the currently selected PaymentMethod type (in snake_case, for example "afterpay_clearpay").
* If a payment method is selected, it will be included in the object.
*/
value: {type: string};
value: {
type: string;
payment_method?: {
id: string;
type: string;
billing_details: {
address: {
city: null | string;
country: null | string;
line1: null | string;
line2: null | string;
postal_code: null | string;
state: null | string;
};
name: null | string;
email: null | string;
phone: null | string;
};
};
};
}

0 comments on commit 8c14042

Please sign in to comment.