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:
authored and GitHub committed 2025-11-07 07:57:44 -05:00
1 parent dc6f253d31
commit 5499cd2749
3 files changed
+12 -2

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
fix(core-flows): payment error handling
@@ -2168,8 +2168,8 @@ medusaIntegrationTestRunner({
authorizePaymentSessionSpy.mockImplementation( authorizePaymentSessionSpy.mockImplementation(
(id, context, sharedContext) => { (id, context, sharedContext) => {
throw new MedusaError( throw new MedusaError(
MedusaError.Types.INVALID_DATA, MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR,
`Throw a random error` `Payment authorization failed`
) )
} }
) )
@@ -58,6 +58,11 @@ export const authorizePaymentSessionStep = createStep(
logger.error( logger.error(
`Error was thrown trying to authorize payment session - ${input.id} - ${e}` `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( const paymentSession = await paymentModule.retrievePaymentSession(