fix(core-flows): payment error handling (#13876)

* fix: payment error handling

* Create dirty-radios-kiss.md

* fix: updated to use isMedusaError

* fix: error message updated and error type corrected

---------

Co-authored-by: William Bouchard <46496014+willbouch@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Govind
2025-11-07 18:27:44 +05:30
committed by GitHub
parent dc6f253d31
commit 5499cd2749
3 changed files with 12 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
fix(core-flows): payment error handling

View File

@@ -2168,8 +2168,8 @@ medusaIntegrationTestRunner({
authorizePaymentSessionSpy.mockImplementation(
(id, context, sharedContext) => {
throw new MedusaError(
MedusaError.Types.INVALID_DATA,
`Throw a random error`
MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR,
`Payment authorization failed`
)
}
)

View File

@@ -58,6 +58,11 @@ export const authorizePaymentSessionStep = createStep(
logger.error(
`Error was thrown trying to authorize payment session - ${input.id} - ${e}`
)
// this implies the error is already a MedusaError, so we can throw it safely,
if (MedusaError.isMedusaError(e)) {
throw e
}
}
const paymentSession = await paymentModule.retrievePaymentSession(