Skip to content

PIPRES-794 Fix credit card 422 amount error with active payment surcharge#1440

Open
TLabutis wants to merge 1 commit into
masterfrom
PIPRES-794-creditcard-payment-fail-amount-rounding-issue
Open

PIPRES-794 Fix credit card 422 amount error with active payment surcharge#1440
TLabutis wants to merge 1 commit into
masterfrom
PIPRES-794-creditcard-payment-fail-amount-rounding-issue

Conversation

@TLabutis

@TLabutis TLabutis commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Ticket

PIPRES-794 (GitHub #1437) - credit card payments failing with a Mollie 422 "amount is off".

Cause

On the Payments API path, PaymentMethodService::getPaymentData() passed the surcharge-inclusive total ($totalAmount) into CartLinesService::getCartLines(). The payment fee is added there as its own line, so folding it into the amount left the per-line rounding residual conflated with the fee and never compensated. The order lines then summed to a cent more or less than the order amount, which Mollie rejects with a 422. Triggered when a payment surcharge is active and PS_ROUND_TYPE rounds per line (or on the total).

Fix

Pass the pre-fee $amount into getCartLines(), matching the Orders API path. The surcharge is still added as its own line and the amount sent to Mollie is unchanged. One line (plus a comment).

Testing

  • Reproduced and verified before/after through a real storefront checkout under the merchant's confirmed settings (round on each line, round half up, percentage surcharge 2.9%).
  • 136-scenario regression matrix (fixed vs unpatched): only surcharge + rounding-gap cases on the Payments path change and now pass; every other scenario is byte-identical, including a no-op when no surcharge is active.
  • No regression to the 6.4.3 whole-number distribution or the 6.4.4 high-value VAT fix (PIPRES-781): the per-line VAT invariant holds with 0 violations.

Note

An unrelated rounding bug (free-shipping voucher on a paid carrier) was found during this work and filed separately as PIPRES-795.

…arge

On the Payments API path the surcharge-inclusive total was passed to the
order-line builder, so a per-line rounding cent was conflated with the fee
and never compensated. The line items then summed to a cent more or less
than the order amount, which Mollie rejects with a 422.

Pass the pre-fee amount into getCartLines instead (the surcharge is added
as its own line), matching the Orders API path.
@TLabutis TLabutis changed the base branch from release-6.4.4 to master July 9, 2026 13:21
@TLabutis TLabutis changed the base branch from master to release-6.4.4 July 9, 2026 13:22
@TLabutis TLabutis changed the base branch from release-6.4.4 to master July 9, 2026 13:23
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