Returns transformed amount by the given currency code which can be handled by the gateway API.

@param float $amount Value from the store.
@param string $currencyCode
@return int
@throws InvalidArgumentException
13106
public static function getGatewayAmountOfCurrency($amount, $currencyCode) {
        $currencyCode = strtoupper($currencyCode);

        if ( ! is_numeric($amount) ) {
            throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.');
        }

        $amount = (float) $amount;

        if ($amount < 0) {
            throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.');
        }

        if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) {
            return (int) $amount;
        }

        if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) {
            return (int) ($amount * self::DIV_1000);
        }

        return (int) ($amount * self::DIV_100);
    }
1201016
public function fromFloat($amount, $currency = null)
    {
        if ($currency) {
            $this->setCurrency($currency);
        }

        if (!is_float($amount)) {
            throw new InvalidArgumentException(sprintf(
                'Amount must be a float, %s given',
                gettype($amount)
            ));
        }
        
        $this->amount = $this->toInt(
            round(
                $this->getSubUnit() * round($amount, $this->getFractionDigits(), PHP_ROUND_HALF_UP),
                0,
                PHP_ROUND_HALF_UP
            )
        );
        return $this;
    }
909083
public function convert(Money $money, $roundingMode = Money::ROUND_HALF_UP)
    {
        if (!$money->getCurrency()->equals($this->baseCurrency)) {
            throw new InvalidArgumentException(
                sprintf('Currencies must match: Money to convert has currency %s, while CurrencyPair has base currency %s.',
                    $money->getCurrency()->getIsoCode(),
                    $this->baseCurrency->getIsoCode()
                )
            );
        }

        return new Money(
            Math::bcround(
                bcmul($money->getAmountString(), $this->ratio, Money::GAAP_PRECISION + 1),
                Money::GAAP_PRECISION,
                $roundingMode
            ),
            $this->counterCurrency
        );
    }
745340
protected function getCurrencyIso4217NumericCode($textCurrencyCode)
    {
        $currencies = null;

        $localIso417data = __DIR__ . DS . "Config" . DS . "iso4217.xml";

        $currencyXmlDataUrl = "http://www.currency-iso.org/dam/downloads/lists/list_one.xml";

        $xmlData = @file_get_contents($currencyXmlDataUrl);

        try {
            $currencies = new \SimpleXMLElement($xmlData);

            // Update the local currencies copy.
            @file_put_contents($localIso417data, $xmlData);
        } catch (\Exception $ex) {
            Tlog::getInstance()->warning("Failed to get currency XML data from $currencyXmlDataUrl: ".$ex->getMessage());
            try {
                $currencies = new \SimpleXMLElement(@file_get_contents($localIso417data));
            } catch (\Exception $ex) {
                Tlog::getInstance()->warning("Failed to get currency XML data from local copy $localIso417data: ".$ex->getMessage());
            }
        }

        if (null !== $currencies) {
            foreach ($currencies->CcyTbl->CcyNtry as $country) {
                if ($country->Ccy == $textCurrencyCode) {
                    return (string) $country->CcyNbr;
                }
            }
        }

        // Last chance
        switch ($textCurrencyCode) {
            case 'USD':
                return 840;
            case 'GBP':
                return 826;
                break;
            case 'EUR':
                return 978;
                break;
        }

        throw new \RuntimeException(
            Translator::getInstance()->trans(
                "Failed to get ISO 4217 data for currency %curr, payment is not possible.",
                ['%curr' => $textCurrencyCode]
            )
        );
    }
661474
public function create($amount, $currency)
    {
        $result = new Money($amount, $currency);
        $this->validator->validateMoney($result);
        return $result;
    }
626639
public static function getSubUnit($currencyCode)
    {
        $subunits = static::getCurrencyData($currencyCode)['sub_unit'];
        if (!is_int($subunits)) {
            throw new UnexpectedValueException(sprintf(
                'The currency sub-units value must be an integer; "%s" given',
                is_object($subunits) ? get_class($subunits) : gettype($subunits)
            ));
        }
        if ($subunits < 1) {
            throw new UnexpectedValueException(sprintf(
                'The currency sub-units value must be greater than 1; "%s" given',
                $subunits
            ));
        }
        return $subunits;
    }
462599
public function findPriceByCurrency($currency): ?PriceInterface
    {
        if ($currency instanceof \Money\Currency) {
            $currency = $currency->getCode();
        } elseif ($currency instanceof CurrencyInterface) {
            $currency = $currency->getIsoCodeAlpha();
        }

        if (!is_string($currency)) {
            throw new \InvalidArgumentException('$currency has to be a string');
        }

        foreach ($this->prices as $price) {
            if ($price->getCurrency()->getIsoCodeAlpha() === $currency) {
                return $price;
            }
        }

        return null;
    }
934800
private function getCurrencyCode($currency)
    {
        $list = self::getCurrencyList();

        if (isset($list[$currency])) {
            return $list[$currency]['code'];
        }

        throw new \RuntimeException('Invalid exception provided');
    }
265308
protected function getDefaultNumberFormatter($currencyCode, $locale = null)
    {
        if (is_null($locale)) {
            $locale = \Locale::getDefault();
        }
        $numberFormatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
        $numberFormatter->setTextAttribute(\NumberFormatter::CURRENCY_CODE, $currencyCode);
        $numberFormatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->decimals);

        return $numberFormatter;
    }
1204964
public function decimal($amount, $currency_code)
    {
        static $divisors = array();

        if (empty($divisors[$currency_code])) {
            $currency = $this->currency->get($currency_code);
            $divisors[$currency_code] = pow(10, $currency['decimals']);
        }

        return $amount / $divisors[$currency_code];
    }
1187166
public function toMachine(string $amount, string $swift_code = ''): int
    {
        $swift_code = empty($swift_code) ? config('currency.default_swift_code') : $swift_code;

        return (new DecimalMoneyParser(
                new ISOCurrencies()
            ))->parse(
                preg_replace('/[^0-9.-]/im', '', $amount),
                (new Currency($swift_code))
            )->getAmount();
    }
41279
protected function checkCurrencies($currencies)
    {
        foreach ((array) $currencies as $currency) {
            if (!$this->hasCurrency($currency)) {
                throw new InvalidCurrencyException(sprintf('"%s" is an unknown currency code.', $currency));
            }
        }
    }
366441
public static function withSecure($amount, Currency $currency = null)
    {
        if(!is_long($amount))
            throw new InvalidAmountException;
        $money = self::withRaw(0, $currency);
        $money->setFraction($amount / 100);
        $money->setWhole($amount / 100);
        return $money;
    }
379896
private function _checkCurrency(&$currency)
    {
        if (!isset($currency)) {
            throw new Klarna_ArgumentNotSetException("Currency");
        }
        if (is_numeric($currency) && !is_int($currency)) {
            $currency = intval($currency);
        }
        if (!is_numeric($currency) || !is_int($currency)) {
            throw new Klarna_InvalidTypeException("Currency", "integer");
        }
    }
855543
public function amount($money)
    {
        if (null === $money) {
            return null;
        }

        $cents = $money * 100;
        if (!is_numeric($money) || $money < 0) {
            throw new \InvalidArgumentException('money amount must be a positive number.');
        }

        return ($this->money_format() == 'cents')
            ? number_format($cents, 0, '', '')
            : number_format($money, 2);
    }
75627
public function getCurrency($code = null)
    {
        $code = $code ?: $this->getUserCurrency();

        return Arr::get($this->getCurrencies(), strtoupper($code));
    }
1228642
public function transformToCurrency($amount, $locale, $currency)
    {
        $localeClassName = $this->resolveLocaleClassName($locale);
        $transformer = new $localeClassName($this->options);

        $decimalPart = (int) ($amount / 100);
        $fractionalPart = $amount % 100;

        if (0 === $fractionalPart) {
            return trim($transformer->toCurrencyWords($currency, $decimalPart));
        }

        return trim($transformer->toCurrencyWords($currency, $decimalPart, $fractionalPart));
    }