Google Checkout API

XML API Developer's Guide

HTML API Developer's Guide

Using Google Analytics

Third-Party Conversion Tracking

Terms and Conditions

Sample Code

XML Schema

Developer's Cookbook

Checkout Button URL Generator

Acceptance logos

FAQ

Developer's Forum

Blog

Sample Order Processing API Implementation

 

The OrderProcessingDemo.asp page demonstrates a simple implementation of a page that sends Order Processing API requests to Google Checkout.

To adapt the OrderProcessingDemo.asp implementation for use in your site, you will need to be able to retrieve the Google Checkout order number associated with an order. You will also need to be able to retrieve information about the order's status (archived, active, canceled, etc.), the amount you have charged the customer for the order, and shipment tracking information for the order. You will then need to call the appropriate OrderProcessingAPIFunctions.php functions, as demonstrated in the sample implementation, to execute the appropriate order processing commands.

In addition, partners who are implementing the Order Processing API also need to implement the Notification API to process and store order data received from Google Checkout.

Sample Order Processing API Implementation

<!--#INCLUDE file="GlobalAPIFunctions.asp"-->
<!--#INCLUDE file="OrderProcessingAPIFunctions.asp"-->
<!--#INCLUDE file="ResponseHandlerAPIFunctions.asp"-->

<%

'**************** Build Order Processing Commands *******************

' Define objects used to create and send Order Processing API requests
Dim xmlRequest
Dim xmlResponse

Dim attrGoogleOrderNumber
Dim elemAmount
Dim elemReason
Dim elemComment
Dim elemCarrier
Dim elemTrackingNumber
Dim elemMessage
Dim elemSendEmail
Dim elemMerchantOrderNumber

Dim transmitResponse

' The next three lines of code specify the information for
' a <charge-order> command and then call the CreateChargeOrder
' function to construct that command.
'
' Following the <charge-order> command, there are several snippets
' of commented code that could be used to create other types of
' Order Processing API commands for the same order.

' This section creates a <charge-order> request
' Comment out the following section and uncomment another section
' to create another request
attrGoogleOrderNumber = "841171949013218"
elemAmount = "100.00"
xmlRequest = createChargeOrder(attrGoogleOrderNumber, elemAmount)

' This section creates a <refund-order> request
' attrGoogleOrderNumber = "841171949013218"
' elemReason = "Buyer requested refund."
' elemAmount = "120.00"
' elemComment = "Buyer is not happy with the product."
' xmlRequest = createRefundOrder(attrGoogleOrderNumber, elemReason, _
'     elemAmount, elemComment)

' This section creates a <cancel-order> request
' attrGoogleOrderNumber = "841171949013218"
' elemReason = "Buyer cancelled the order."
' elemComment = "Buyer found a better deal."
' xmlRequest = createCancelOrder(attrGoogleOrderNumber, elemReason, elemComment)

' This section creates a <process-order> request
' attrGoogleOrderNumber = "841171949013218"
' xmlRequest = createProcessOrder(attrGoogleOrderNumber)

' This section creates a <deliver-order> request
' attrGoogleOrderNumber = "841171949013218"
' elemCarrier = "UPS"
' elemTrackingNumber = "Z5498W45987123684"
' elemSendEmail = "true"
' xmlRequest = createDeliverOrder(attrGoogleOrderNumber, elemCarrier, _
'    elemTrackingNumber, elemSendEmail)

' This section creates an <add-tracking-data> request
' attrGoogleOrderNumber = "841171949013218"
' elemCarrier = "UPS"
' elemTrackingNumber = "Z9842W69871281267"
' xmlRequest = createAddTrackingData(attrGoogleOrderNumber, elemCarrier, _
'    elemTrackingNumber)

' This section creates an <archive-order> request
' attrGoogleOrderNumber = "841171949013218"
' xmlRequest = createArchiveOrder(attrGoogleOrderNumber)

' This section creates an <unarchive-order> request
' attrGoogleOrderNumber = "841171949013218"
' xmlRequest = createUnarchiveOrder(attrGoogleOrderNumber)

' This section creates a <send-buyer-message> request
' attrGoogleOrderNumber = "841171949013218"
' elemMessage = "Dear Customer, due to a high volume of orders, your order " _
'     & "will not be charged and shipped until next week."
' elemSendEmail = "true"
' xmlRequest = createSendBuyerMessage(attrGoogleOrderNumber, elemMessage, _
'    elemSendEmail)

' This section creates an <add-merchant-order-number> request
' attrGoogleOrderNumber = "841171949013218"
' elemMerchantOrderNumber = "MyOrderNumber012345"
' xmlRequest = createAddMerchantOrderNumber(attrGoogleOrderNumber, _
'    elemMerchantOrderNumber)

' The following HTML page calls the displayDiagnoseResponse function,
' which is defined in GlobalAPIFunctions.asp, to verify that the
' API request contains valid XML. If the request does contain valid XML,
' the page sends the request to Google Checkout by calling the sendRequest
' function, which is also defined in GlobalAPIFunctions.asp.
' The page then calls the processXmlData function, which is defined in
' ResponseHandlerAPIFunctions.asp, to handle Google Checkout's API response.
'
' If the request does not contain valid XML, you will see a link to
' a tool that lets you edit and recheck the XML. The code for that
' tool is in the <b>DebuggingTool.asp</b> file, which is also
' included in the <b>checkout-asp-samplecode.zip</b> file.
%>

<html>
<head>
    <style type="text/css">@import url(googleCheckout.css);</style>
</head>
<body>
<p style="text-align:center">
<table class="table-1" cellspacing="5" cellpadding="5">
    <tr><td style="padding-bottom:20px;text-align:center"><h2>
        Order Processing Command
    </h2></td></tr>
    <tr><td style="padding-bottom:20px">
        <p><b>Order Processing Command XML:</b></p>
        <p><%=Server.HTMLEncode(xmlRequest)%></p>
    </td></tr>
<%
    ' Validate Request XML
    DisplayDiagnoseResponse xmlRequest, requestDiagnoseUrl, _
        xmlRequest, "debug"

    Response.write "<tr><td style=""padding-bottom:20px"">" & _
        "<p><b>Synchronous Response Received:</b></p>"

    ' Send the request and receive a response
    transmitResponse = SendRequest(xmlRequest, requestUrl)

    ' Process the response
    Response.write "<p>" & ProcessXmlData(transmitResponse) & "</p></td></tr>"

%>
</table>
</p>
</body>
</html>