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 Code for ResponseHandlerAPIFunctions.asp

 

The ResponseHandlerAPIFunctions.asp library contains a set of functions that are used to handle synchronous responses that Google Checkout sends when it receives an API request from you.

This document includes an explanation of each function in the ResponseHandlerAPIFunctions.asp file. Each explanation includes a list of the parameters that are passed to the function, links to other functions that call the function, and links to the sample API implementations that call the function.

You need to modify the shell functions in the ResponseHandlerAPIFunctions.asp library so that they call your internal order processing systems. The functions should transfer the information in the notifications to your order processing systems so that those systems can react to the notification in the appropriate manner.

Please refer to the CheckoutShoppingCartDemo.asp implementation to see sample usages of these functions.

ResponseHandlerAPIFunctions.asp Functions

processXmlData
 
processRequestReceivedResponse
 
processErrorResponse
 
processDiagnosisResponse
 
processCheckoutRedirect
 

processXmlData

Definition:

The processXmlData function creates a DOM object representation of the XML document received from Google Checkout. It then evaluates the root tag of the XML document to determine which function should handle the response.

This function routes the XML replies that Google Checkout sends in response to your API requests. These replies are sent to one of the other three functions in this library. It also routes Merchant Calculations API requests and Notification API requests. Those requests are processed by functions in the MerchantCalculationsAPIFunctions.asp and NotificationAPIFunctions.asp libraries, respectively.

Parameters:

Parameter Name Definition
xmlData Required. This parameter contains an XML document sent by the Google Checkout server. The document may be a response to a Checkout or Order Processing API request. It may also be a Merchant Calculations or Notification API request that you must process.

See Sample Usage:

OrderProcessingDemo
ResponseHandler

Code:

Function processXmlData(xmlData)

    Dim domResponseObj

    Set domResponseObj = Server.CreateObject(strMsxmlDomDocument)
    domResponseObj.loadXml xmlData

    Dim messageRecognizer
    messageRecognizer = domResponseObj.documentElement.tagName

    ' Select the appropriate function to handle the XML document
    ' by evaluating the root tag of the document. Functions to
    ' handle the following types of responses are contained in
    ' this document:
    '     <request-received>
    '     <error>
    '     <diagnosis>
    '     <checkout-redirect>
    '
    ' This function routes the following types of responses
    ' to the MerchantCalculationsAPIFunctions.asp file:
    '     <merchant-calculation-callback>
    '
    ' This function routes the following types of responses
    ' to the NotificationAPIFunctions.asp file:
    '     <new-order-notification>
    '     <order-state-change-notification>
    '     <charge-amount-notification>
    '     <chargeback-amount-notification>
    '     <refund-amount-notification>
    '     <risk-information-notification>

    Select Case messageRecognizer

        ' <request-received> received
        Case "request-received"
            processRequestReceivedResponse domResponseObj
        
        ' <error> received
        Case "error"
            processErrorResponse domResponseObj

        ' <diagnosis> received
        Case "diagnosis"
            processDiagnosisResponse domResponseObj

        ' <checkout-redirect> received
        Case "checkout-redirect"
            processCheckoutRedirect domResponseObj

        ' +++ CHANGE ME +++
        ' The following case is only for partners who are implementing
        ' the Merchant Calculations API. If you are not implementing
        ' the Merchant Calculations API, you may ignore this case.
        ' <merchant-calculation-callback> received
        Case "merchant-calculation-callback"
            processMerchantCalculationCallback domResponseObj

        ' +++ CHANGE ME +++
        ' The following cases are only for partners who are
        ' implementing the Notification API. If you are not
        ' implementing the Notification API, you may ignore
        ' the remaining cases in this function.

        ' <new-order-notification> received
        Case "new-order-notification"
            processNewOrderNotification domResponseObj
    
        ' <order-state-change-notification> received
        Case "order-state-change-notification"
            processOrderStateChangeNotification domResponseObj
    
        ' <charge-amount-notification> received
        Case "charge-amount-notification"
            processChargeAmountNotification domResponseObj
        
        ' <chargeback-amount-notification> received
        Case "chargeback-amount-notification"
            processChargebackAmountNotification domResponseObj
        
        ' <refund-amount-notification> received
        Case "refund-amount-notification"
            processRefundAmountNotification domResponseObj
        
        ' <risk-information-notification> received
        Case "risk-information-notification"
            processRiskInformationNotification domResponseObj
        
        ' None of the above: message is not recognized.
        ' You should not remove this case.
        Case Else

    End Select

End Function

processRequestReceivedResponse

Definition:

The processRequestReceivedResponse function receives a synchronous Google Checkout response to an API request originating from your site. This function indicates that your API request contained properly formed XML but does not indicate whether your request was processed successfully.

Parameters:

Parameter Name Definition
domResponseObj Required. This parameter contains a DOM object representation of an XML document.

Functions that call processRequestReceivedResponse:

processXmlData

Code:

Function processRequestReceivedResponse(domResponseObj)
    ' +++ CHANGE ME +++
    ' You may need to modify this function if you wish to log information
    ' or perform other actions when you receive a Google Checkout
    ' <request-received> response. The <request-received> response indicates
    ' that you sent a properly formed XML request to Google Checkout. However,
    ' this response does not indicate whether your request was processed
    ' successfully.
    Response.write Server.HTMLEncode(domResponseObj.xml)
End Function

processErrorResponse

Definition:

The processErrorResponse function receives a synchronous Google Checkout response to an API request originating from your site. This function indicates that your API request was not processed. A request might not be processed if it does not contain properly formed XML or if it does not contain a valid merchant ID and merchant key.

Parameters:

Parameter Name Definition
domResponseObj Required. This parameter contains a DOM object representation of an XML document.

Functions that call processErrorResponse:

processXmlData

Code:

Function processErrorResponse(domResponseObj)
    ' +++ CHANGE ME +++
    ' You may need to modify this function if you wish to log
    ' information or perform other actions when you receive
    ' a Google Checkout <error> response. The <error> response indicates that
    ' you sent an invalid XML request to Google Checkout and contains
    ' information explaining why the request was invalid.
    Response.write domResponseObj.xml
End Function

processDiagnosisResponse

Definition:

The processDiagnosisResponse function receives a synchronous Google Checkout response to an API request sent to the Google Checkout XML validator. You can submit a request to the validator by appending the text "/diagnose" to the POST target URL. The response to a diagnostic request contains a list of any warnings returned by the Google Checkout validator.

Parameters:

Parameter Name Definition
domResponseObj Required. This parameter contains a DOM object representation of an XML document.

Functions that call processDiagnosisResponse:

processXmlData

Code:

Function processDiagnosisResponse(domResponseObj)
    ' +++ CHANGE ME +++
    ' You may need to modify this function if you wish to log
    ' warnings or perform other actions when you receive
    ' a Google Checkout <diagnosis> response. The <diagnosis> response contains
    ' warnings that the Google Checkout XML validator generated when
    ' evaluating your XML request.
    Response.write "<i>Diagnosis response message received:</i><br>"
    Response.write Server.HTMLEncode(domResponseObj.xml)
End Function

processCheckoutRedirect

Definition:

The processCheckoutRedirect function receives a synchronous Google Checkout response to a Checkout API request. The response identifies the URL to which you should redirect your customer so that the customer can complete an order using Google Checkout.

Parameters:

Parameter Name Definition
domResponseObj Required. This parameter contains a DOM object representation of an XML document.

Functions that call processCheckoutRedirect:

processXmlData

Code:

Function processCheckoutRedirect(domResponseObj)

    ' Define objects used to process <checkout-redirect> response
    Dim domResponseObjRoot
    Dim redirectUrlList
    Dim strRedirectUrl

    ' Identify the URL to which the customer should be redirected
    Set domResponseObjRoot = domResponseObj.documentElement
    Set redirectUrlList = _
        domResponseObjRoot.getElementsByTagname("redirect-url")
    strRedirectUrl = redirectUrlList(0).text

    ' Redirect the customer to the URL
    Response.redirect strRedirectUrl

    ' Release objects used to process <checkout-redirect> response
    Set domResponseObjRoot = Nothing
    Set redirectUrlList = Nothing

End Function