Skip to content

Fix CyberSource refund handling - #4016

Open
cp-at-mit wants to merge 3 commits into
mainfrom
transaction-amount-fix
Open

cp-at-mit wants to merge 3 commits into
mainfrom
transaction-amount-fix

Conversation

@cp-at-mit

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

NA

Description (What does it do?)

Fixes an issue where we were incorrectly reading data from the cybersource JSON response. This was resulting in transactions being created with incorrect data. This PR also adds a fallback for reading the transaction ID from the Transaction model.

An example of a recent, incorrect, Transaction record is: https://mitxonline.mit.edu/admin/ecommerce/order/557540/change/?_changelist_filters=state__exact%3Dfulfilled

Notice how the amount of the Transaction shown is 0.

How can this be tested?

Complete a purchase and verify that the amount is correct populated.

Additional Context

The multi-gateway commit (Aug 5, 0b76b0b) changed create_transaction to branch by gateway type, and it reads the amount as: transaction_payload["amount"] = payment_data.get("amount", Decimal(0))

The CyberSource Secure Acceptance response (the request.POST from checkout) uses req_amount, not amount. The amount key only appears in CyberSource's REST API responses. So every SA checkout since Aug 5 stored Transaction.amount = 0.

Handle legacy CyberSource refund records where `transaction_id` only exists on the model field, and accept Secure Acceptance `req_amount` responses when creating transactions. Added coverage for both refund and amount parsing paths.
@cp-at-mit
cp-at-mit marked this pull request as ready for review September 23, 2026 16:10
@github-actions

github-actions Bot commented Sep 23, 2026

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).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant