/** * Get exchange rates * * @param boolean $mergePrimaryCurrency * @return array */ public function getExchangeRates($mergePrimaryCurrency = true) { $rates = []; if (PaymentService::getExchangeRates()) { $rates = $mergePrimaryCurrency ? array_merge(PaymentService::getExchangeRates(), array(PaymentService::getPrimaryCurrency()['code'] => PaymentService::getPrimaryCurrency())) : PaymentService::getExchangeRates(); krsort($rates); } return $rates; }
/** * Process cost * * @param float|integer $cost * @param boolean $rounding * @return string */ public function __invoke($cost, $rounding = false) { $exchangeRates = PaymentService::getExchangeRates(); $activeShoppingCurrency = PaymentService::getShoppingCartCurrency(); // convert cost if (isset($exchangeRates[$activeShoppingCurrency])) { $cost = $cost * $exchangeRates[$activeShoppingCurrency]['rate']; } if ($rounding) { $cost = PaymentService::roundingCost($cost); } return $this->getView()->currencyFormat($cost, $activeShoppingCurrency); }