Skip to content

Commit

Permalink
Add missing types to Payment Intent Next Actions (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdaily-stripe authored Dec 12, 2024
1 parent a93850c commit 585c69b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
9 changes: 8 additions & 1 deletion tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,14 @@ stripe.handleNextAction({clientSecret: ''}).then((res) => {

stripe
.verifyMicrodepositsForPayment('', {amounts: [32, 45]})
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => null);
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => {
if (result.paymentIntent?.next_action?.verify_with_microdeposits) {
console.log(
result.paymentIntent?.next_action?.verify_with_microdeposits
.arrival_date
);
}
});

stripe.createPaymentMethod({
elements: elements,
Expand Down
34 changes: 32 additions & 2 deletions types/api/payment-intents.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,30 @@ export namespace PaymentIntent {
}

export interface NextAction {
/**
* Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk`, `wechat_pay_display_qr_code`, or `verify_with_microdeposits`.
*/
type: string;

/**
* Contains instructions for authenticating a payment by redirecting your customer to another page or application.
*/
redirect_to_url?: NextAction.RedirectToUrl;

/**
* Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk` or `wechat_pay_display_qr_code`.
* When confirming a SetupIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. The shape of the contents is subject to change and is only intended to be used by Stripe.js.
*/
type: string;
use_stripe_sdk?: NextAction.UseStripeSdk;

/**
* Wechat Pay display qrcode
*/
wechat_pay_display_qr_code?: NextAction.WechatPayDisplayQrCode;

/**
* Contains details describing microdeposits verification flow.
*/
verify_with_microdeposits?: NextAction.VerifyWithMicrodeposits;
}

export namespace NextAction {
Expand All @@ -214,6 +227,23 @@ export namespace PaymentIntent {
*/
image_data_url: string;
}
export interface UseStripeSdk {}
export interface VerifyWithMicrodeposits {
/**
* The timestamp when the microdeposits are expected to land.
*/
arrival_date: number;

/**
* The URL for the hosted verification page, which allows customers to verify their bank account.
*/
hosted_verification_url: string;

/**
* The type of the microdeposit sent to the customer. Used to distinguish between different verification methods.
*/
microdeposit_type: string | null;
}
}

export type SetupFutureUsage = 'off_session' | 'on_session';
Expand Down

0 comments on commit 585c69b

Please sign in to comment.