Google currency converter no longer working

currency-exchange-rates

It appears that Google Finance Currency Converter has stopped working altogether. A week ago I started getting these email notifications from my Magento 1.9.2 store:

Currency update warnings:
WARNING: Cannot retrieve rate from https://finance.google.com/finance/converter?a=1&from=GBP&to=EUR.
WARNING: Cannot retrieve rate from https://finance.google.com/finance/converter?a=1&from=GBP&to=USD.

Those URLs are indeed no longer valid. Does anyone know if there are new URLs we can use, or do we need to configure a different service?

Best Answer

This link is not working anymore.

 protected $_url = 'https://finance.google.com/finance/converter?a=1&from={{CURRENCY_FROM}}&to={{CURRENCY_TO}}';

I researched and found this codes.

Find this file:

app/code/local/Payserv/GoogleFinance/Model/Google.php

Replace the codes with this:

class Payserv_GoogleFinance_Model_Google extends Mage_Directory_Model_Currency_Import_Abstract {

protected $_url = 'http://free.currencyconverterapi.com/api/v3/convert?q={{CURRENCY_FROM}}_{{CURRENCY_TO}}';

protected $_messages = array();

protected function _convert($currencyFrom, $currencyTo, $retry=0) {
    $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, $this->_url);
    $url = str_replace('{{CURRENCY_TO}}', $currencyTo, $url);
    try {
         $resultKey = $currencyFrom.'_'.$currencyTo;
         $response = file_get_contents($url);
         $data = Mage::helper('core')->jsonDecode($response);
         $results = $data['results'][$resultKey];
         $queryCount = $data['query']['count'];
         if( !$queryCount &&  !isset($results)) {
            $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
            return null;
        }
       return (float)$results['val'];
    } catch (Exception $e) {
        if ($retry == 0) {
            $this->_convert($currencyFrom, $currencyTo, 1);
        } else {
            $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s', $url);
        }
    }
}
}
Related Topic