Skip to content

Commit 585c69b

Browse files
Add missing types to Payment Intent Next Actions (#698)
1 parent a93850c commit 585c69b

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

tests/types/src/valid.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,14 @@ stripe.handleNextAction({clientSecret: ''}).then((res) => {
24572457

24582458
stripe
24592459
.verifyMicrodepositsForPayment('', {amounts: [32, 45]})
2460-
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => null);
2460+
.then((result: {paymentIntent?: PaymentIntent; error?: StripeError}) => {
2461+
if (result.paymentIntent?.next_action?.verify_with_microdeposits) {
2462+
console.log(
2463+
result.paymentIntent?.next_action?.verify_with_microdeposits
2464+
.arrival_date
2465+
);
2466+
}
2467+
});
24612468

24622469
stripe.createPaymentMethod({
24632470
elements: elements,

types/api/payment-intents.d.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,30 @@ export namespace PaymentIntent {
178178
}
179179

180180
export interface NextAction {
181+
/**
182+
* Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk`, `wechat_pay_display_qr_code`, or `verify_with_microdeposits`.
183+
*/
184+
type: string;
185+
186+
/**
187+
* Contains instructions for authenticating a payment by redirecting your customer to another page or application.
188+
*/
181189
redirect_to_url?: NextAction.RedirectToUrl;
182190

183191
/**
184-
* Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk` or `wechat_pay_display_qr_code`.
192+
* 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.
185193
*/
186-
type: string;
194+
use_stripe_sdk?: NextAction.UseStripeSdk;
187195

188196
/**
189197
* Wechat Pay display qrcode
190198
*/
191199
wechat_pay_display_qr_code?: NextAction.WechatPayDisplayQrCode;
200+
201+
/**
202+
* Contains details describing microdeposits verification flow.
203+
*/
204+
verify_with_microdeposits?: NextAction.VerifyWithMicrodeposits;
192205
}
193206

194207
export namespace NextAction {
@@ -214,6 +227,23 @@ export namespace PaymentIntent {
214227
*/
215228
image_data_url: string;
216229
}
230+
export interface UseStripeSdk {}
231+
export interface VerifyWithMicrodeposits {
232+
/**
233+
* The timestamp when the microdeposits are expected to land.
234+
*/
235+
arrival_date: number;
236+
237+
/**
238+
* The URL for the hosted verification page, which allows customers to verify their bank account.
239+
*/
240+
hosted_verification_url: string;
241+
242+
/**
243+
* The type of the microdeposit sent to the customer. Used to distinguish between different verification methods.
244+
*/
245+
microdeposit_type: string | null;
246+
}
217247
}
218248

219249
export type SetupFutureUsage = 'off_session' | 'on_session';

0 commit comments

Comments
 (0)