Skip to content

[ECP-10044] Compare authorized amounts in minor units to complete split payments - #3397

Merged
candemiralp merged 2 commits into
mainfrom
ECP-10044
Oct 28, 2026
Merged

candemiralp merged 2 commits into
mainfrom
ECP-10044

Conversation

@candemiralp

Copy link
Copy Markdown
Contributor

Description

For some split (partial) payments, the last AUTHORISATION webhook did not complete the order: it was neither finalised nor invoiced, and only a history comment was added. Whether it happened depended on the amounts (e.g. 10.00 + 20.00 worked, 10.10 + 20.20 did not).

AdyenOrderPayment::isFullAmountAuthorized() compared the grand total with payment_authorization_amount using === on floats. AuthorisationWebhookHandler adds each partial amount to the stored value, which is loaded from sales_order as a decimal string, so the sum can pick up float noise: "25.0000" + 4.99 is 29.990000000000002, which is not identical to 29.99. Both amounts are now compared in minor units with Data::formatAmount(), using the base currency for base and the order currency for display charged currency, the same way as isFullAmountFinalized() and v10. Amounts are therefore matched at the currency precision instead of 4 decimals. Based on the investigation and patch in #3379.

Tested scenarios

  • Partial payments whose float sum is not exact (25.00 + 4.99, 10.10 + 20.20) are fully authorized for display and base charged currency
  • Exact sums, zero decimal currency (JPY) and decimal string values from the database still match
  • Partially authorized, one cent short, nothing authorized and unknown charged currency are not fully authorized
  • Unit test suite passes

Fixes #3352

@candemiralp
candemiralp requested a review from a team as a code owner October 27, 2026 13:27
@candemiralp candemiralp added the Fix Indicates a bug fix label Oct 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the isFullAmountAuthorized method in AdyenOrderPayment.php to compare authorization amounts in minor units using the Adyen data helper, replacing direct float comparisons to avoid precision issues. It also adds comprehensive unit tests with a data provider to validate this behavior across different currencies and partial payment scenarios. There are no review comments to address, and I have no feedback to provide.

@sonarqubecloud

Copy link
Copy Markdown

@candemiralp
candemiralp merged commit 3f433b9 into main Oct 28, 2026
9 of 10 checks passed
@candemiralp
candemiralp deleted the ECP-10044 branch October 28, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Indicates a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ECP-10044][Bug]: Full order amount has not been authorized

3 participants