Google Checkout Custom Control
A custom control that easily integrates your website with Google Checkout.
Google recently introduce Google Checkout. "Google Checkout is a checkout process that you integrate with your website, enabling your customers to buy from you quickly and securely, using a single username and password. Once they do, you can use Google Checkout to charge their credit cards, process their orders, and receive payment in your bank account."
They currently have no ASP.NET examples posted on their site so I have created an ASP.NET 2.0 Custom Web Control that will allow you to easily integrated with their service by simply dropping a control on the page a specifying a few parameters. So here it is...
Step 1: Modify the Web.Config file
Add the following entry to the web.config file. This will allow you to use the control on any page with out having to add the control directive to each page. Also, don't for get to add the dll to the bin directory of your website.
<add tagPrefix="Google" namespace="Google.Web.UI.WebControls"
Step 2: Add the control to the page.
This is pretty simple, but just make sure you add it outside to the form tags on the page. Specify your MerchantId and MerchantKey that you received for Google and tell the control if it should use the sandbox (test) or the production service. You will need to register for both through Google.
<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="form1" runat="server">
Place info here...
Step 3: Set the Shopping Cart XML Property
In the code behind for the page set the
ShoppingCartXml property. For testing purpose I simply Desearlized there sample
xml in to a ShoppingCart object. Here is a great article on how to do that.
protected void Page_Load(object sender, EventArgs e)
btnGoogleCheckout.CartXml = GetCartXML();
private string GetCartXML()
string xmlFile = "checkout-shopping-cart-SIMPLE.xml";
XmlDocument xml = new XmlDocument();
You are all set. Just click the button and you
will see the shopping cart appear on the Google site. Let me know if you have
any questions or problems with the control.
For more information visit the following link
to the developers guide.