Jump to content
inra311

Updating currencies with fixer not working anymore?

Recommended Posts

I cannot update the currencies in admin anymore (2.3.4.1 CE), with fixer

When I go to http://api.fixer.io/

I get the impression something has changed there, you need an api key!?

 

Anyone else who has this problem or even a solution? (I have not tried to get an api key yet, as I probably would not know how to integrate it in osc)

As an alternative, I meanwhile edited admin/includes/application_top.php and admin/includes/functions/localization.php top as suggested here:

This way currencies update with xe at least --> define('CURRENCY_SERVER_BACKUP', 'xe');

Share this post


Link to post
Share on other sites

From the fixer.io GitHub account https://github.com/fixerAPI/fixer

Quote

Required Changes to Legacy Integrations (api.fixer.io)

As of March 6th 2018, the legacy Fixer API (api.fixer.io) is deprecated and a completely re-engineered API is now accessible at https://data.fixer.io/api/ The core structure of the old API has remained unchanged, and you will only need to perform a few simple changes to your integration.

1. Get a Free Fixer Access Token

Go to fixer.io and create an account. After signup, you will receive an access token immediately. If you plan on using less than 1000 requests per month, your account will be completely free. If you need more or want to use some of our new features, you’ll need to choose one of the paid options.

2. Replace API URL and add Access Key

The new API comes with a new endpoint and now requires an access key in the GET URL. Please change your API URL from api.fixer.io to https://data.fixer.io/api and attach your newly generated access key to the URL as a GET parameter named „access_key“.

Example

If your old API Call was https://api.fixer.io/latest then your new integration should point to: https://data.fixer.io/api/latest?access_key=YOUR_ACCESS_KEY

 

Share this post


Link to post
Share on other sites

I could fix it, here the code:

admin/includes/functions/localization.php:

within the quote_fixer_currency function:

  function quote_fixer_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;

    $ch = curl_init('http://data.fixer.io/api/latest?access_key=YOUR_ACCESS_KEY&base=' . $from . '&symbols=' . $to);

 

Share this post


Link to post
Share on other sites

I think I prefer the fix from the link above which makes the currency updates via xe. It seems to work very reliable so far.

Although the fixer api key is free, you need to register there and even enter your credit card data while this is not required with xe.

The two changes are:

replace in  admin/includes/functions/localization.php:

$page = file('https://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to); 

  to

$page = file('http://www.xe.com/currencyconverter/convert/?Amount=1&From=' . $from . '&To=' . $to);

 

and in admin/includes/application_top.php :

   define('CURRENCY_SERVER_PRIMARY', 'fixer');

to

   define('CURRENCY_SERVER_PRIMARY', 'xe');                          

 

Share this post


Link to post
Share on other sites
On 6/7/2018 at 2:28 PM, wHiTeHaT said:

Is there an alternative?
Currently working on the bootstrapped admin.
So a legit fix can be implemented before release.

I've been using

"https://free.currencyconverterapi.com/api/v5/convert?q={$from}_{$to}&compact=ultra"); 

Not sure it would be the right thing for your build... but it does work... however.....

Share this post


Link to post
Share on other sites
On 6/7/2018 at 7:18 PM, inra311 said:

I think I prefer the fix from the link above which makes the currency updates via xe. It seems to work very reliable so far.

Although the fixer api key is free, you need to register there and even enter your credit card data while this is not required with xe.

The two changes are:

replace in  admin/includes/functions/localization.php:

$page = file('https://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to); 

  to

$page = file('http://www.xe.com/currencyconverter/convert/?Amount=1&From=' . $from . '&To=' . $to);

 

and in admin/includes/application_top.php :

   define('CURRENCY_SERVER_PRIMARY', 'fixer');

to

   define('CURRENCY_SERVER_PRIMARY', 'xe');                          

 

Works for me, 2.3.4BS

Previously used fixer

 

Thank you


David

Share this post


Link to post
Share on other sites

Hello 

I was using XE for a while but now that has stopped working

 

I signed up for a free account on Fixer, but the base currency is fixed to EUR, as use GBP i cannot use it usless i upgrade to the basic account which is only £10 per month but many a mickle makes a muckle

 

so i am now using 

 

$ch = curl_init('https://api.exchangeratesapi.io/latest?&base=' . $from . '&symbols=' . $to);

 

from https://exchangeratesapi.io/

seems to work at the moment, to make it easier i have included the whole section below that would go in

 

Admin/includes/functions/ localization.php

(dont forget you have to select define('CURRENCY_SERVER_PRIMARY', 'fixer'); in admin/application_top.php)

 

Not a coder just a store owner so make your own enquires as to whether this is suitable for you

 

  function quote_fixer_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;
   

     $ch = curl_init('https://api.exchangeratesapi.io/latest?&base=' . $from . '&symbols=' . $to);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch); 
    curl_close($ch); 

    $currencies = json_decode($data, true);
    
    if (isset($currencies['rates'][$to])) {
      return $currencies['rates'][$to];
    } else {
      return false;
    }
  }


David

Share this post


Link to post
Share on other sites
On 8/27/2018 at 8:30 AM, DAVID3733 said:

I signed up for a free account on Fixer, but the base currency is fixed to EUR, as use GBP i cannot use it usless i upgrade to the basic account which is only £10 per month but many a mickle makes a muckle

so i am now using 

$ch = curl_init('https://api.exchangeratesapi.io/latest?&base=' . $from . '&symbols=' . $to);

from https://exchangeratesapi.io/

Thanks DAVID3733, I had the same issue as my base currency is Thai Baht, so this fix ^^^ worked for me. I actually just created an additional quote function which I called quote_exapi_currency, and then changed the primary currency converter service in application top and the auto-update currencies to use the exapi function.

  function quote_exapi_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;

    $ch = curl_init('https://api.exchangeratesapi.io/latest?&base=' . $from . '&symbols=' . $to);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);

    $currencies = json_decode($data, true);

    if (isset($currencies['rates'][$to])) {
      return $currencies['rates'][$to];
    } else {
      return false;
    }
  }

My currencies are updating again. Wo0t!
 

Share this post


Link to post
Share on other sites

@DAVID3733

Thanks for that link, now I finally have a working exchange rate server again after 2 months we didn't notice all fail (oanda, xe and fixer).

We do still need a backup server, just in case this one fails and we won't notice again. Does anyone have any suggestions/alternatives, preferably that don't require registration.

Thanks 

Edited by dr_lucas

Share this post


Link to post
Share on other sites
On 6/6/2018 at 12:31 PM, raiwa said:

I could fix it, here the code:

admin/includes/functions/localization.php:

within the quote_fixer_currency function:


  function quote_fixer_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;

    $ch = curl_init('http://data.fixer.io/api/latest?access_key=YOUR_ACCESS_KEY&base=' . $from . '&symbols=' . $to);

I signed up for  new fixer.io account and copied my API code in "localization.php as such:

function quote_fixer_currency($to, $from = DEFAULT_CURRENCY) {
    if ($to == $from) return 1;

    $ch = curl_init('http://data.fixer.io/api/latest?access_key=740a5dw0cb3987ea949g91f3d054624&base=' . $from . '&symbols=' . $to);

 

Both currencies that i have installed (EUR, USD) stay at 1.00000, even when i click "Update exchange rate" manually in admin/currencies.

I keep getting this error:

Error Error: The exchange rate for U.S. Dollar (USD) was not updated via fixer. Is it a valid currency code?

Success The exchange rate for Euro (EUR) was updated successfully via fixer

 

The green one is always the default one.

Is there another file that needs to be edited maybe?

Share this post


Link to post
Share on other sites

Fixer works only with EUR base currency.

Pleasae see this post:

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×