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

fix: PayPal refund bug on prod #317

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commerce_coordinator/apps/commercetools/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def create_return_payment_transaction(
try:
logger.info(
f"[CommercetoolsAPIClient] - Creating refund transaction for payment with ID {payment_id} "
f"following successful refund {refund['id']} in PSP: {psp}"
f"following successful refund {refund.get('id')} in PSP: {psp}"
syedsajjadkazmii marked this conversation as resolved.
Show resolved Hide resolved
)
refund = self._preprocess_refund_object(refund, psp)

Expand Down
6 changes: 6 additions & 0 deletions commerce_coordinator/apps/paypal/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django.conf import settings
from paypalserversdk.api_helper import ApiHelper
from paypalserversdk.configuration import Environment
from paypalserversdk.controllers.payments_controller import PaymentsController
from paypalserversdk.http.auth.o_auth_2 import ClientCredentialsAuthCredentials
from paypalserversdk.paypalserversdk_client import PaypalserversdkClient
Expand All @@ -18,6 +19,11 @@ def __init__(self):
o_auth_client_id=settings.PAYMENT_PROCESSOR_CONFIG['edx']['paypal']['client_id'],
o_auth_client_secret=settings.PAYMENT_PROCESSOR_CONFIG['edx']['paypal']['client_secret'],
),
environment=(
syedsajjadkazmii marked this conversation as resolved.
Show resolved Hide resolved
Environment.SANDBOX
if settings.PAYMENT_PROCESSOR_CONFIG['edx']['paypal']['env'] == 'sandbox'
else Environment.PRODUCTION
),
)

def refund_order(self, capture_id):
Expand Down
2 changes: 2 additions & 0 deletions commerce_coordinator/apps/paypal/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def run_filter(
tag = type(self).__name__

if psp != EDX_PAYPAL_PAYMENT_INTERFACE_NAME or not amount_in_cents or not ct_transaction_interaction_id:
logger.info(f'[{tag}] capture_id or amount_in_cents not set, '
f'skipping refund for order: {order_id} with psp: {psp}')
return PipelineCommand.CONTINUE.value

if has_been_refunded:
Expand Down
1 change: 1 addition & 0 deletions commerce_coordinator/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def root(*path_fragments):
'paypal_webhook_id': PAYPAL_WEBHOOK_ID,
'client_id': '',
'client_secret': '',
'env': 'sandbox',
},
},
}
Expand Down
Loading