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:
5
.changeset/dirty-radios-kiss.md
Normal file
5
.changeset/dirty-radios-kiss.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/core-flows": patch
|
||||
---
|
||||
|
||||
fix(core-flows): payment error handling
|
||||
@@ -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`
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user