From b648878245bbf435bce47bd62f134b84ce9dbeda Mon Sep 17 00:00:00 2001 From: Thomas Bruun Date: Mon, 14 Oct 2019 19:54:12 +0200 Subject: [PATCH] [stripe] Add missing properties on StripeError (#39016) * Remove seemingly unintentional property on StripeError It looks like this was supposed to contain a property name after the readonly keywork, bu instead StripeError now has a property named readonly. * Add missing properties to StripeError All properties except statusCode were added in version 7.10.0: https://github.com/stripe/stripe-node/pull/699 * Update stripe version number --- types/stripe/index.d.ts | 11 +++++++++-- types/stripe/stripe-tests.ts | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 60be376e3a..4f7f2ba036 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 6.32 +// Type definitions for stripe 7.10 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston // Peter Harris @@ -13900,9 +13900,16 @@ declare namespace Stripe { }; readonly requestId: string; readonly detail?: any; - readonly: number; readonly params?: string; readonly type: string; + readonly statusCode?: number; + + readonly charge?: string; + readonly decline_code?: string; + readonly payment_intent?: paymentIntents.IPaymentIntent; + readonly payment_method?: paymentMethods.IPaymentMethod; + readonly setup_intent?: setupIntents.ISetupIntent; + readonly source?: sources.ISource; } class StripeCardError extends StripeError { readonly type: 'StripeCardError'; diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 7d8fca1502..1713a262c5 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -2065,6 +2065,30 @@ stripe.charges if (err instanceof Stripe.errors.StripeCardError) { const type = err.type; } + + if (err instanceof Stripe.errors.StripeError) { + if (err.charge) { + const charge: string = err.charge; + } + if (err.payment_intent) { + const payment_intent: Stripe.paymentIntents.IPaymentIntent = err.payment_intent; + } + if (err.payment_method) { + const payment_method: Stripe.paymentMethods.IPaymentMethod = err.payment_method; + } + if (err.setup_intent) { + const setup_intent: Stripe.setupIntents.ISetupIntent = err.setup_intent; + } + if (err.source) { + const source: Stripe.sources.ISource = err.source; + } + if (err.decline_code) { + const decline_code: string = err.decline_code; + } + if (err.statusCode) { + const statusCode: number = err.statusCode; + } + } }); //#endregion Errors