Solved

Allowing users to change currency on e-commerce web site

Posted on 2013-05-16
1
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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