Model/Adapter/ChargeAmountAdapter.php
public static function getPaymentFinalCurrencyValue($orderAmount) {

        // Get the object manager
        $manager = \Magento\Framework\App\ObjectManager::getInstance();
         
        // Load the gateway config and get the gateway payment currency
        $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency();

        // Get the storoe id
        $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId();

        // Get the user currency display
        $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote();
        $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder();
        if ($quote) {
            $userCurrencyCode = $quote->getQuoteCurrencyCode();
        }
        else if ($order) {
            $userCurrencyCode = $quote->getOrderCurrencyCode();
        }
        else {
            $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode();
        }

        // Load the store currency
        $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); 
 
        // Test the store and gateway config conditions
        if ($gatewayPaymentCurrency == self::BASE_CURRENCY) {

            if ($userCurrencyCode == $storeBaseCurrencyCode) {

                // Convert the user currency amount to base currency amount
                $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode);      
            }
            else {
                $finalAmount = $orderAmount;        
            }

        }
        elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) {

            if ($userCurrencyCode != $storeBaseCurrencyCode) {

                $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode);            
            } else {
                // Convert the base amount to user currency amount
                $finalAmount = $orderAmount;        
            }
        }
        else {

            if ($userCurrencyCode != $gatewayPaymentCurrency) {
                // We have a specific currency to use for the payment
                $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency);
            } else {
               
               $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency);
            }
        }

        return $finalAmount;
    }
public static function getPaymentFinalCurrencyValue($orderAmount) {

        // Get the object manager
        $manager = \Magento\Framework\App\ObjectManager::getInstance();
         
        // Load the gateway config and get the gateway payment currency
        $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency();

        // Get the storoe id
        $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId();

        // Get the user currency display
        $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote();
        $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder();
        if ($quote) {
            $userCurrencyCode = $quote->getQuoteCurrencyCode();
        }
        else if ($order) {
            $userCurrencyCode = $quote->getOrderCurrencyCode();
        }
        else {
            $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode();
        }

        // Load the store currency
        $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); 
 
        // Test the store and gateway config conditions
        if ($gatewayPaymentCurrency == self::BASE_CURRENCY) {

            if ($userCurrencyCode == $storeBaseCurrencyCode) {

                // Convert the user currency amount to base currency amount
                $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode);      
            }
            else {
                $finalAmount = $orderAmount;        
            }

        }
        elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) {

            if ($userCurrencyCode != $storeBaseCurrencyCode) {

                $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode);            
            } else {
                // Convert the base amount to user currency amount
                $finalAmount = $orderAmount;        
            }
        }
        else {

            if ($userCurrencyCode != $gatewayPaymentCurrency) {
                // We have a specific currency to use for the payment
                $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency);
            } else {
               
               $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency);
            }
        }

        return $finalAmount;
    }
public static function getPaymentFinalCurrencyValue ( $ orderAmount ) { // Get the object manager $ manager = \ Magento \ Framework \ App \ ObjectManager :: getInstance ( ) ; // Load the gateway config and get the gateway payment currency $ gatewayPaymentCurrency = $ manager -> create ( 'CheckoutCom\Magento2\Gateway\Config\Config' ) -> getPaymentCurrency ( ) ; // Get the storoe id $ storeId = $ manager -> create ( 'Magento\Checkout\Model\Session' ) -> getQuote ( ) -> getStoreId ( ) ; // Get the user currency display $ quote = $ manager -> create ( 'Magento\Checkout\Model\Session' ) -> getQuote ( ) ; $ order = $ manager -> create ( 'Magento\Checkout\Model\Session' ) -> getLastRealOrder ( ) ; if ( $ quote ) { $ userCurrencyCode = $ quote -> getQuoteCurrencyCode ( ) ; } else if ( $ order ) { $ userCurrencyCode = $ quote -> getOrderCurrencyCode ( ) ; } else { $ userCurrencyCode = $ manager -> create ( 'Magento\Store\Model\StoreManagerInterface' ) -> getStore ( $ storeId ) -> getCurrentCurrencyCode ( ) ; } // Load the store currency $ storeBaseCurrencyCode = $ manager -> create ( 'Magento\Store\Model\StoreManagerInterface' ) -> getStore ( $ storeId ) -> getBaseCurrency ( ) -> getCode ( ) ; // Test the store and gateway config conditions if ( $ gatewayPaymentCurrency == self :: BASE_CURRENCY ) { if ( $ userCurrencyCode == $ storeBaseCurrencyCode ) { // Convert the user currency amount to base currency amount $ finalAmount = $ orderAmount / $ manager -> create ( 'Magento\Directory\Model\CurrencyFactory' ) -> create ( ) -> load ( $ storeBaseCurrencyCode ) -> getAnyRate ( $ userCurrencyCode ) ; } else { $ finalAmount = $ orderAmount ; } } elseif ( $ gatewayPaymentCurrency == self :: ORDER_CURRENCY ) { if ( $ userCurrencyCode != $ storeBaseCurrencyCode ) { $ finalAmount = $ orderAmount * $ manager -> create ( 'Magento\Directory\Model\CurrencyFactory' ) -> create ( ) -> load ( $ storeBaseCurrencyCode ) -> getAnyRate ( $ userCurrencyCode ) ; } else { // Convert the base amount to user currency amount $ finalAmount = $ orderAmount ; } } else { if ( $ userCurrencyCode != $ gatewayPaymentCurrency ) { // We have a specific currency to use for the payment $ finalAmount = $ orderAmount * $ manager -> create ( 'Magento\Directory\Model\CurrencyFactory' ) -> create ( ) -> load ( $ userCurrencyCode ) -> getAnyRate ( $ gatewayPaymentCurrency ) ; } else { $ finalAmount = $ orderAmount * $ manager -> create ( 'Magento\Directory\Model\CurrencyFactory' ) -> create ( ) -> load ( $ storeBaseCurrencyCode ) -> getAnyRate ( $ gatewayPaymentCurrency ) ; } } return $ finalAmount ; }
Returns a converted currency value.
@param float $orderAmount
@return float
Returns a converted currency value .