Skip to content

fix: Handle payment gateway refund errors in admin - #3803

Open
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/admin-refund-gateway-errors
Open

fix: Handle payment gateway refund errors in admin#3803
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/admin-refund-gateway-errors

Conversation

@sentry

@sentry sentry Bot commented Jul 30, 2026

Copy link
Copy Markdown

This PR adds a try-except block around the refund_order call in the Django admin refund view (ecommerce/admin.py).

Previously, if the underlying payment gateway (e.g., CyberSource) returned an unexpected error response format (such as a 401 Unauthorized error which lacks a top-level 'reason' key), it would lead to a KeyError and an unhandled 500 error in the admin interface.

This change catches any exceptions raised by the payment gateway during a refund attempt and displays a user-friendly error message to the admin, preventing a server error and providing better feedback. It also logs the full exception for debugging purposes.

This change complements a fix in mitol-django-payment-gateway that makes the perform_refund method more robust against varied error response structures from CyberSource.

Fixes MITXONLINE-6WC

@github-actions

Copy link
Copy Markdown

OpenAPI Changes

Show/hide changes
## Changes for v0.yaml:
No changes detected

## Changes for v1.yaml:
No changes detected

## Changes for v2.yaml:
No changes detected

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@asadali145 asadali145 self-assigned this Jul 30, 2026
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.

1 participant