• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Shopping cart euro conversion

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    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.
    bloggoth

    If everything isn't black and white, I say, 'Why the hell not?'
    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

    #2
    http://www.xe.com/ucc/customize.php

    ?
    ‎"See, you think I give a tulip. Wrong. In fact, while you talk, I'm thinking; How can I give less of a tulip? That's why I look interested."

    Comment


      #3
      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.
      bloggoth

      If everything isn't black and white, I say, 'Why the hell not?'
      John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

      Comment


        #4
        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/)
        ‎"See, you think I give a tulip. Wrong. In fact, while you talk, I'm thinking; How can I give less of a tulip? That's why I look interested."

        Comment


          #5
          Originally posted by xoggoth View Post
          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; 10 November 2008, 16:50. Reason: clarify parse
          This default font is sooooooooooooo boring and so are short usernames

          Comment


            #6
            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");

            Comment


              #7
              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.
              Feist - 1234. One camera, one take, no editing. Superb. How they did it
              Feist - I Feel It All
              Feist - The Bad In Each Other (Later With Jools Holland)

              Comment


                #8
                Originally posted by PAH View Post
                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.
                Best Forum Advisor 2014
                Work in the public sector? You can read my FAQ here
                Click here to get 15% off your first year's IPSE membership

                Comment


                  #9
                  Originally posted by PAH View Post
                  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.

                  Comment


                    #10
                    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; 10 November 2008, 20:58.
                    bloggoth

                    If everything isn't black and white, I say, 'Why the hell not?'
                    John Wayne (My guru, not to be confused with my beloved prophet Jeremy Clarkson)

                    Comment

                    Working...
                    X