PIPRES-794 Fix credit card 422 amount error with active payment surcharge#1440
Open
TLabutis wants to merge 1 commit into
Open
PIPRES-794 Fix credit card 422 amount error with active payment surcharge#1440TLabutis wants to merge 1 commit into
TLabutis wants to merge 1 commit into
Conversation
…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.
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.
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) intoCartLinesService::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 andPS_ROUND_TYPErounds per line (or on the total).Fix
Pass the pre-fee
$amountintogetCartLines(), 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
Note
An unrelated rounding bug (free-shipping voucher on a paid carrier) was found during this work and filed separately as PIPRES-795.