From 585c69b21210d78ba09bb28d85bdb8eafa45add2 Mon Sep 17 00:00:00 2001 From: Brad Daily <89274751+bdaily-stripe@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:50:31 -0500 Subject: [PATCH] Add missing types to Payment Intent Next Actions (#698) --- tests/types/src/valid.ts | 9 ++++++++- types/api/payment-intents.d.ts | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tests/types/src/valid.ts b/tests/types/src/valid.ts index 48a738c5..2a345725 100644 --- a/tests/types/src/valid.ts +++ b/tests/types/src/valid.ts @@ -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, diff --git a/types/api/payment-intents.d.ts b/types/api/payment-intents.d.ts index 6c83a4f3..95821e96 100644 --- a/types/api/payment-intents.d.ts +++ b/types/api/payment-intents.d.ts @@ -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 { @@ -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';