I am using the below code to get Sub Total and Grand Total but it is returning total in Display Currency.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$subTotal = $cart->getQuote()->getSubtotal();
$grandTotal = $cart->getQuote()->getGrandTotal();
How to get the grand Total in Base Currency in case Default Currency is different than Display Currency.
I am able to get the Base Currency Total by below code, but it is not exactly the same as displayed on "You will be charged for" on the payment page.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$grandTotal = $cart->getQuote()->getGrandTotal();
$priceCurrencyFactory = $objectManager->get('Magento\Directory\Model\CurrencyFactory');
$storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$currencyCodeTo = $storeManager->getStore()->getCurrentCurrency()->getCode();
$currencyCodeFrom = $storeManager->getStore()->getBaseCurrency()->getCode();
$rate = $priceCurrencyFactory->create()->load($currencyCodeTo)->getAnyRate($currencyCodeFrom);
$baseTotal = $grandTotal * $rate;
Difference of value is shown in image.