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.
<system.web>
<pages maintainScrollPositionOnPostBack="true">
<controls>
<add tagPrefix="Google" namespace="Google.Web.UI.WebControls"
assembly="Google.Web"/>
</controls>
</pages>
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" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Place info here...
</div>
</form>
<Google:CheckoutButton MerchantId="101156456465"
MerchantKey="234lk4j53452lkj34" UseSandBox="true"
runat="server" ID="btnGoogleCheckout"/>
</body>
</html>
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.
http://www.netomatix.com/Products/Ecomm/GoogleCheckOut.aspx
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();
xml.Load(Server.MapPath(xmlFile));
return xml.InnerXml;
}
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.
Sandeep Kumar MPosted Jun 9, 2009, 8:23 AM
Hi all, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p> This article is almost 3 years old. Google code has all documents and sample codes for asp.net. List of useful links for Google Checkout http://code.google.com/apis/checkout/index.html Examples includes response handling methods http://code.google.com/p/google-checkout-dotnet-sample-code/ http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_NET.html#googleCheckoutSampleCodeNETStepsToInstallGCheckoutModuleVisualStudio http://windowsdevcenter.com/pub/a/windows/2007/01/09/build-a-net-app-for-google-checkout.html?page=1<o:p></o:p>
WAQAR AHMADPosted May 20, 2009, 3:37 AM
First of all thanx for this effort. i m wondering if can explain how to handle the response, that would be sent by google check out Thanx
WAQAR AHMADPosted May 20, 2009, 3:23 AM
First of all thanx for this effort. i m wondering if can explain how to handle the response, that would be sent by google check out Thanx
Rahul MishraPosted Jun 21, 2007, 6:01 AM
hi, i was using this code but on click on google check out button its opening google.com (default page of google)...?
Rahul MishraPosted Jun 21, 2007, 5:52 AM
hi, i was using this code but on click on google check out button its opening google.com (default page of google)...?
Mike GoldPosted May 3, 2007, 7:11 PM
Thanks Justin, We need more articles on the site like this one. Good Work!