Skip to content

Commit

Permalink
Removed empty float decimal on getAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
eusonlito committed Sep 7, 2018
1 parent 67b6713 commit 6307d0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Redsys/Tpv/Tpv.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ public function getAmount($amount)
$amount = substr($amount, 0, $point + 1 + 2);
}

// Set as Redsys valid amount value: 12,34 = 1234
return ($amount * 100);
// Set as Redsys valid amount value: 12.34 = 1234
// Avoid to use intval, round or sprintf without remove decimals before
// because this functions applies a round.
return sprintf('%03d', preg_replace('/\.[0-9]+$/', '', $amount * 100));
}

public function getValuesSignature()
Expand Down

0 comments on commit 6307d0d

Please sign in to comment.