From 42d4730ed64014e37edb28ad4ed083bd3f2a2b6c Mon Sep 17 00:00:00 2001 From: Mohammad Ahtasham ul Hassan Date: Fri, 13 Dec 2024 18:48:33 +0500 Subject: [PATCH] fix: fixes --- commerce_coordinator/apps/commercetools/tasks.py | 3 +-- commerce_coordinator/apps/commercetools/tests/test_clients.py | 2 +- commerce_coordinator/apps/commercetools/tests/test_tasks.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/commerce_coordinator/apps/commercetools/tasks.py b/commerce_coordinator/apps/commercetools/tasks.py index f775c76f..688a19c6 100644 --- a/commerce_coordinator/apps/commercetools/tasks.py +++ b/commerce_coordinator/apps/commercetools/tasks.py @@ -56,7 +56,6 @@ def refund_from_stripe_task( Celery task for a refund registered in Stripe dashboard and need to create refund payment transaction record via Commercetools API. """ - # Celery serializes stripe_refund to a dict, so we need to explictly convert it back to a Refund object client = CommercetoolsAPIClient() try: payment = client.get_payment_by_key(payment_intent_id) @@ -72,7 +71,7 @@ def refund_from_stripe_task( return updated_payment except CommercetoolsError as err: logger.error(f"Unable to create refund transaction for payment [ {payment.id} ] " - f"on Stripe refund {stripe_refund.id} " + f"on Stripe refund {stripe_refund['id']} " f"with error {err.errors} and correlation id {err.correlation_id}") return None diff --git a/commerce_coordinator/apps/commercetools/tests/test_clients.py b/commerce_coordinator/apps/commercetools/tests/test_clients.py index 424bfa43..08357646 100644 --- a/commerce_coordinator/apps/commercetools/tests/test_clients.py +++ b/commerce_coordinator/apps/commercetools/tests/test_clients.py @@ -605,7 +605,7 @@ def test_create_refund_transaction_exception(self): expected_message = ( f"[CommercetoolsError] Unable to create refund payment transaction for " - f"payment mock_payment_id and stripe refund {mock_stripe_refund.id} " + f"payment mock_payment_id and refund {mock_stripe_refund.id} " f"- Correlation ID: {exception.correlation_id}, Details: {exception.errors}" ) diff --git a/commerce_coordinator/apps/commercetools/tests/test_tasks.py b/commerce_coordinator/apps/commercetools/tests/test_tasks.py index 3b2e6863..15dcd241 100644 --- a/commerce_coordinator/apps/commercetools/tests/test_tasks.py +++ b/commerce_coordinator/apps/commercetools/tests/test_tasks.py @@ -119,7 +119,7 @@ def test_correct_arguments_passed(self, mock_client): mock_client().create_return_payment_transaction.assert_called_once_with( payment_id=mock_payment.id, payment_version=mock_payment.version, - stripe_refund=mock_stripe_refund + refund=mock_stripe_refund ) def test_full_refund_already_exists(self, mock_client):