Skip to content

Commit

Permalink
fix: multiple paypal refund transactions bug
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsajjadkazmii committed Dec 19, 2024
1 parent 9242856 commit 9e14286
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commerce_coordinator/apps/commercetools/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def refund_from_paypal_task(
client = CommercetoolsAPIClient()
try:
payment = client.get_payment_by_transaction_interaction_id(paypal_capture_id)
if has_full_refund_transaction(payment):
logger.info(f"PayPal payment.capture.refunded event received, but Payment with ID {payment.id} "
f"already has a refund with id:{refund.id}. Skipping task to add refund transaction.")
return None

Check failure on line 94 in commerce_coordinator/apps/commercetools/tasks.py

View workflow job for this annotation

GitHub Actions / tests (ubuntu-20.04, 3.12, django42)

Missing coverage

Missing coverage on lines 91-94
updated_payment = client.create_return_payment_transaction(
payment_id=payment.id,
payment_version=payment.version,
Expand Down

0 comments on commit 9e14286

Please sign in to comment.