Link to home
Start Free TrialLog in
Avatar of Graeme McGilvray
Graeme McGilvrayFlag for Australia

asked on

Using Currency Layer API within ASP

Hi there, I have learned that Currency Layer have a free Currency conversion API available for use

I have never used an API or implemented one before and was wondering if I can get some help

What I want to do is, on display prices on my website in the currency the browser uses.

Unfortunately I do no know where to start, ask questions away!
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

For a currency conversion, the documentation days you need to call this url or API endpoint

http://apilayer.net/api/convert
    ? access_key = YOUR_ACCESS_KEY
    & from = USD
    & to = GBP      
    & amount = 10  

Classic ASP allows you to make calls to the REST services using the MSXML2.ServerXMLHTTP library, which you can use like this:
Set request = Server.CreateObject("MSXML2.ServerXMLHTTP")
request.Open "GET", theUrl, False
request.Send

Open in new window

You'll get the YOUR_ACCESS_KEY which is somewhat like a user identifier from the Currency Layer website.
Avatar of Graeme McGilvray

ASKER

Hi MlandaT and thanks for the info

sorry unfortunately I am not sure what that means...

I have got as far as signing up with Currency Layer and reproducing the API infomation

http://apilayer.net/api/live?access_key=accesskey&currencies=AUD,GBP,EUR,CAD,AED,JPN,MYR,SGD,NZD&source=USD&format=1

So from reading i use it like this?

Set request = Server.CreateObject("MSXML2.ServerXMLHTTP")
request.Open "GET", http://apilayer.net/api/live?access_key=accesskey&currencies=AUD,GBP,EUR,CAD,AED,JPN,MYR,SGD,NZD&source=USD&format=1, False
request.Send

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for this, seems to be coming along, am going to try and play with it on my site, will report back If i get stuck

Thanks so far!
What is the difference as using as a dictionary vs not ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It sounds like dictionary is the way, as sometimes I would be passing them in a string (well i think i might be)

This is my page I am wishing to incorporate it into: GPTouring

as you can imagine, these motorsports are worldwide and I wish to sell to the world in some popular currencies.
I agree. I think dictionary is the way as well.

Exchange rates, just keep in mind that there will be a lot of variables. If someone pays you using their card, the issuing merchant will use their own exchange rates, which might differ slightly from what you get on Currency Layer (VISA for example https://developer.visa.com/products/foreign_exchange). Any price information that you display on your site, ideally, should indicate that you will still charge them the equivalent in $ (AUD or USD?) unless you are actually able to receive the money without conversion, which would imply you'd have several accounts in the different currencies you want to accept (without x-rate conversion). Here is a nice Quora https://www.quora.com/What-is-the-best-way-to-take-online-payment-in-multiple-currencies-into-a-single-merchant-account
Yes, for sure! I have those rates from my bank of what % i should be charging on top to cover my exchange rate conversion.

Getting back to my Currencies,

If I have a client who visits my site and they wish to view it in EUR

from my API I have, how can I tell my site I want USDEUR rate, so I work out the actual price in the client currency ?

I understand that the ticket will need conversion (possibly, depending on currency it will be bought in)

eg 400 USD, what would be the code to have it auto covert when a client visits the site?