diff --git a/paypal.php b/paypal.php index 502868ee..7daab54f 100755 --- a/paypal.php +++ b/paypal.php @@ -2322,12 +2322,21 @@ public function getPartnerInfo() return $response; } - public static function getPrecision() + public static function getPrecision($currency = null) { if (version_compare(_PS_VERSION_, '1.7.7', '<')) { return _PS_PRICE_DISPLAY_PRECISION_; } else { - return Context::getContext()->getComputingPrecision(); + if ($currency instanceof Currency && Validate::isLoadedObject($currency)) { + $context = Context::getContext()->cloneContext(); + $context->currency = $currency; + $precision = $context->getComputingPrecision(); + unset($context); + + return $precision; + } else { + return Context::getContext()->getComputingPrecision(); + } } } @@ -2345,7 +2354,7 @@ public static function getDecimal($isoCurrency = null) $isoCurrency = $paypal->getPaymentCurrencyIso(); } - $precision = self::getPrecision(); + $precision = self::getPrecision(new Currency(Currency::getIdByIsoCode($isoCurrency))); if (in_array($isoCurrency, $currency_wt_decimal) || ($precision == 0)) { return (int) 0; diff --git a/services/Order/RefundAmountCalculator.php b/services/Order/RefundAmountCalculator.php index 1862af29..bfc15613 100644 --- a/services/Order/RefundAmountCalculator.php +++ b/services/Order/RefundAmountCalculator.php @@ -32,7 +32,6 @@ } use Order; -use PayPal; class RefundAmountCalculator { @@ -50,7 +49,7 @@ public function calculate($params) } foreach ($params['productList'] as $product) { - $amount += \Tools::ps_round($product['amount'], PayPal::getPrecision()); + $amount += (float) $product['amount']; } if (false == empty($params['partialRefundShippingCost'])) {