-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(core-flows): payment error handling #13876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core-flows): payment error handling #13876
Conversation
🦋 Changeset detectedLatest commit: 098a2d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@SGFGOV is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
|
@olivermrbl , sorry to ping you directly. would you mind reviewing and approving. it's blocking a development activity. We need a method of sending an error message up the stack from the the payment provider. This seemed the simplest way to do so |
|
Hi @SGFGOV ! Can you give a little bit more context as to what is happening? I think the PR makes sense, but I am scared that it might be a breaking change for some people. My reasoning behind this is "what exactly happens with those medusa errors that are "skipped"? You see the error received is mangled? Can you maybe provide an example? |
|
When those messages are skipped the old flow continues..so whatever was the older behaviour prior to this PR, that is preserved. |
packages/core/core-flows/src/payment/steps/authorize-payment-session.ts
Outdated
Show resolved
Hide resolved
|
@adrien2p thanks for approving. has the been merged into the dev or will it be included in the next release |
Thanks I figured it out :) it's in the changeset |
|
@SGFGOV It looks like one test is failing. I cannot deploy it without the text fixed :/ |
|
Ok let me fix it :) |
…ub.com/SGFGOV/medusa into fix/payment-provider-error-propogation
|
@willbouch please check and approve |

Summary
errors in the provider authorization step wasn't ever propogated up the stack. Instead the message received was mangled.
Why — Why are these changes relevant or necessary?
Many times there are provider specific error codes and message that need to be visible in other parts of the stack via api etc.
Please provide answer here
It's very simple. We check if the error is a medusaError. This implies the provider has sanitised the error. If it is we allow it to propogate up the stack as it is. Else, we continue with the earlier implementations.
Please provide answer here
Testing — How have these changes been tested, or how can the reviewer test the feature?
You can throw an error in a provider and you should see the same in your api response.
Examples
This isn't really a feature. Just a small bug fix
Additional Context
Note
Propagates MedusaError from payment authorization and updates integration test to assert cart completion returns cart with payment authorization error.
packages/core/core-flows)payment/steps/authorize-payment-session.ts, rethrow provider errors whenMedusaError.isMedusaError(e)is true to preserve original payment authorization errors.integration-tests/modules/__tests__/cart/store/carts.spec.tsto mockauthorizePaymentSessionthrowingMedusaError.Types.PAYMENT_AUTHORIZATION_ERRORand assert/store/carts/:id/completereturns atype: "cart"response with the payment authorization error."@medusajs/core-flows".Written by Cursor Bugbot for commit 098a2d5. This will update automatically on new commits. Configure here.