Skip to content

Commit

Permalink
add dedicated setupintent types; add confirmation_token (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwang-stripe committed May 5, 2024
1 parent b906dc1 commit 395ad83
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
7 changes: 7 additions & 0 deletions types/stripe-js/payment-intents.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,13 @@ export interface ConfirmPaymentData extends PaymentIntentConfirmParams {
allow_redisplay?: 'always' | 'limited' | 'unspecified';
};

/**
* Optional `id` of an existing [ConfirmationToken](https://stripe.com/docs/api/confirmation_tokens).
*
* @docs https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-confirmation_token
*/
confirmation_token?: string;

/**
* Optional `id` of an existing [PaymentMethod](https://stripe.com/docs/api/payment_methods).
*
Expand Down
55 changes: 54 additions & 1 deletion types/stripe-js/setup-intents.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SetupIntentConfirmParams} from '../api';
import {PaymentMethodCreateParams, SetupIntentConfirmParams} from '../api';

import {
CreatePaymentMethodAcssDebitData,
Expand All @@ -17,6 +17,59 @@ import {

import {Omit} from '../utils';

/**
* Data to be sent with a `stripe.confirmSetup` request.
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
*/
export interface ConfirmSetupData extends SetupIntentConfirmParams {
/**
* The url your customer will be directed to after they complete payment.
*/
return_url: string;

/**
* An object to attach additional billing_details to the PaymentMethod created via Elements.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_data
*/
payment_method_data?: {
/**
* The customer's billing details. Details collected by Elements will override values passed here.
* Billing fields that are omitted in the Payment Element via the `fields` option required.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_data-billing_details
*/
billing_details?: PaymentMethodCreateParams.BillingDetails;

/**
* Requires beta access:
* Contact [Stripe support](https://support.stripe.com/) for more information.
*
* Specifies if the PaymentMethod should be redisplayed when using the Saved Payment Method feature
*/
allow_redisplay?: 'always' | 'limited' | 'unspecified';
};

/**
* Optional `id` of an existing [ConfirmationToken](https://stripe.com/docs/api/confirmation_tokens).
*
* @docs https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-confirmation_token
*/
confirmation_token?: string;

/**
* Optional `id` of an existing [PaymentMethod](https://stripe.com/docs/api/payment_methods).
*
* @docs https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-payment_method
*/
payment_method?: string;

/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;
}

/**
* Data to be sent with a `stripe.confirmCardSetup` request.
* Refer to the [Setup Intents API](https://stripe.com/docs/api/setup_intents/confirm) for a full list of parameters.
Expand Down
12 changes: 6 additions & 6 deletions types/stripe-js/stripe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ export interface Stripe {
*/
confirmSetup(options: {
elements: StripeElements;
confirmParams?: Partial<paymentIntents.ConfirmPaymentData>;
confirmParams?: Partial<setupIntents.ConfirmSetupData>;
redirect: 'if_required';
}): Promise<SetupIntentResult>;

Expand All @@ -725,7 +725,7 @@ export interface Stripe {
confirmSetup(options: {
elements?: StripeElements;
clientSecret: string;
confirmParams?: Partial<paymentIntents.ConfirmPaymentData>;
confirmParams?: Partial<setupIntents.ConfirmSetupData>;
redirect: 'if_required';
}): Promise<SetupIntentResult>;

Expand All @@ -738,7 +738,7 @@ export interface Stripe {
*/
confirmSetup(options: {
elements: StripeElements;
confirmParams: paymentIntents.ConfirmPaymentData;
confirmParams: setupIntents.ConfirmSetupData;
redirect?: 'always';
}): Promise<never | {error: StripeError}>;

Expand All @@ -752,7 +752,7 @@ export interface Stripe {
confirmSetup(options: {
elements?: StripeElements;
clientSecret: string;
confirmParams: paymentIntents.ConfirmPaymentData;
confirmParams: setupIntents.ConfirmSetupData;
redirect?: 'always';
}): Promise<never | {error: StripeError}>;

Expand Down Expand Up @@ -1299,8 +1299,8 @@ export type EphemeralKeyNonceResult =
| {nonce: string; error?: undefined}
| {nonce?: undefined; error: StripeError};

/* A Radar Session is a snapshot of the browser metadata and device details that helps Radar make more accurate predictions on your payments.
This metadata includes information like IP address, browser, screen or device information, and other device characteristics.
/* A Radar Session is a snapshot of the browser metadata and device details that helps Radar make more accurate predictions on your payments.
This metadata includes information like IP address, browser, screen or device information, and other device characteristics.
You can find more details about how Radar uses this data by reading about how Radar performs [advanced fraud detection](https://stripe.com/docs/disputes/prevention/advanced-fraud-detection).
*/
export type RadarSessionPayload =
Expand Down

0 comments on commit 395ad83

Please sign in to comment.