Build a .NET App for Google Checkout
Pages: 1, 2, 3, 4
Order Processing API
You already have a pretty solid integration at this point. The next logical step would be to let your system tell Google when to charge orders that are ready to ship, so that you won't have to log in to Google, look up the order, and click the Charge button.
Make sure your app references GCheckout.dll and that you import the GCheckout, GCheckout.Util, and GCheckout.OrderProcessing namespaces. Then you can simply do this:
ChargeOrderRequest Req = new ChargeOrderRequest(X, Y, "Sandbox", 1234567890, "USD", 100.00m);
GCheckoutResponse R = X.Send();
Once you replace X and Y with your Merchant Id and Key, the code above will charge $100.00 for order number 1234567890. If it fails, you will either get an exception or R.IsGood will be false. If the latter, R.ErrorMessage will contain a human-readable error message.
There are nine other requests you can send to Google in the same way as you would a ChargeOrderRequest:
AddMerchantOrderNumberRequest: Mark a Checkout order with an order number from your order system.AddTrackingDataRequest: Set carrier and tracking number for a shipped order, so your customer can track her order.ArchiveOrderRequest: Remove an order from the Order Inbox in your merchant account.CancelOrderRequest: Cancel an order.DeliverOrderRequest: Mark an order as "Shipped."ProcessOrderRequest: Mark an order as "Processing."RefundOrderRequest: Refund an order fully or in part.SendBuyerMessageRequest: Send an email to the customer.UnarchiveOrderRequest: Put a previously archived order back in the Order Inbox.
Tips and Tricks
I hope to have given you a flavor of what it is like integrating with Google Checkout using the .NET sample code. As you move from the examples above to a full integration with your existing web-based store, here are a few lessons from the field:
- Read up on the APIs in the Dev Guide. Even if the sample code lifts the abstraction level, you must have a solid understanding of the APIs to build a successful integration.
- You can add your own custom data to a cart with the "merchant-private-data" field. You can, for example, put cart id, affiliate id, user id, and other things in there that your system needs. Google will send the "merchant-private-data" field back to you as part of the new-order-notification. See the Dev Guide for more details.
- Log all incoming and outgoing XML. This is especially important when your code processes notifications from Google, because that code runs unattended and you can't see the result directly. Even after you have launched, logging all XML can save hours or days of troubleshooting later.
- When you log in to your merchant account, click the Settings tab, and then click Integration link, you will see a list called Integration Issues. All errors visible to Google will be logged there. Check it often, and don't launch until your code produces no more errors!
- When users are on the Google Checkout page, they expect that clicking the Back button in their browser will take them back to your store so they can add more items to their cart. But if they come back to your website the day after placing their order with Checkout, they expect an empty cart. If your system persists carts outside user sessions, it's best to destroy the user's cart when you get the new-order-notification.
- When a new order is placed, parse the new-order-notification to get the order's contents. Don't try to find the existing cart record in your system and assume that's what's in the order. If you do that, a smart user could add items to the cart in your system (with a second browser window) during the Google Checkout process. They could then receive more items than they paid for.
Final Notes
I believe Google Checkout is good for online shoppers, developers, and merchants. The existing sample code reduces the time it takes to integrate with Checkout, compared to starting from scratch. But that is just the beginning. I would encourage you to visit the websites below, ask questions, reply to the questions of others, discuss, and help improve the open source code. To be done with the day's work at 5 p.m., you should not reinvent the wheel.
Martin Omander works at Google where he helps large merchants integrate with Google Checkout.
Return to the Windows DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 17 of 17.
-
SVN Username/Password
2007-12-11 16:13:05 easton [Reply | View]
I tried pulling down the SVN project, however it requires a Username/Password. I looked all over the article but failed to find them. Any chance to get that from anyone?
Thanks!
-
New Order Notification issue
2007-11-30 22:55:22 Imrankhan [Reply | View]
I have implement code to send email to user in the case of new order notification but mail is sent 4 times to user.Any body can help me regarding this problem. -
New Order Notification issue
2007-12-03 23:45:29 momander [Reply | View]
This could happen if there is a timeout. If the Checkout system doesn't get a response from you within 10 seconds, it assumes you didn't get it and retries later. But you may have heard the notification and your response back to Google may simply have been delayed by general Internet slowness.
So you should detect and ignore duplicate notifications. The notification's serial-number remains the same for all retries, so this is a good fiel to check.
-
Using CheckOut API in VB. NET
2007-11-20 06:32:36 zeeshanks [Reply | View]
Hello Martin,
Can you please advise if CheckOut API has been implemented in VB.NET. If yes, where can i find information on it?
Thanks,
Zee -
Using CheckOut API in VB. NET
2007-11-21 00:03:44 momander [Reply | View]
You can download the code from http://code.google.com/p/google-checkout-dotnet-sample-code/
The download examples-v1.2.zip has C# and VB samples of how to call the library.
Cheers
/Martin
-
Using CheckOut API in VB. NET
2007-11-21 13:28:24 zeeshanks [Reply | View]
Hello Martin,
Thanks for your reply. In the example folder, there are subfolders which only have .aspx files and they are in C#. Can you please advise as to which files are VB.NET files?
Thanks,
Zee -
Using CheckOut API in VB. NET
2007-11-21 14:55:25 momander [Reply | View]
Zee,
Sorry I forgot; the VB samples aren't in an official release yet. So either wait a week or two for v1.3 to be released, or grab the VB files from the trunk here: http://google-checkout-dotnet-sample-code.googlecode.com/svn/trunk/examples/vb.net/
/Martin
-
Using CheckOut API in VB. NET
2007-11-21 23:17:23 zeeshanks [Reply | View]
Hello Martin,
Is it possible to get the actual form file for the simple.aspx file?
I 'm trying to compile my project with PostCarttoGoogle function. I have created a button (Button4) in my form.
The first error is related to this line:
Dim Req As CheckoutShoppingCartRequest = Button4.CreateRequest
The error is :
'CreateRequest' is not a member of 'System.Web.UI.WebControls.Button'.
Can you please help.
Thanks,
Zee -
Using CheckOut API in VB. NET
2007-11-22 12:33:14 momander [Reply | View]
Zee,
Sounds like your Button4 is a regular Button and not a GCheckoutButton. Did you add the button to your ASPX page according to page 3 of the article, like this:
<cc1:GCheckoutButton id="GCheckoutButton1" onclick="PostCartToGoogle" runat="server"/>
/Martin
-
Buy Now Button Mistery
2007-11-15 21:46:11 Chital [Reply | View]
Hi All,
I am trying to use Buy Now Button facility of Google Checkout. Now, my application is in ASP.NET 2.0, and given code from google is in HTML. I have used Master Pages for my application which contain a single Form tag into master page, and other content page has only content of the pages (form, text etc.). I cannot use action tag in form as its in Master page, so can any one help for the same?
Its really confusing, how to use Buy Now Buttons in my application?
How can I integrate Buy Now Button code?
As well, there is confusion in Buy Now Button code and Google Checkout - HTML API code. Whether both are the same concept or different one?
Please help as it is urgent.
Chital -
Buy Now Button Mistery
2007-11-17 15:45:02 momander [Reply | View]
The Buy Now button is a way to add Checkout capabilities to a web site by only editing static HTML. They only support buying a single product at a time, and their tax and shipping options are very limited.
If you are ASP.NET writing code anyway, you are probably better off skipping the Buy Now button and going with the regular Checkout button. This is the GCheckoutButton component. It supports adding multiple items per purchase, complex tax rules, and multiple shipping methods.
Even if you don't need all those options, the GCheckoutButton is very easy to work with, and it plays nice with ASP.NET's form handling, which the Buy Now button doesn't.
/Martin
-
looking for vb.net code.
2007-08-30 17:50:08 cemal [Reply | View]
Hi, I appriciate the effort on trying to enlighting us with this google mystery. however since I am a newbie I need a vb.net code for this google checkout sample/tutorial.
do you have one or do you know which web site have it?
thanks again.
Cemal -
looking for vb.net code.
2007-08-30 23:56:59 momander [Reply | View]
You are not alone in wanting a VB version of the code. A community member recently added VB examples to the repository, which you can view here: http://google-checkout-dotnet-sample-code.googlecode.com/svn/trunk/examples/vb.net/
Good luck!
/Martin
-
Google Checkout
2007-03-07 03:00:31 dutt.niraj [Reply | View]
As per you document, I integrated the Google Checkout button in my shopping cart, and also set the API Callback URL, But the thing is, the google does not returns the user back to the URL specified and neither do i get a notification.
Can you please help me by telling where can i be probably wrong






Thanks!