Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not finish Payment with PayPal due to rounding issues #2804

Open
alex-jungwirth opened this issue Feb 22, 2025 · 2 comments
Open

Could not finish Payment with PayPal due to rounding issues #2804

alex-jungwirth opened this issue Feb 22, 2025 · 2 comments

Comments

@alex-jungwirth
Copy link

When using the built in Payment Method "PayPal" (Express Checkout), I get some rounding errors:
I have the option: "store prices with VAT" in my store config.

Example with Tax: 19%

Product Price (gross): 21,95 €
Quantity: 4
Shpping Costs (gross): 7,95 €

Calculation for Cart:
21,95 * 4 + 7,95 = 95,75

Calculation in PayPal Checkout (ConvertPaymentAction.php):
Product Price (net) * quty + taxTotal + shipping (net)
18,45 * 4 + 15,29 + 6,98 = 95,77

Due to the diff the paypal payment will not work.

Error in Transaction:

L_ERRORCODE0 10413
L_SHORTMESSAGE0 Total mismatch. See additional message for details.
L_LONGMESSAGE0 The totals of the cart item amounts do not match order amounts.
L_SEVERITYCODE0 Warning
@dpfaffenbauer
Copy link
Member

welcome to the world of tax calculation ;). We know this. Its due to how CoreShop calculates tax and how PayPal calculates it. CoreShop calculates it row based, so we calculate tax for every row, round it, and sum it. PayPal calculates tax for each tax-rate (so horizontal), it takes all net values and applies the tax-rate. Due to rounding, we get different results.

2 Solutions: Either increase the decimal factors (use eg. 4 numbers after the coma) to improve rounding issues. or create a OrderProcessor that calculates it back and removes the cent rounding. We already did that, I can provide the code for this next week.

@alex-jungwirth
Copy link
Author

welcome to the world of tax calculation ;). We know this. Its due to how CoreShop calculates tax and how PayPal calculates it. CoreShop calculates it row based, so we calculate tax for every row, round it, and sum it. PayPal calculates tax for each tax-rate (so horizontal), it takes all net values and applies the tax-rate. Due to rounding, we get different results.

2 Solutions: Either increase the decimal factors (use eg. 4 numbers after the coma) to improve rounding issues. or create a OrderProcessor that calculates it back and removes the cent rounding. We already did that, I can provide the code for this next week.

yes please, u rock 👍

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

No branches or pull requests

2 participants