fix(medusa-payment-stripe): Fix error handling (#5991)

This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-01-04 09:04:43 +01:00
1 parent 3550750975
commit 7f62ab1b58
3 files changed
+14 -8

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/medusa": patch
"medusa-payment-stripe": patch
---
fix(medusa, medusa-payment-stripe): fix stripe error handling
@@ -322,16 +322,16 @@ abstract class StripeBase extends AbstractPaymentProcessor {
protected buildError( protected buildError(
message: string, message: string,
e: Stripe.StripeRawError | PaymentProcessorError | Error error: Stripe.StripeRawError | PaymentProcessorError | Error
): PaymentProcessorError { ): PaymentProcessorError {
return { return {
error: message, error: message,
code: "code" in e ? e.code : "", code: "code" in error ? error.code : "unknown",
detail: isPaymentProcessorError(e) detail: isPaymentProcessorError(error)
? `${e.error}${EOL}${e.detail ?? ""}` ? `${error.error}${EOL}${error.detail ?? ""}`
: "detail" in e : "detail" in error
? e.detail ? error.detail
: e.message ?? "", : error.message ?? "",
} }
} }
} }
@@ -777,5 +777,5 @@ export abstract class AbstractPaymentProcessor implements PaymentProcessor {
export function isPaymentProcessorError( export function isPaymentProcessorError(
obj: any obj: any
): obj is PaymentProcessorError { ): obj is PaymentProcessorError {
return obj && typeof obj === "object" && (obj.error || obj.code || obj.detail) return obj && typeof obj === "object" && obj.error && obj.code && obj.detail
} }