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

Legacy capture webhook refactoring #1908

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Conversation

garmashdev
Copy link
Collaborator

@garmashdev garmashdev commented Nov 26, 2024

Description

Refactoring the invoice webhook for the legacy flow to align it with the API flow:
https://github.com/BoltApp/source/blob/5fd05c30b2518b8d813be44b4815d8c0a2807f7f/hail/services/merchantproxy/cart/magento2/webhook.go#L620

Changes introduced in this PR:

  1. Handling fully covered offline invoices:
  • Currently, if an offline invoice fully covering the order is already created in Magento (offline mode or via an ERP system), we throw the error: "The same capture amount was already invoiced."
  • In this PR, we simply skip creating a new invoice and avoid throwing an error.
  1. Handling partially covered offline invoices:
  • Currently, if an offline invoice partially covering the order is already created in Magento (offline mode or via an ERP system) and a request is made for a full invoice, we throw the error:
    "Capture amount is invalid: capture amount [%1], previously captured [%2], grand total [%3]."
  • In this PR, we create an invoice for the remaining amount needed to cover the order instead of throwing an error.

Fixes:
https://app.devrev.ai/bolt-inc/works/ISS-200
https://app.asana.com/0/1200879031426307/1207325055456921/f

#changelog Legacy capture webhook refactoring

Type of change

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please validate that you have tested your change in at least one of the following areas:

  • Successfully tested locally (or docker image)
  • Successfully tested on a staging or sandbox server
  • Successfully tested on a merchant's staging server

For PR Reviewer

  • Reviewed unit tests to make sure we are using real components rather than mocks as much as possible?
  • For any major change (observer, new Bolt feature, core Magento interaction) we must add a feature switch, did you verify this?

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • New and existing unit tests pass locally with my changes.
  • I have created or modified unit tests to sufficiently cover my changes.
  • I have added my ticket link and provided a changelog message.

Copy link
Collaborator Author

garmashdev commented Nov 26, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@garmashdev garmashdev marked this pull request as ready for review November 27, 2024 07:40
@garmashdev garmashdev requested a review from a team as a code owner November 27, 2024 07:40
@garmashdev garmashdev requested review from pejter and dumega November 27, 2024 07:40
@garmashdev garmashdev merged commit 6de6c70 into master Dec 17, 2024
11 checks passed
@garmashdev garmashdev deleted the ygarmash/legacy_capture_webhook branch December 17, 2024 09:18
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.

3 participants