mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
101 stars 53 forks source link

Invalid amount value for field unitPrice #542

Closed Detzler closed 2 years ago

Detzler commented 2 years ago

Used versions

To Reproduce Steps to reproduce the behavior: Simple checkout with any mollie payment method (select payment method and complete order)

Actual behavior After clicking the order button in checkout, a redirect occurs to the cart page. An error is shown:

image

Error executing API call (422: Unprocessable Entity): Order line 3 is invalid. Invalid amount value for field unitPrice.. Field: lines.3.unitPrice.value.

I digged in the mollie.log and saw negative price / amount values in the request entry: image

Disabling the adjustment order line helped temporarily: image

Detzler commented 2 years ago

I digged deeper in vendor/mollie/magento2/Service/Order/Lines/Order.php::getAdjustment

image

.. and made a var_dump on $difference The result is: -1.7763568394003E-15

Read here about this kind of value: https://stackoverflow.com/questions/35319109/php-difference-between-2-float-returns-a-very-big-result https://www.php.net/manual/en/language.types.float.php#language.types.float.comparison

1.7763568394003E-15 isn't a big number, it's actually very very small. It's being shown in scientific notation; it's 0.0000000000000017763568394003 in normal form. This is the error due to floating point representations.

(not a php bug) https://bugs.php.net/bug.php?id=79185&edit=2

Frank-Magmodules commented 2 years ago

HI @Detzler , 

Thank you for opening this issue! Based on the current information we can't see directly why this is happening. Therefore, can you please share more details of this environment with us through our secured contact form? Thanks a lot!

Frank-Magmodules commented 2 years ago

HI @Detzler ,

Due to the lack of information and we can't reproduce this issue, we will close this issue for now. Please feel free to reopen the issue or contact us directly through our contact form so we can investigate this issue further with you.

jaybong commented 1 year ago

We are experiencing the same or a similar problem (unitPrice is -0.00 which causes an error. I've sent more details through your contact form.