Skip to content
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

Surface original Vertex errors via new bang methods #75

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nht007
Copy link
Member

@nht007 nht007 commented Aug 7, 2024

Stakeholder Overview (learn more)

As part of the Hybrid GO Migration work in stores, we've begun issuing tax distributions at the time of fulfillment of items to account for any changes to shipping address and tax amount between the time of purchase and the time of fulfillment.

That tax distribution process is ignorant of the prior state of the tax invoice originally reported to Vertex, and relies on idempotency to correct the tax invoice data in Vertex.

While this has worked well in most cases, we found that the Vertex API rejects tax distribution requests with an error response if there is no difference to the tax invoice data in Vertex vs. the data in the new tax distribution request.

Today, this results in a generic VertexClient::ServerError returned by the VertexClient to the stores app due to the masking of the raw Vertex API error via the fallback_response structure within the resource models.

While the raw error message returned by Vertex in this case is:

(soapenv:Client) Input tax has been specified but there are no taxes to which it may be distributed. Please verify the details for this transaction. (Savon::SOAPFault)

In order to differentiate this error with other errors related to Vertex API outages, etc. and handle this case accordingly (no-op, prevent reprocessing of jobs) we need access to the raw error message returned by Vertex.

We achieve this by adding ! request methods that bypass the fallback_response structure of the existing request methods and raising the lower level Savon::SOAPFault error to the application. The specific error type and message can then be accessed via the to_hash method and custom error handling can be performed.

Risk Estimate (learn more)

Relatively low risk as this is mostly the addition of new methods alongside existing ones, with release controlled by gem versioning.

Changes

  • Added quotation!, invoice!, distribute_tax!, tax_area! class methods to VertexClient that raise Savon::SOAPFault errors when errors are returned from the Vertex SOAP API

Notes

Relies on the Circuitbox circuit exception option, which was previously set to false across the board

Library-Specific
  • Increment the changelog (CHANGELOG.md)
  • Increment the version number (lib/version.rb)
  • [Release & Tag][release] the version above in Github

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants