I'm experiencing an issue when trying to buy a product that has cents. For example, 17.99.
In the JS console I get the error Invalid value for paymentRequest(): displayItems.0.amount should be an amount in the currency's subunit. You specified: 1798.9999999999998.
I managed to track down where the issue is happening but have no idea what is causing it. In the file vendor\ether\web-payments\src\web\Variable.php on line 103 the $options variable is converted in to json with the method json_encode. This is where the line item sale price changes from 1799 to 1798.9999999999998.
Steps to Reproduce
Install and setup web-payment plugin.
add product with price of 17.99.
Add product to cart and go to checkout.
View JS console for errors.
Expected Results
Apple Pay and Google Pay work on mobile with prices of 17.99.
Issue Description
I'm experiencing an issue when trying to buy a product that has cents. For example, 17.99.
In the JS console I get the error
Invalid value for paymentRequest(): displayItems.0.amount should be an amount in the currency's subunit. You specified: 1798.9999999999998.
I managed to track down where the issue is happening but have no idea what is causing it. In the file
vendor\ether\web-payments\src\web\Variable.php
on line 103 the$options
variable is converted in to json with the methodjson_encode
. This is where the line item sale price changes from1799
to1798.9999999999998
.Steps to Reproduce
Expected Results
Apple Pay and Google Pay work on mobile with prices of 17.99.
Additional Information
Current Work arround
Use prices that do not have decimal places.