 |
10th November 2008, 14:22
|
#1
|
|
Super poster
Join Date: Jul 2005
Location: xoggoth towers
Posts: 3,026
|
Shopping cart euro conversion
I want to show an approximate value of an order in Euros on my shopping cart. I could just manually update a rate at regular intervals but as there are so many useful little gadgets around I was wondering if there might be a freeware/cheap link thingy one can embed in a website that I can retrieve in jscript?
Cheers for any ideas.
|
|
|
10th November 2008, 15:15
|
#2
|
|
Super poster
Join Date: Mar 2007
Location: London
Posts: 4,062
|
__________________
Level 20 Xeno Geek.
|
|
|
10th November 2008, 15:42
|
#3
|
|
Super poster
Join Date: Jul 2005
Location: xoggoth towers
Posts: 3,026
|
Ta mule, have found a few neat little converters like that to add to website but am ideally looking for something that needs no user input and will just supply me with a multiplier so I can work out a euro cost from pound cost and show on order page.
|
|
|
10th November 2008, 16:46
|
#4
|
|
Super poster
Join Date: Mar 2007
Location: London
Posts: 4,062
|
Ok. I think you'll end up paying for that sort of thing. I've never seen anywhere that does it for free but then I haven't researched it that thoroughly  .
Maybe you could use their (free) email service some how (maybe extracting the rate you need and plugging into your database?).
Looking at it though, you might be breaking some rules if you use the data commercially ( http://www.xe.com/cus/)
__________________
Level 20 Xeno Geek.
|
|
|
10th November 2008, 16:49
|
#5
|
|
Should try harder
Join Date: Aug 2008
Posts: 141
|
Quote:
Originally Posted by xoggoth
I want to show an approximate value of an order in Euros on my shopping cart. I could just manually update a rate at regular intervals but as there are so many useful little gadgets around I was wondering if there might be a freeware/cheap link thingy one can embed in a website that I can retrieve in jscript?
Cheers for any ideas.
|
Well can you "call" Google - it seems to know the latest exchange rate, e.g. do a search for "100 GBP to EUR", you only have to parse the response.
Last edited by MPwannadecentincome : 10th November 2008 at 16:50.
Reason: clarify parse
|
|
|
10th November 2008, 17:42
|
#6
|
|
Godlike
Join Date: Jul 2005
Posts: 10,425
|
I use Yahoo to get the exchange rate.
Here's some quick and dirty C# code:
Code:
using System;
using System.IO;
using System.Net;
namespace DimPrawn.ASP.NET.Support
{
/// <summary>
/// Summary description for LookupCurrency.
/// </summary>
public class LookupCurrency
{
public LookupCurrency()
{
}
public decimal GetExchangeRate(string fromCurrencyCode, string toCurrencyCode)
{
decimal exchangeRate = 0.0m;
string url = string.Format(URL, fromCurrencyCode, toCurrencyCode);
Uri uri = new Uri(url);
string content = FetchPage(uri);
Numeric.IsNumber(content, out exchangeRate);
return exchangeRate;
}
private string FetchPage(Uri uri)
{
string content = null;
WebResponse response = null;
try
{
// Create a request for this uri
WebRequest request = WebRequest.Create(uri);
// First we only want to ge the HEADER to determine the type of resource at this url
request.Method = "HEAD";
// Fetch the response
response = request.GetResponse();
if ( response is HttpWebResponse )
{
_statusCode = ((HttpWebResponse)response).StatusCode.ToString();
_statusDescription = ((HttpWebResponse)response).StatusDescription;
if ( _statusCode.Equals( "OK" ) )
{
// read the headers
WebHeaderCollection headers = response.Headers;
// get the content type
string contentType = headers["Content-type"];
// If HTML, we will read the content
if (contentType.StartsWith("application/octet-stream"))
{
// Fetch full content
request = WebRequest.Create(uri);
// Fetch the response
response = request.GetResponse();
if ( response is HttpWebResponse )
{
_statusCode = ((HttpWebResponse)response).StatusCode.ToString();
_statusDescription = ((HttpWebResponse)response).StatusDescription;
if ( _statusCode.Equals( "OK" ) )
{
StreamReader sr = new StreamReader( response.GetResponseStream( ) );
content = sr.ReadToEnd( );
}
else
{
_errorCount++;
}
}
else
{
_errorCount++;
}
}
}
}
}
catch(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
_errorCount++;
}
finally
{
if (response != null)
{
response.Close();
}
}
return content;
}
private string _statusCode;
private string _statusDescription;
private int _errorCount;
private const string URL = "http://finance.yahoo.com/d/quotes.csv?s={0}{1}=X&f=a&e=.txt";
}
}
usage:
Code:
LookupCurrency currencyRate = new LookupCurrency();
Decimal exchangeRate = currencyRate.GetExchangeRate("GBP", "EUR");
__________________
Last week I cashed a cheque and the bank bounced.
|
|
|
10th November 2008, 19:45
|
#7
|
|
Super poster
Join Date: Oct 2006
Location: iamapratville - I love the valleys
Posts: 2,597
|
Isn't a general conversion rate asking for trouble, if it doesn't match what your payment processor conversion rate (+ commission, handling fees etc, etc) is?
Last thing you want is to advertise an example calculation, then the punters get charged a totally different amount. Bound to end in tears.
__________________
A bird's for christmas not for life.
|
|
|
10th November 2008, 19:59
|
#8
|
|
Lord of the FAQ
Join Date: Oct 2006
Location: North West
Posts: 6,817
|
Quote:
Originally Posted by PAH
Isn't a general conversion rate asking for trouble, if it doesn't match what your payment processor conversion rate (+ commission, handling fees etc, etc) is?
Last thing you want is to advertise an example calculation, then the punters get charged a totally different amount. Bound to end in tears.
|
You just need to caveat it when you display the price in Euros, that this is an indicative cost and may vary from the amount charged by the payment processor. Same as eBay does for their converted currencies.
__________________
Quote:
Originally Posted by Cyberman
Only Labour politicians deliberately lie.
|
Test please delete - The greatest thread in CUK history (TM)
Visit TPDVille - the online TPD City
|
|
|
10th November 2008, 20:02
|
#9
|
|
Super poster
Join Date: Jun 2007
Location: Your local branch
Posts: 2,776
|
Quote:
Originally Posted by PAH
Isn't a general conversion rate asking for trouble, if it doesn't match what your payment processor conversion rate (+ commission, handling fees etc, etc) is?
Last thing you want is to advertise an example calculation, then the punters get charged a totally different amount. Bound to end in tears.
|
That's an excellent point - the exchange rate on the foreign currency markets would have only marginal relevance to the actual rate used in processing payment. I know you originally specified an approximate conversion, but people don't read the words next to the figures, and whinge when the final figure varies.
Does the company that provides payment processing offer some kind of web service that would allow you to get a more accurate approximation? Better still would be if users could select their currency of choice and see all prices presented in that. Though then that price would become binding, I would imagine.
|
|
|
10th November 2008, 20:56
|
#10
|
|
Super poster
Join Date: Jul 2005
Location: xoggoth towers
Posts: 3,026
|
Ta for all replies. Code looks good Dim, will try that.
I assumed it wouldn't exactly match value they will be charged when they get into Worldpay where they are presented with a choice of currency and it then shows the appropriate sum, although I had assumed the charges fell on us rather than them so difference would be small. Still, easy enough to check that out.
Couldn't find any facility on Worldpay except processing an email after the order.
Last edited by xoggoth : 10th November 2008 at 20:58.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 03:21.
|  |
| Advertisers |
|
| Contractor Alliance |
Formed a new Ltd Co?
20% off business insurance
£10 off Bauer & Cottrell contract reviews
Find co-workers & client introductions
Increase your value to clients here
|
|