Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

currency update fails #523

Closed
gthb1 opened this issue Aug 4, 2018 · 3 comments
Closed

currency update fails #523

gthb1 opened this issue Aug 4, 2018 · 3 comments

Comments

@gthb1
Copy link

gthb1 commented Aug 4, 2018

Hi.
When executing
/index.php?_url=/api/admin/currency/update_rates
they all go to zero exchange rate and when looking into the code at
/bb-modules/Currency/Service.php
it seems to be this bit
http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D".$from_Currency.$to_Currency."%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json
which if tested in a browser throws this error
"Invalid URL http://download.finance.yahoo.com/d/quotes?s=".$from_Currency.$to_Currency."%3DX&f=l1n: Illegal character in query at index 45: http://download.finance.yahoo.com/d/quotes?s=".$from_Currency.$to_Currency."%3DX&f=l1n"
BoxBilling doc says
http://docs.boxbilling.com/en/latest/reference/currency.html?highlight=currency%20update
"Currency rates are taken form google.com" (but it is stamped with 2012, so either 2012 is wrong, or the info on the doc page).
Either way, what is the fix?

@himadrikgp
Copy link

I'm wondering if you're still facing the issue. I faced the same issue today. So, I have changed few lines under the _getRate function in the /bb-modules/Currency/Service.php page. I have used the API
from https://free.currencyconverterapi.com.

Replace the whole _getRate function with this

protected function _getRate($from, $to)
    {
        $from_Currency = urlencode($from);
        $to_Currency   = urlencode($to);
        $url = "http://free.currencyconverterapi.com/api/v5/convert?q=".$from_Currency."_".$to_Currency."&compact=y";
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch,  CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
        $json = curl_exec($ch);
        $array = json_decode($json, true);
        return (float)$array[$from_Currency."_".$to_Currency]['val'];
    }

@gthb1
Copy link
Author

gthb1 commented Oct 1, 2018

Your code works perfectly!
Awesome, thank you sooooo much :)

@stale
Copy link

stale bot commented Jun 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. The resources of the BoxBilling team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the stale label Jun 18, 2020
@stale stale bot closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants