wallee-payment / magento-2

Wallee integration for Magento 2.3 and later
https://wallee.com
Apache License 2.0
3 stars 3 forks source link

The line item total amount of 263.04 does not match the expected amount of 263.04. #16

Closed FloWord closed 1 year ago

FloWord commented 1 year ago

We updated from 1.3.14 to 1.3.15. Now we got this error message in checkout: main.CRITICAL: The line item total amount of 263.04 does not match the expected amount of 263.04. {"exception":"[object] (Exception(code: 0): The line item total amount of 263.04 does not match the expected amount of 263.04. at /var/www/domain/repo/htdocs/magento/src/vendor/wallee/magento-2/Helper/LineItem.php:101)"} []

We found this in vendor/wallee/magento-2/Helper/LineItem.php MicrosoftTeams-image (3)

The issue because: 188.17 - 188.17 = -0.00...0284 the value is NOT ZERO

Can you solve this rounding problem?

theodorspringwallee commented 1 year ago

Dear FloWord

This is a PHP rounding issue, that needs to be solved on merchants servers individually.

PHP precision is a PHP server config issue that the wallee plugin has no control over. That is why we have the line item consistency setting.

For a general solution, you can turn off the line-item-consistency option: https://plugin-documentation.wallee.com/wallee-payment/magento-2/1.3.15/docs/en/documentation.html#_line_items

Best regards

FloWord commented 1 year ago

Dear @theodorspringwallee thanks for your support.

i tried to upgrade again to 1.3.15 and disable this settings but now i got this error: [2023-01-23 16:18:50] main.CRITICAL: Error 442 connecting to the API (https://app-wallee.com/api/transaction/create?spaceId=33XX) : {"date":"2023-01-23T15:18:50.863Z","defaultMessage":"The number 0.000000000000056843418860808 needs to have at most 11 integer digits and at most 8 decimal digits.","id":"7Q54f1bypemlltR8LcA07ZzwkfZWvvy4CPNUr8D93b4 (2023-01-23T15:18:50.863Z)","message":"The number 0.000000000000056843418860808 needs to have at most 11 integer digits and at most 8 decimal digits.","type":"DEVELOPER_ERROR"} {"exception":"[object] (Wallee\\Sdk\\ApiException(code: 442): Error 442 connecting to the API (https://app-wallee.com/api/transaction/create?spaceId=33XX) : {\"date\":\"2023-01-23T15:18:50.863Z\",\"defaultMessage\":\"The number 0.000000000000056843418860808 needs to have at most 11 integer digits and at most 8 decimal digits.\",\"id\":\"7Q54f1bypemlltR8LcA07ZzwkfZWvvy4CPNUr8D93b4 (2023-01-23T15:18:50.863Z)\",\"message\":\"The number 0.000000000000056843418860808 needs to have at most 11 integer digits and at most 8 decimal digits.\",\"type\":\"DEVELOPER_ERROR\"} at /var/www/domain/repo/htdocs/magento/src/vendor/wallee/sdk/lib/ApiClient.php:495)"} [] Any idea whats wrong now? Thank you

theodorspringwallee commented 1 year ago

Dear FloWord

I think It's again about your PHP settings. Please ensure that you have not more than 8 digits after the amount separator.

From other customers I do not know such an issue, so I guess you have made some additional configurations within PHP or with your server settings in general, or you have a special environment, where your shop is running.

For further help, please contact info@wallee.com

Best regards

sprankhub commented 1 year ago

We have a very similar issue:

[2023-01-24T15:04:42.794508+00:00] report.CRITICAL: Wallee\Sdk\ApiException: Error 442 connecting to the API (https://app-wallee.com/api/transaction/create?spaceId=12345) : {"date":"2023-01-24T15:04:42.519Z","defaultMessage":"The discount including tax of 0.00000000000000022204460492503 needs to be rounded to '2' decimal places accordingly to the currency.","id":"yFzUg4RGs6copRjG10dPJObHiUKWw-qc_v2kD34YATA (2023-01-24T15:04:42.519Z)","message":"The discount including tax of 0.00000000000000022204460492503 needs to be rounded to '2' decimal places accordingly to the currency.","type":"DEVELOPER_ERROR"} in /var/www/html/vendor/wallee/sdk/lib/ApiClient.php:495
Stack trace:
#0 /var/www/html/vendor/wallee/sdk/lib/Service/TransactionService.php(384): Wallee\Sdk\ApiClient->callApi('/transaction/cr...', 'POST', Array, Object(Wallee\Sdk\Model\TransactionCreate), Array, '\\Wallee\\Sdk\\Mod...', '/transaction/cr...')
#1 /var/www/html/vendor/wallee/sdk/lib/Service/TransactionService.php(316): Wallee\Sdk\Service\TransactionService->createWithHttpInfo('12345', Object(Wallee\Sdk\Model\TransactionCreate))
#2 /var/www/html/vendor/wallee/magento-2/Model/Service/Quote/TransactionService.php(267): Wallee\Sdk\Service\TransactionService->create('12345', Object(Wallee\Sdk\Model\TransactionCreate))
[...]

@theodorspringwallee, this is not a PHP server setting. You guys broke it here:

https://github.com/wallee-payment/magento-2/compare/1.3.14...1.3.15#diff-d52e7365b52ebb360796c9734ab3a62d2bd9f6097e38c253892c3d22a36668b5R90

Previously, you used PHP's round with two decimal digits. Now in the new version, you use \Magento\Framework\Pricing\Helper\Data::currency, which does not apply any rounding. This is why certain cases now break as outlined by @FloWord.

This is a critical issue and needs to be fixed ASAP.

theodorspringwallee commented 1 year ago

Dear sprankhub

Thank you for the correction.

I forwarded this as high prio ticket to our developers.

FloWord, sprankhub In the meanwhile, please use our previous plugin version.

Best regards

theodorspringwallee commented 1 year ago

Dear sprankhub, FloWord

Currently, in our showcase, we can't reproduce this issue: https://magento-2.showcase-wallee.com/

Since your amounts in the API error message is nearly to zero I also tried with a Magento 2 coupon, but I still can proceed such an order: image

Please, can you tell us, how exactly we can reproduce this issue?

Best regards

sprankhub commented 1 year ago

It probably depends on the prices and maybe even on the tax settings. I could reproduce it with the following cart on our systems:

Can you reproduce it with these prices?

Even if you can't, the issue is still pretty clear when looking at the code.

theodorspringwallee commented 1 year ago

Dear sprankhub

Even with these prices, it's not reproducible: image

As you proposed, we will continue the fixing of this issue on the code level, about the Magento\Framework\Pricing\Helper\Data object, which does not apply the rounding.

Best regards

norgeindian commented 1 year ago

@theodorspringwallee , please try to set a tax class to the shipping costs, if you did not try that, yet. In my tests, everything still works more or less, as long as I use a shipping method which is for free. As soon as I switch to another shipping method, the error comes up.

theodorspringwallee commented 1 year ago

Dear norgeindian

Thank you for the input. Unfortunately, this reproduction step, didn't work within our showcase.

But one of our developers could (sporadically) reproduce this issue and tries to fix this issue now.

Best regards

FloWord commented 1 year ago

Hello @theodorspringwallee i updated now from 1.3.14to 1.3.16. It works! Thanks for this quick fix.