Detect a currency change after the Quickpay payment was created - #63
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #63 +/- ##
============================================
+ Coverage 96.93% 97.04% +0.10%
- Complexity 144 151 +7
============================================
Files 15 15
Lines 392 406 +14
============================================
+ Hits 380 394 +14
Misses 12 12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A Quickpay payment's currency is fixed at creation — the authorize happens in that currency no matter what the details say. But ConvertPaymentAction overwrote the stored currency on every conversion, so a Payum payment whose currency changed after conversion silently drifted: the shop believed one currency while Quickpay kept charging in the other, reading the amount in the wrong unit. A drifted currency now throws a LogicException naming both currencies — the payment must be cancelled and a fresh one converted. A model without a currency (nullable on Payum's model) keeps the stored value instead of overwriting it with null, and an agreeing model refreshes it as before.
loevgaard
force-pushed
the
fix/convert-currency-drift
branch
from
August 17, 2026 06:55
36ecfef to
5759e1f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes robustness finding R7 of #57.
Problem
ConvertPaymentActionwrote$details['currency'] = $paymentModel->getCurrencyCode()unconditionally, on every conversion. A Quickpay payment's currency is fixed at creation, so if the Payum payment's currency changed after the Quickpay payment existed, the stored value silently drifted: the shop believed one currency while Quickpay kept authorizing in the other — with the amount read in the wrong unit. (A null model currency also overwrote a good stored value.)Fix
currencyis written from the same asserted value the payment is created with.LogicExceptionnaming the payment and both currencies — the payment must be cancelled and a fresh one converted. A model without a currency keeps the stored value; an agreeing model is a no-op refresh.Tests
Drifted currency throws with zero HTTP requests; a currency-less model keeps the stored value; the existing already-created and create-path tests pin the unchanged behavior.