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

🐛(backend) cancel and refund installments to update with response instead of notification in payment backends #993

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jonathanreveille
Copy link
Member

@jonathanreveille jonathanreveille commented Dec 13, 2024

Purpose

With the actual payment provider backend we are using (Lyra), it seems like we don't get the events through ( handle_notification ) on our notification URL when the action is 'refund'. It's problematic because we use the notifications to update our objects once there is an event that occurs on the payment backend.

After couple of attempts to add the ipnTargetUrl into the payload of the cancel/refund request, it was not possible to receive the event afterwards.

Knowing that, I've decided to update the objects after the call with the response back from the payment provider. The payment provider itself suggested us to use the response directly to update our objects once calling the method cancel_or_refund .

Proposal

  • Use the response from the endpoint cancelOrRefund from Lyra Backend to update our objects when refund or cancel is done ( and refactor mail sending when order is fully refunded).
  • Update DummyPaymentBackend.
  • Update the DebugPaymentView to avoid creating 2 transactions when using the OrderGeneratorFactory

@jonathanreveille jonathanreveille added the bug Something isn't working label Dec 13, 2024
@jonathanreveille jonathanreveille self-assigned this Dec 13, 2024
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch 6 times, most recently from 8cc921c to 48fc29d Compare December 24, 2024 09:39
@jonathanreveille jonathanreveille changed the title 🐛(backend) cancel and refund installment on order notification issue... 🐛(backend) cancel and refund to update with response instead of notification in payment backends Dec 24, 2024
@jonathanreveille jonathanreveille changed the title 🐛(backend) cancel and refund to update with response instead of notification in payment backends 🐛(backend) cancel and refund installments to update with response instead of notification in payment backends Dec 24, 2024
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch from 48fc29d to d5db896 Compare December 24, 2024 16:13
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch 7 times, most recently from d5547b7 to c7536e9 Compare January 6, 2025 17:33
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch 5 times, most recently from 3ad2e5c to 7cb8f73 Compare January 7, 2025 14:08
CHANGELOG.md Outdated Show resolved Hide resolved
src/backend/joanie/payment/backends/dummy.py Show resolved Hide resolved
With the actual payment provider backend we are using (Lyra),
it seems like we don't get the events through our notification
URL when the action is 'refund'. It's problematic because
we use the notifications to update our objects. After
couple of attempts to add the ipnTargetUrl into the payload
of the cancel/refund request, it was not possible to receive
the event afterwards. Knowing that, we now update our objects
once we receive the response from the call of that endpoint.
Only for cancel or refund situation, we don't rely on the
notification anymore.

Fix #793
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch from 7cb8f73 to bc1e1b0 Compare January 9, 2025 18:56
We are now using Lyra as a payment backend. We have
discovered that Lyra does not let us handle through
notifications our refunded installments and forces
us to use the response of that call. To mimick the
behavior, we have decided to change the behavior
as well of the dummy payment backend to update
the objects once we call the method to cancel or
refund an installment for an order.
The `OrderGeneratorFactory` used for the debug payment view
was not appropriate because it creates a transaction when
the state of the order in in pending payment. When we
create a payment with the debug view, and we want to refund it,
the method `get_transaction_references_to_refund` would find
2 different transactions with the  same amount to refund. Only
one out of two is known to the payment provider, and thus,
it would raise an error while attempting to refund the
order from the backoffice of Joanie.
@jonathanreveille jonathanreveille force-pushed the feat/add_webhook_url_to_refund_transaction branch from bc1e1b0 to bb96253 Compare January 10, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants