Solved

Allowing users to change currency on e-commerce web site

Posted on 2013-05-16
1
210 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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