Jump to content

Free Hook - Add a non-supported currency to auto update


Recommended Posts

If you want to use a currency not supported by WHMCS (I think there are only 8 or so) then you can use this hook, which draws its data from https://www.currencyconverterapi.com/.

They have a free account which is sufficient for a once a day cron update, although of course you can upgrade if need be.

Firstly you need to sign up with ccapi to get your free API key, then edit the variables at the top of the hook file to suit your needs.

Finally, place the file in the /includes/hooks directory and you're done 🙂

 

hook_cron_update_custom_currency.php

Link to comment
Share on other sites

  • 2 weeks later...

I need help, I'm using USD as default currency and want to convert to PKR, I input all the required parameters correct still it says failed in the Activity Log. I have tried running the API through browser and it works fine and gives result but WHMCS is not working with it, help please.

Link to comment
Share on other sites

3 hours ago, bendrop said:

Have you run it from a browser / wget on the server? The free api key only lets you connect from a single ip address.

At first when I registered the API, I copied the key from the email I received and pasted it directly in the config and waited till the next day for the CRON job to trigger and update it, it said failed, then I tried it in my browser from my personal laptop and it returned the results fine. What I'm trying to say is that I did not use the API ANYWHERE else before putting it in the config and letting the CRON run.

For information, we use CloudFlare to proxy our company domains and WHMCS installation, and cURL is fully setup and running without any issues.

Link to comment
Share on other sites

  • 2 weeks later...
On 8/11/2020 at 2:47 AM, bendrop said:

That "failed" message will trigger if the script couldn't connect to the api server, that's all it does.

This is why you need to try and run the api call directly from the server to see if it's giving some kind of denied error.

Can you tell me the format of the command to run at server side? As I run wget or curl I get this:

Quote

https://free.currconv.com/api/v7/convert?q=USD_PKR
Resolving free.currconv.com (free.currconv.com)... 104.18.48.56, 104.18.49.56, 172.67.140.185, ...
Connecting to free.currconv.com (free.currconv.com)|104.18.48.56|:443... connected.
HTTP request sent, awaiting response... 400 Bad request
2020-08-19 02:58:09 ERROR 400: Bad request.


[1]-  Exit 8                  wget https://free.currconv.com/api/v7/convert?q=USD_PKR
[2]+  Done                    compact=ultra

Awaiting your response.

Link to comment
Share on other sites

4 hours ago, bendrop said:

Sure!


https://free.currconv.com/api/v7/convert?q=USD_PKR&compact=ultra&apiKey=YOURAPIKEY

Obviously changing "YOURAPIKEY" to your api key 🙂

This is what I run:

Quote

Yes I do fill in the required text but it does not return a response and asks me to provide a API KEY whilst I have already provided.

Link to comment
Share on other sites

1 hour ago, Mohsin Amer said:

Yes I do fill in the required text but it does not return a response and asks me to provide a API KEY whilst I have already provided.

did you get your own API key from their site ?

https://free.currencyconverterapi.com/free-api-key

you will need a unique key and can't just use the phrase "YOURAPIKEY" in the link. 🙂

Link to comment
Share on other sites

2 hours ago, Mohsin Amer said:

This is what I run:

Yes I do fill in the required text but it does not return a response and asks me to provide a API KEY whilst I have already provided.

But it works from your own personal computer right?

This points towards a block then, as you can only do the check from a single IP.

Email them and and ask for the IP to be reset.

Link to comment
Share on other sites

22 hours ago, sorabit said:

You must verify email first

Let me clarify things, I have verified the email, I have reset the IP, I have cURL installed, the thing is it is working occasionally, like it works one day and next day it doesn't and so on, I guess it has to do with it being free. Thanks for your help and guiding through.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated