Skip to content

Commit

Permalink
Update classes/PaymentModule.php
Browse files Browse the repository at this point in the history
Change strcmp for strict inequality operator for amount string comparison

Co-authored-by: Jonathan Lelievre <jo.lelievre@gmail.com>
  • Loading branch information
mpaolino and jolelievre committed Dec 9, 2021
1 parent d1bfdf2 commit d7755bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion classes/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function validateOrder(
// if ($order->total_paid != $order->total_paid_real)
// We use number_format to convert the numbers to strings and strcmp to compare them to avoid auto reconversions to numbers in PHP < 8.0
$comp_precision = Context::getContext()->getComputingPrecision();
if ($order_status->logable && (strcmp(number_format($cart_total_paid, $comp_precision), number_format($amount_paid, $comp_precision)) != 0)) {
if ($order_status->logable && (number_format($cart_total_paid, $comp_precision) !== number_format($amount_paid, $comp_precision))) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Total paid amount does not match cart total', 3, null, 'Cart', (int) $id_cart, true);
$id_order_state = Configuration::get('PS_OS_ERROR');
}
Expand Down

0 comments on commit d7755bd

Please sign in to comment.