Skip to content

Fixes Bug with number rounding#364

Closed
MarkusHolstein wants to merge 3 commits intoSylius:1.6from
perspeqtive:1.6
Closed

Fixes Bug with number rounding#364
MarkusHolstein wants to merge 3 commits intoSylius:1.6from
perspeqtive:1.6

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.

@GSadee
Copy link
Member

GSadee commented Jul 14, 2025

Hi @MarkusHolstein! Thank you very much for your contribution. I've just merged the fix for this problem in another PR with up-to-date tests for branch 1.7, so I'm closing this one.

@GSadee GSadee closed this Jul 14, 2025
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.

2 participants