Skip to content

Commit

Permalink
Add missing properties to StripeError
Browse files Browse the repository at this point in the history
All properties except statusCode were added in version 7.10.0: stripe/stripe-node#699
  • Loading branch information
bruun committed Oct 10, 2019
1 parent 68ce866 commit 7156946
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/stripe/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13902,6 +13902,14 @@ declare namespace Stripe {
readonly detail?: any;
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';
Expand Down
24 changes: 24 additions & 0 deletions types/stripe/stripe-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7156946

Please sign in to comment.