Skip to content

Fixes Bug with number rounding #364

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

Open
wants to merge 3 commits into
base: 1.6
Choose a base branch
from
Open

Conversation

MarkusHolstein
Copy link

Q A
Branch? 1.6 (and above)
Bug fix? yes
New feature? no

Und certain circumstances the rounding in PHP runs wild. This leads to a problem, when trying to validate the amount sent to paypal vs. the amount of the cart.

Example:

$totalAmount = 0;
$unit['amount']['value'] = '2258.45';

$stringAmount = $unit['amount']['value'] ?? '0';
$totalAmount += (int) ($stringAmount * 100);

var_dump($totalAmount);
var_dump($stringAmount * 100);

Results in

int(225844)
float(225844.99999999997)

Thus, the value needs to be rounded, before casting to int.

So some people are currently unable to use the paypal function of our website.

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

Successfully merging this pull request may close these issues.

1 participant