public static function getPaymentFinalCurrencyCode($orderCurrencyCode) {
                
        // 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) {

            // Use the store base currency code
            $finalCurrencyCode = $storeBaseCurrencyCode;
        }
        elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) {

            // Use the order currency code
            $finalCurrencyCode = $userCurrencyCode;
        }
        else {

            // We have a specific currency code to use for the payment
            $finalCurrencyCode = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getCustomCurrency();
        }

        return $finalCurrencyCode;
    }