Solved

Allowing users to change currency on e-commerce web site

Posted on 2013-05-16
1
211 Views
Last Modified: 2013-08-22
I'm working on an e-commerce web site that currently displays all of the prices in USD.
I would like to add functionality that would allow the user to change the currency.

I was thinking about using a currency converter api to get the rates.
The base rate would be USD = 1

I would create a process that would consume the currency convert service/api and persist the rates every 12 hours.

On the top header of every page would be a menu to select a different currency.
Once the user selected a different currency, I would do a post back and look up the rate to calculate the prices.

I would then persist that selected rate to a cookie.

What are your thoughts? Any areas that can be improved on?
0
Comment
Question by:JRockFL
1 Comment
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 500 total points
ID: 39210070
Use google api services to convert currency

And use one currency at back end and always show on front the currency change

like in calculations normally there is always one single currency

but on display you can just change currency by calling it from google api services

You just have to pass Currency from (etc PKR) , currency to (etc $)
Then it will give you the exact amount
So no need to worried about update your currency every day.
The code call the google api to convert currency

public static string ConvertCurrency (string To , string Amount , HttpRequest Request)
        {


        string Expression = Amount + “USD” + “=?” + To;
        string url = “http://www.google.com/ig/calculator?hl=en&q=” + Expression;


        string response = “”;
        string responseMsg = Request.Params.ToString();
        string post = responseMsg;
       
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        req.Method = “POST”;
        req.ContentType = “application/x-www-form-urlencoded”;
        req.ContentLength = post.Length;


        StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
        writer.Write(post);
        writer.Close();


        StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream());
        response = reader.ReadToEnd();
        reader.Close();


        char[] cChar = new  char[3];
        string[] _params = new string[100];


        cChar[0] = ‘,’;
        _params = response.Split(cChar[0]);


        string ConvertedAmount = “”;


        ConvertedAmount = _params[1];
        ConvertedAmount = ConvertedAmount.Replace(“\”", “”);
        ConvertedAmount = ConvertedAmount.Replace(“rhs”, “”);
        ConvertedAmount = ConvertedAmount.Replace(“:”, “”);
        ConvertedAmount = ConvertedAmount.Trim();
        ConvertedAmount = ConvertedAmount.Remove(ConvertedAmount.IndexOf(‘ ‘), ConvertedAmount.Length – ConvertedAmount.IndexOf(‘ ‘));


        return ConvertedAmount;


        }

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question