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 CheckoutAPIFunctions.asp

 

The CheckoutAPIFunctions.asp library contains a set of functions that are used to create Checkout API XML requests. These XML requests include the items in the customer's shopping cart as well as tax tables, shipping options and other information that is used during the customer checkout process.

This document includes an explanation of each function in the CheckoutAPIFunctions.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.

Note: To use these functions in your web application, you will need to update the return values of the GetMerchantID and GetMerchantKey functions in the GlobalAPIFunctions.asp library.

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

Checkout API Functions

createItem
 
createShoppingCart
 
createUsCountryArea
 
createUsStateArea
 
createUsZipArea
 
createUsPlaceArea
 
createTaxArea
 
createDefaultTaxRule
 
createAlternateTaxRule
 
createAlternateTaxTable
 
createTaxTables
 
addAllowedAreas
 
addExcludedAreas
 
addAreas
 
createFlatRateShipping
 
createMerchantCalculatedShipping
 
createPickup
 
createShipping
 
createMerchantCalculations
 
createMerchantCheckoutFlowSupport
 
createCheckoutShoppingCart
 

createItem

Definition:

The createItem function constructs the XML for a single <item> in a shopping cart.

Parameters:

Parameter Name Definition
elemItemName Required. The elemItemName parameter contains the name of the item.
elemItemDescription Required. The elemItemDescription parameter contains a description of the item.
elemQuantity Required. The elemQuantity parameter indicates how many units of the item are included in the order.
elemUnitPrice Required. The elemUnitPrice parameter identifies the numeric cost of the item.
elemTaxTableSelector Optional. The elemTaxTableSelector parameter identifies an alternate tax table that should be used to calculate taxes for the item. The elemTaxTableSelector parameter's value must correspond to the name parameter of an alternate tax table.
elemMerchantPrivateItemData Optional. The elemMerchantPrivateItemData parameter contains proprietary information about the item. Google Checkout will return this information in the new order notification that includes the item. The parameter value must be well formed XML.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createItem(elemItemName, elemItemDescription, elemQuantity, _
    elemUnitPrice, elemMerchantItemId, _
    elemTaxTableSelector, elemMerchantPrivateItemData)

    Dim strFunctionName
    Dim errorType
    strFunctionName = "createItem()"

    ' Each of these parameters must have a value to create an <item>
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "elemItemName", elemItemName
    checkForError errorType, strFunctionName, "elemItemDescription", _
        elemItemDescription
    checkForError errorType, strFunctionName, "elemQuantity", elemQuantity
    checkForError errorType, strFunctionName, "elemUnitPrice", elemUnitPrice
    checkForError errorType, strFunctionName, "attrCurrency", attrCurrency

    ' HTML entities need to be escaped properly
    elemItemName = Server.HTMLEncode(elemItemName)
    elemItemDescription = Server.HTMLEncode(elemItemDescription)

    ' Define objects used to create the item
    Dim domItemObj
    Dim domItem
    Dim domItemName
    Dim domItemDescription
    Dim domQuantity
    Dim domUnitPrice
    Dim domMerchantItemId
    Dim domTaxTableSelector
    Dim domMerchantPrivateItemDataObj
    Dim domNewMerchantPrivateItemData
    Dim domMerchantPrivateItemDataRoot
    Dim domItemsRoot
    Dim domItemRoot

    ' Create the <items> tag if this is the first item to be created
    If Not(IsObject(domItemsObj)) Then
        Set domItemsObj = Server.CreateObject(strMsxmlDomDocument)
        domItemsObj.async = False
        domItemsObj.appendChild(domItemsObj.createElement("items"))
    End If

    Set domItemObj = Server.CreateObject(strMsxmlDomDocument)
    domItemObj.async = False

    ' Create the <item> tag for the item to be created
    Set domItem = domItemObj.appendChild(domItemObj.createElement("item"))

    ' Add the item name to the XML
    Set domItemName = domItem.appendChild(domItemObj.createElement("item-name"))
    domItemName.Text = elemItemName
    
    ' Add the item description to the XML
    Set domItemDescription = _
        domItem.appendChild(domItemObj.createElement("item-description"))
    domItemDescription.Text = elemItemDescription

    ' Add the quantity to the XML
    Set domQuantity = _
        domItem.appendChild(domItemObj.createElement("quantity"))
    domQuantity.Text = elemQuantity

    ' Add the unit price for the item to the XML
    Set domUnitPrice = _
        domItem.appendChild(domItemObj.createElement("unit-price"))
    domUnitPrice.setAttribute "currency", attrCurrency
    domUnitPrice.Text = elemUnitPrice

    ' If you provided a value for the elemMerchantItemId variable,
    ' that value will be used for the <merchant-item-id> tag.
    If elemMerchantItemId <> "" Then
        Set domMerchantItemId = _
            domItem.appendChild(domItemObj.createElement("merchant-item-id"))
        domMerchantItemId.Text = elemMerchantItemId
    End If

    ' If there is an alternate-tax-table associated with this item,
    ' specify the table's name using the <tax-table-selector> tag.
    If elemTaxTableSelector <> "" Then
        Set domTaxTableSelector = _
            domItem.appendChild(domItemObj.createElement("tax-table-selector"))
        domTaxTableSelector.Text = elemTaxTableSelector
    End If

    ' If you have provided a value for the elemMerchantPrivateItemData
    ' variable, that value will be printed inside the
    ' <merchant-private-item-data> tag.
    If elemMerchantPrivateItemData <> "" Then

        Set domMerchantPrivateItemDataObj = _
            Server.CreateObject(strMsxmlDomDocument)
        domMerchantPrivateItemDataObj.async = False
        domMerchantPrivateItemDataObj.loadXml elemMerchantPrivateItemData

        Set domNewMerchantPrivateItemData = domItem.appendChild( _
            domItemObj.createElement("merchant-private-item-data"))

        Set domMerchantPrivateItemDataRoot = _
            domMerchantPrivateItemDataObj.documentElement

        domNewMerchantPrivateItemData.appendChild( _
            domMerchantPrivateItemDataRoot.cloneNode(True))

    End If

    ' The newly created item is added as a child of the <items> tag.
    Set domItemsRoot = domItemsObj.documentElement
    Set domItemRoot = domItemObj.documentElement
    domItemsRoot.appendChild domItemRoot.cloneNode(True)

Set createItem = domItemObj

    ' Release objects used to create item
    Set domItemObj = Nothing
    Set domItem = Nothing
    Set domItemName = Nothing
    Set domItemDescription = Nothing
    Set domQuantity = Nothing
    Set domUnitPrice = Nothing
    Set domMerchantItemId = Nothing
    Set domTaxTableSelector = Nothing
    Set domMerchantPrivateItemDataObj = Nothing
    Set domNewMerchantPrivateItemData = Nothing
    Set domMerchantPrivateItemDataRoot = Nothing
    Set domItemsRoot = Nothing
    Set domItemRoot = Nothing

End Function

createShoppingCart

Definition:

The createShoppingCart function constructs the XML for the <shopping-cart> element in a Checkout API request. Since the <shopping-cart> element contains all of the items in the cart, this function must be called after you have already called the createItem function for each item in the order.

Parameters:

Parameter Name Definition
dtmCartExpiration Optional. The dtmCartExpiration parameter identifies the date that the shopping cart expires. If you specify a value for this parameter, Google Checkout will reject the shopping cart if the user submits the cart after the specified date. If you do not specify a value for this element, the cart will not expire.
elemMerchantPrivateData Optional. The elemMerchantPrivateData parameter contains proprietary information about the order. Google Checkout will return this information in the new order notification for the order. The parameter value must be well formed XML.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createShoppingCart(dtmCartExpiration, elemMerchantPrivateData)

    Dim strFunctionName
    Dim errorType

    strFunctionName = "createShoppingCart()"
    
    ' There must be at least one item in the shopping cart by the
    ' time you call this function or the function will log an error.
    errorType = "MISSING_PARAM"
    If Not(IsObject(domItemsObj)) Then
        errorHandler errorType, strFunctionName, "domItems"
    End If

    ' Define objects used to create the shopping cart
    Dim domShoppingCart
    Dim domItemsRoot
    Dim domCartExpiration
    Dim domGoodUntilDate
    Dim domNewMerchantPrivateData
    Dim domMerchantPrivateDataObj
    Dim domMerchantPrivateDataRoot

    Set domShoppingCartObj = Server.CreateObject(strMsxmlDomDocument)
    domShoppingCartObj.async = False

    ' Create the <shopping-cart> element
    Set domShoppingCart = domShoppingCartObj.appendChild( _
        domShoppingCartObj.createElement("shopping-cart"))
    Set domItemsRoot = domItemsObj.documentElement
    domShoppingCart.appendChild(domItemsRoot.cloneNode(true))
    
    ' If there is an expiration date (dtmCartExpiration) for the cart,
    ' include it in the <shopping-cart> XML.
    If dtmCartExpiration <> "" Then
        Set domCartExpiration = domShoppingCart.appendChild( _
            domShoppingCartObj.createElement("cart-expiration"))
        Set domGoodUntilDate = domCartExpiration.appendChild( _
            domShoppingCartObj.createElement("good-until-date"))
        domGoodUntilDate.Text = dtmCartExpiration
    End If

    ' If you have provided a value for the elemMerchantPrivateData
    ' variable, that value will be printed inside the
    ' <merchant-private-data> tag.
    If elemMerchantPrivateData <> "" Then

        Set domMerchantPrivateDataObj = Server.CreateObject(strMsxmlDomDocument)
        domMerchantPrivateDataObj.async = False
        domMerchantPrivateDataObj.loadXml elemMerchantPrivateData

        Set domNewMerchantPrivateData = domShoppingCart.appendChild( _
            domShoppingCartObj.createElement("merchant-private-data"))

        Set domMerchantPrivateDataRoot = _
            domMerchantPrivateDataObj.documentElement

        domNewMerchantPrivateData.appendChild( _
            domMerchantPrivateDataRoot.cloneNode(true))
    End If

    Set createShoppingCart = domShoppingCartObj

    ' Release objects used to create shipping cart
    Set domShoppingCart = Nothing
    Set domItemsObj = Nothing
    Set domItemsRoot = Nothing
    Set domCartExpiration = Nothing
    Set domGoodUntilDate = Nothing
    Set domNewMerchantPrivateData = Nothing
    Set domMerchantPrivateDataObj = Nothing
    Set domMerchantPrivateDataRoot = Nothing

End Function

createUsCountryArea

Definition:

The createUsCountryArea function is a wrapper function that calls the createUsPlaceArea function. The createUsPlaceArea function, in turn, creates and returns a <us-country-area> XML block.

Parameters:

Parameter Name Definition
areaPlace

The areaPlace parameter identifies the U.S. region that should be included in the XML block.

The valid values for the areaPlace parameter are CONTINENTAL_48, FULL_50_STATES and ALL.

Functions that call createUsCountryArea:

addAreas
createUsZipArea

Code:

Function createUsCountryArea(areaPlace)
    Set createUsCountryArea = createUsPlaceArea("country", areaPlace)
End Function

createUsStateArea

Definition:

The createUsStateArea function is a wrapper function that calls the createUsPlaceArea function. The createUsPlaceArea function, in turn, creates and returns a <us-state-area> XML block.

Parameters:

Parameter Name Definition
areaPlace

The areaPlace parameter identifies the U.S. state that should be included in the XML block.

The areaPlace parameter value should be a two-letter U.S. state abbreviation.

Functions that call createUsStateArea:

addAreas
createUsZipArea

Code:

Function createUsStateArea(areaPlace)
    Set createUsStateArea = createUsPlaceArea("state", areaPlace)
End Function

createUsZipArea

Definition:

The createUsZipArea function is a wrapper function that calls the createUsPlaceArea function. The createUsPlaceArea function, in turn, creates and returns a <us-zip-area> XML block.

Parameters:

Parameter Name Definition
areaPlace

The areaPlace parameter identifies the U.S. zip code}} that should be included in the XML block.

The areaPlace parameter value should be a five-digit U.S. zip code or a zip code pattern.

Functions that call createUsZipArea:

addAreas

Code:

Function createUsZipArea(areaPlace)
    Set createUsZipArea = createUsPlaceArea("zip", areaPlace)
End Function

createUsPlaceArea

Definition:

The createUsPlaceArea function creates <us-country-area>, <us-state-area> and <us-zip-area> XML blocks. This function is called by the createTaxArea and addAreas functions.

Parameters:

Parameter Name Definition
areaType Required. The areaType parameter indicates whether the function should construct a <us-country-area>, <us-state-area> or <us-zip-area> XML block. Valid values for this parameter are country, state and zip.
areaPlace

The areaPlace parameter identifies the U.S. region, state or zip code that should be included in the XML block.

If the value of the areaType parameter is country, then the valid values for the areaPlace parameter are CONTINENTAL_48, FULL_50_STATES and ALL.

If the value of the areaType parameter is state, then the areaPlace parameter value should be a two-letter U.S. state abbreviation.

If the value of the areaType parameter is zip, then the areaPlace parameter value should be a five-digit U.S. zip code or a zip code pattern.

Functions that call createUsPlaceArea:

createTaxArea
createUsCountryArea
createUsStateArea
createUsZipArea

Code:

Function createUsPlaceArea(areaType, areaPlace)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createUsPlaceArea()"
    
    ' Both parameters must be specified for the function call to execute.
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "areaType", areaType
    checkForError errorType, strFunctionName, "areaPlace", areaPlace

    ' Define objects used to create the XML block
    Dim domAreaObj
    Dim domArea
    Dim domAreaPlace

    ' Create the parent XML element for the areaType
    Set domAreaObj = Server.CreateObject(strMsxmlDomDocument)
    domAreaObj.async = False
    Set domArea = domAreaObj.appendChild( _
        domAreaObj.createElement("us-" & areaType & "-area"))

    ' Create the element that contains the areaPlace data
    If areaType = "state" Then

        Set domAreaPlace = _
            domArea.appendChild(domAreaObj.createElement("state"))
        domAreaPlace.Text = areaPlace

    ElseIf areaType = "zip" Then

        Set domAreaPlace = _
            domArea.appendChild(domAreaObj.createElement("zip-pattern"))
        domAreaPlace.Text = areaPlace

    ElseIf areaType = "country" Then

        domArea.setAttribute "country-area", areaPlace

    End If

    Set createUsPlaceArea = domAreaObj

    ' Release objects used to create the XML block
    Set domAreaObj = Nothing
    Set domArea = Nothing
    Set domAreaPlace = Nothing

End Function

createTaxArea

Definition:

The createTaxArea function creates a <tax-area> XML block, which identifies a geographic region where a tax rate applies.

Parameters:

Parameter Name Definition
areaType Required. The areaType parameter indicates whether the function should construct a <us-country-area>, <us-state-area> or <us-zip-area> XML block. Valid values for this parameter are country, state and zip.
areaPlace

The areaPlace parameter identifies the U.S. that should be included in the XML block.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createTaxArea(taxAreaType, taxAreaPlace)
    
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createTaxArea()"
    
    ' Both parameters must be specified for the function call to execute.
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "taxAreaType", taxAreaType
    checkForError errorType, strFunctionName, "taxAreaPlace", taxAreaPlace

    ' Define the objects used to create the tax area
    Dim domTaxAreaObj
    Dim domTaxArea
    Dim domArea
    Dim domAreaRoot

    ' Create the <tax-area> element
    Set domTaxAreaObj = Server.CreateObject(strMsxmlDomDocument)
    domTaxAreaObj.async = False
    Set domTaxArea = _
        domTaxAreaObj.appendChild(domTaxAreaObj.createElement("tax-area"))

    ' Call the createUsPlaceArea function to create the child
    ' elements of the <tax-area> element
    Set domArea = createUsPlaceArea(taxAreaType, taxAreaPlace)
    Set domAreaRoot = domArea.documentElement
    domTaxArea.appendChild(domAreaRoot.cloneNode(true))

    Set createTaxArea = domTaxAreaObj

    ' Release the objects used to create the tax area
    Set domTaxAreaObj = Nothing
    Set domTaxArea = Nothing
    Set domArea = Nothing
    Set domAreaRoot = Nothing

End Function

createDefaultTaxRule

Definition:

The createDefaultTaxRule function creates and returns a <default-tax-rule> XML block.

Parameters:

Parameter Name Definition
elemRate Required. This parameter identifies the tax rate that should be assessed for a given tax rule. The value should be a positive decimal value. Any items that fall under this tax rate will be multiplied by this amount to calculate the tax for the item.
domTaxArea Required. This parameter identifies the area where the tax rate should be applied. The value should be a <tax-area> XML block such as that returned by the createTaxArea function.
elemShippingTaxed Required. This parameter contains a Boolean value that indicates whether shipping costs should be taxed.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createDefaultTaxRule(elemRate, domTaxArea, elemShippingTaxed)

    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createDefaultTaxRule()"
    
    ' Check for missing parameters
    ' You must specify a rate and provide a domTaxArea object for each rule
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "elemRate", elemRate

    If Not(IsObject(domTaxArea)) Then
        errorHandler errorType, strFunctionName, "domTaxArea"
    End If
    
    ' Define the objects used to create the <default-tax-rule>
    Dim domDefaultTaxRuleObj
    Dim domDefaultTaxRule
    Dim domShippingTaxed
    Dim domRate
    Dim domTaxAreaRoot
    Dim domDefaultTaxRulesRoot
    Dim domDefaultTaxRuleRoot

    ' Create the <default-tax-rule> element
    Set domDefaultTaxRuleObj = Server.CreateObject(strMsxmlDomDocument)
    domDefaultTaxRuleObj.async = False

    Set domDefaultTaxRule = domDefaultTaxRuleObj.appendChild( _
        domDefaultTaxRuleObj.createElement("default-tax-rule"))

    ' Add a <shipping-taxed> element if a elemShippingTaxed value is provided
    Set domShippingTaxed = domDefaultTaxRule.appendChild( _
        domDefaultTaxRuleObj.createElement("shipping-taxed"))

    domShippingTaxed.appendChild( _
        domDefaultTaxRuleObj.createTextNode(elemShippingTaxed))

    ' Add the tax rate for the tax rule
    Set domRate = domDefaultTaxRule.appendChild( _
        domDefaultTaxRuleObj.createElement("rate"))
    domRate.appendChild(domDefaultTaxRuleObj.createTextNode(elemRate))

    Set domTaxAreaRoot = domTaxArea.documentElement
    domDefaultTaxRule.appendChild(domTaxAreaRoot.cloneNode(true))

    ' Create a <tax-rules> element if no other <default-tax-rule>
    ' elements have been created. Append the rule to a list that
    ' will appear under the <tax-rules> element within the
    ' <default-tax-table> element
    If Not(IsObject(domDefaultTaxRulesObj)) Then
        Set domDefaultTaxRulesObj = Server.CreateObject(strMsxmlDomDocument)
        domDefaultTaxRulesObj.async = False
        domDefaultTaxRulesObj.appendChild( _
            domDefaultTaxRulesObj.createElement("tax-rules"))
    End If

    ' Add the tax rules to the XML
    Set domDefaultTaxRulesRoot = domDefaultTaxRulesObj.documentElement
    Set domDefaultTaxRuleRoot = domDefaultTaxRuleObj.documentElement
    domDefaultTaxRulesRoot.appendChild(domDefaultTaxRuleRoot.cloneNode(true))

    Set createDefaultTaxRule = domDefaultTaxRuleObj

    ' Release the objects used to create the <default-tax-rule>
    Set domDefaultTaxRuleObj = Nothing
    Set domDefaultTaxRule = Nothing
    Set domShippingTaxed = Nothing
    Set domRate = Nothing
    Set domTaxAreaRoot = Nothing
    Set domDefaultTaxRulesRoot = Nothing
    Set domDefaultTaxRuleRoot = Nothing

End Function

createAlternateTaxRule

Definition:

The createAlternateTaxRule function creates and returns a <alternate-tax-rule> XML block.

Parameters:

Parameter Name Definition
elemRate Required. This parameter identifies the tax rate that should be assessed for a given tax rule. The value should be a positive decimal value. Any items that fall under this tax rate will be multiplied by this amount to calculate the tax for the item.
domTaxArea Required. This parameter identifies the area where the tax rate should be applied. The value should be a <tax-area> XML block such as that returned by the createTaxArea function.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createAlternateTaxRule(elemRate, domTaxArea)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createAlternateTaxRule()"
    
    ' You must specify an elemRate and domTaxArea object for each tax rule
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "elemRate", elemRate

    If Not(IsObject(domTaxArea)) Then
        errorHandler errorType, strFunctionName, "domTaxArea"
    End If

    ' Define the objects used to create the <alternate-tax-rule>
    Dim domAltTaxRuleObj
    Dim domAltTaxRule
    Dim domRate
    Dim domTaxAreaRoot
    Dim domAltTaxRulesRoot
    Dim domAltTaxRuleRoot

    ' Create the <alternate-tax-rule> element
    Set domAltTaxRuleObj = Server.CreateObject(strMsxmlDomDocument)
    domAltTaxRuleObj.async = False
    Set domAltTaxRule = domAltTaxRuleObj.appendChild( _
        domAltTaxRuleObj.createElement("alternate-tax-rule"))

    ' Add the tax rate for the tax rule
    Set domRate = _
        domAltTaxRule.appendChild(domAltTaxRuleObj.createElement("rate"))
    domRate.appendChild(domAltTaxRuleObj.createTextNode(elemRate))

    Set domTaxAreaRoot = domTaxArea.documentElement
    domAltTaxRule.appendChild(domTaxAreaRoot.cloneNode(true))

    ' Create an <alternate-tax-rules> element if this is the first
    ' <alternate-tax-rule> to be created. Append the rule to a list
    ' that will appear under the <alternate-tax-rules> element within
    ' an <alternate-tax-table> element
    If Not(IsObject(domAltTaxRulesObj)) Then
        Set domAltTaxRulesObj = Server.CreateObject(strMsxmlDomDocument)
        domAltTaxRulesObj.async = False
        domAltTaxRulesObj.appendChild( _
            domAltTaxRulesObj.createElement("alternate-tax-rules"))
    End If

    ' Add the alternate tax rules to the XML
    Set domAltTaxRulesRoot = domAltTaxRulesObj.documentElement
    Set domAltTaxRuleRoot = domAltTaxRuleObj.documentElement
    domAltTaxRulesRoot.appendChild(domAltTaxRuleRoot.cloneNode(true))

    Set createAlternateTaxRule = domAltTaxRuleObj

    ' Release the objects used to create the <alternate-tax-rule>
    Set domAltTaxRuleObj = Nothing
    Set domAltTaxRule = Nothing
    Set domRate = Nothing
    Set domTaxAreaRoot = Nothing
    Set domAltTaxRulesRoot = Nothing
    Set domAltTaxRuleRoot = Nothing

End Function

createAlternateTaxTable

Definition:

The createAlternateTaxTable function creates and returns a <alternate-tax-table> XML block. The XML will contain any <alternate-tax-rule> elements that have not already been included in an <alternate-tax-table>.

For example, suppose you want to create two alternate tax tables that each contain two alternate tax rules. One table will contain tax rates for food items and the other would contain tax rates for services. To create the alternate tax tables, you would need to call the createAlternateTaxRule function twice, once for each alternate tax rule in the food tax table. Then you would call the createAlternateTaxTable function. Then you would repeat this process, calling the createAlternateTaxRule function twice, once for each alternate tax rule in the services tax table, and then calling the createAlternateTaxTable function again.

Parameters:

Parameter Name Definition
attrStandalone The attrStandalone parameter contains a Boolean value that indicates how taxes should be calculated if there is no matching <alternate-tax-rule> in the <alternate-tax-table> for the customer's zip code, state or region. Please see the definition of the Checkout API's <alternate-tax-table> tag for more information.
attrName The attrName parameter contains a string, such as "food", that can be used to identify the tax table.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createAlternateTaxTable(attrStandalone, attrName)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createAlternateTaxTable()"
    
    ' You must specify values for the attrStandalone and attrName parameters
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "attrStandalone", attrStandalone
    checkForError errorType, strFunctionName, "attrName", attrName

    ' There must be at least one alternate tax rule to include
    ' in the <alternate-tax-table>. This tax table will include
    ' any <alternate-tax-rule> elements that were created since
    ' after the last call to the createAlternateTaxTable function.

    If Not(IsObject(domAltTaxRulesObj)) Then
        errorHandler errorType, strFunctionName, "domAlternateTaxRules"
    End If
    
    ' Define the objects used to create the <alternate-tax-rule>
    Dim domAltTaxTableObj
    Dim domAltTaxTable
    Dim domAltTaxRulesRoot
    Dim domAltTaxTablesRoot
    Dim domAltTaxTableRoot

    Set domAltTaxTableObj = Server.CreateObject(strMsxmlDomDocument)
    domAltTaxTableObj.async = False

    ' Create the <alternate-tax-table> element
    Set domAltTaxTable = _
        domAltTaxTableObj.appendChild(domAltTaxTableObj.createElement("alternate-tax-table"))
    domAltTaxTable.setAttribute "standalone", attrStandalone
    domAltTaxTable.setAttribute "name", attrName

    ' Add the <alternate-tax-rules> element as
    ' a child element of <alternate-tax-table> elements
    Set domAltTaxRulesRoot = domAltTaxRulesObj.documentElement
    domAltTaxTable.appendChild(domAltTaxRulesRoot.cloneNode(true))

    ' Create an <alternate-tax-tables> element, if one has not yet
    ' been created, to contain all <alternate-tax-table> elements
    If Not(IsObject(domAltTaxTablesObj)) Then
        Set domAltTaxTablesObj = Server.CreateObject(strMsxmlDomDocument)
        domAltTaxTablesObj.async = False
        domAltTaxTablesObj.appendChild(domAltTaxTablesObj.createElement("alternate-tax-tables"))
    End If

    ' Add the <alternate-tax-table> element as a child of
    ' the <alternate-tax-tables> element
    Set domAltTaxTablesRoot = domAltTaxTablesObj.documentElement
    Set domAltTaxTableRoot = domAltTaxTableObj.documentElement
    domAltTaxTablesRoot.appendChild(domAltTaxTableRoot.cloneNode(true))

    Set domAltTaxRulesObj = Server.CreateObject(strMsxmlDomDocument)
    domAltTaxRulesObj.async = False
    domAltTaxRulesObj.appendChild(domAltTaxRulesObj.createElement("alternate-tax-rules"))

    Set createAlternateTaxTable = domAltTaxTableObj

    ' Release the objects used to create the <alternate-tax-rule>
    Set domAltTaxTableObj = Nothing
    Set domAltTaxTable = Nothing
    Set domAltTaxRulesRoot = Nothing
    Set domAltTaxTablesRoot = Nothing
    Set domAltTaxTableRoot = Nothing

End Function

createTaxTables

Definition:

The createTaxTables function constructs the <tax-tables> XML for an order.

Parameters:

Parameter Name Definition
attrMerchantCalculated Required. The attrMerchantCalculated parameter contains a Boolean value that indicates whether tax for the order is calculated using a special process.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createTaxTables(attrMerchantCalculated)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createTaxTables()"
    
    ' Check for missing parameters
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "attrMerchantCalculated", _
        attrMerchantCalculated

    ' Define the objects used to create the <tax-tables>
    Dim domTaxTables
    Dim domDefaultTaxRulesRoot
    Dim domDefaultTaxTableObj
    Dim domDefaultTaxTable
    Dim domDefaultTaxTableRoot
    Dim domAltTaxTablesRoot

    ' Create the <tax-tables> element
    Set domTaxTablesObj = Server.CreateObject(strMsxmlDomDocument)
    domTaxTablesObj.async = False
    Set domTaxTables = _
        domTaxTablesObj.appendChild(domTaxTablesObj.createElement("tax-tables"))

    ' Set the "merchant-calculated" attribute on the <tax-tables> element
    If attrMerchantCalculated <> "" Then
        domTaxTables.setAttribute "merchant-calculated", attrMerchantCalculated
    End If

    ' Create a <default-tax-table> element and append the default tax rules
    Set domDefaultTaxTableObj = Server.CreateObject(strMsxmlDomDocument)
    domDefaultTaxTableObj.async = False
    Set domDefaultTaxTable = domDefaultTaxTableObj.appendChild( _
        domDefaultTaxTableObj.createElement("default-tax-table"))
    Set domDefaultTaxRulesRoot = domDefaultTaxRulesObj.documentElement
    domDefaultTaxTable.appendChild(domDefaultTaxRulesRoot.cloneNode(true))

    ' Make the <default-tax-table> element a child of <tax-tables> element
    Set domDefaultTaxTableRoot = domDefaultTaxTableObj.documentElement
    domTaxTables.appendChild(domDefaultTaxTableRoot.cloneNode(true))

    ' Add the <alternate-tax-tables> elements as children of <tax-tables>
    If IsObject(domAltTaxTablesObj) Then
        Set domAltTaxTablesRoot = domAltTaxTablesObj.documentElement
        domTaxTables.appendChild(domAltTaxTablesRoot.cloneNode(true))
    End If

    Set createTaxTables = domTaxTablesObj

    ' Release the objects used to create the <tax-tables>
    Set domTaxTables = Nothing
    Set domDefaultTaxRulesObj = Nothing
    Set domDefaultTaxRulesRoot = Nothing
    Set domDefaultTaxTableObj = Nothing
    Set domDefaultTaxTable = Nothing
    Set domDefaultTaxTableRoot = Nothing
    Set domAltTaxRulesObj = Nothing
    Set domAltTaxTablesObj = Nothing
    Set domAltTaxTablesRoot = Nothing

End Function

addAllowedAreas

Definition:

The addAllowedAreas function is a wrapper function that calls the addAreas function. The addAreas function, in turn, creates and returns an <allowed-areas> XML DOM.

Parameters:

Parameter Name Definition
attrAllowedCountry This parameter specifies a region of the country where a shipping option is available or unavailable. Valid values for this parameter are CONTINENTAL_48, FULL_50_STATES and ALL.
arrayAllowedState This parameter specifies an array of one or more states where a shipping option is available or unavailable. Each item in the array should be a two-letter U.S. state abbreviation.
arrayAllowedZip This parameter specifies an array of one or more zip codes where a shipping option is available or unavailable. Each item in the array should specify either a five-digit U.S. zip code or a range of zip codes. To specify a range of zip codes, use an asterisk as a wildcard operator. For example, you can specify zip codes 94040 through 94049 by including the value 9404\* in the zip_areas array.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Functions that call addAllowedAreas:

addAreas

Code:

Function addAllowedAreas(attrAllowedCountry, arrayAllowedState, arrayAllowedZip)

    Set addAllowedAreas = _
        addAreas(attrAllowedCountry, arrayAllowedState, arrayAllowedZip, _
            "allowed")

End Function

addExcludedAreas

Definition:

The addExcludedAreas function is a wrapper function that calls the addAreas function. The addAreas function, in turn, creates and returns an <excluded-areas> XML DOM.

Parameters:

Parameter Name Definition
attrExcludedCountry This parameter specifies a region of the country where a shipping option is available or unavailable. Valid values for this parameter are CONTINENTAL_48, FULL_50_STATES and ALL.
arrayExcludedState This parameter specifies an array of one or more states where a shipping option is available or unavailable. Each item in the array should be a two-letter U.S. state abbreviation.
arrayExcludedZip This parameter specifies an array of one or more zip codes where a shipping option is available or unavailable. Each item in the array should specify either a five-digit U.S. zip code or a range of zip codes. To specify a range of zip codes, use an asterisk as a wildcard operator. For example, you can specify zip codes 94040 through 94049 by including the value 9404\* in the zip_areas array.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function addExcludedAreas(attrExcludedCountry, arrayExcludedState, _
    arrayExcludedZip)

    Set addExcludedAreas = _
        addAreas(attrExcludedCountry, arrayExcludedState, arrayExcludedZip, _
            "excluded")

End Function

addAreas

Definition:

The addAreas function creates a list of regions where shipping options are either available or unavailable. The first parameter to this function indicates whether a particular shipping option is available in the specified geographic regions. The remaining parameters specify the regions where that shipping option is available or unavailable.

Parameters:

Parameter Name Definition
attrCountry This parameter specifies a region of the country where a shipping option is available or unavailable. Valid values for this parameter are CONTINENTAL_48, FULL_50_STATES and ALL.
arrayState This parameter specifies an array of one or more states where a shipping option is available or unavailable. Each item in the array should be a two-letter U.S. state abbreviation.
arrayZip This parameter specifies an array of one or more zip codes where a shipping option is available or unavailable. Each item in the array should specify either a five-digit U.S. zip code or a range of zip codes. To specify a range of zip codes, use an asterisk as a wildcard operator. For example, you can specify zip codes 94040 through 94049 by including the value 9404\* in the zip_areas array.
allowedOrExcluded This parameter indicates whether a shipping option is available or unavailable in the specified regions. Valid values for this parameter are allowed and excluded.

Functions that call addAreas:

addAllowedAreas
addExcludedAreas

Code:

Function addAreas(attrCountry, arrayState, arrayZip, allowedOrExcluded)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "addAllowedAreas()"

    ' Verify that arrayState and arrayZip parameters are actually arrays
    errorType = "INVALID_INPUT_ARRAY"
    If Not(IsArray(arrayAllowedState)) Then
        errorHandler errorType, strFunctionName, "arrayState"
    End If

    If Not(IsArray(arrayAllowedZip)) Then
        errorHandler errorType, strFunctionName, "arrayZip"
    End If

    ' Verify that at least one region has been specified
    errorType = "MISSING_PARAM_NONE"
    If attrAllowedCountryArea = "" _
        And UBound(arrayAllowedState) < 0 _
        And UBound(arrayAllowedZip) < 0 _
    Then
        errorHandler errorType, strFunctionName, "attrCountry"
    End If

    ' Define objects used to create the <allowed-areas> or
    ' <excluded-areas> element
    Dim domAreasObj
    Dim domAreas
    Dim domAreasRoot
    Dim domCountry
    Dim domCountryRoot
    Dim domState
    Dim domStateRoot
    Dim domZip
    Dim domZipRoot
    Dim domShippingRestrictionsRoot
    
    Dim iUboundState
    Dim iUboundZip
    Dim iState
    Dim iZip

    ' Create the <allowed-areas> or <excluded-areas> element
    Set domAreasObj = Server.CreateObject(strMsxmlDomDocument)
    domAreasObj.async = False
    Set domAreas = domAreasObj.appendChild( _
        domAreasObj.createElement(allowedOrExcluded & "-areas"))

    ' Add the <us-country-area> element if an attrCountry is provided
    If attrCountry <> "" Then
        Set domCountry = createUsCountryArea(attrCountry)
        Set domCountryRoot = domCountry.documentElement
        domAreas.appendChild(domCountryRoot.cloneNode(true))
    End If

    ' Add a <us-state-area> element for each item in the arrayState array
    For iState = 0 To UBound(arrayState)
        If arrayState(iState) <> "" Then
            Set domState = createUsStateArea(arrayState(iState))
            Set domStateRoot = domState.documentElement
            domAreas.appendChild(domStateRoot.cloneNode(true))
        End If
    Next

    ' Add a <us-zip-area> element for each item in the arrayZip array
    For iZip = 0 To UBound(arrayZip)
        If arrayZip(iZip) <> "" Then
            Set domZip = createUsZipArea(arrayZip(iZip))
            Set domZipRoot = domZip.documentElement
            domAreas.appendChild(domZipRoot.cloneNode(true))
        End If
    Next

    ' Create a <shipping-restrictions> parent element if one has
    ' not already been created
    If Not(IsObject(domShippingRestrictionsObj)) Then
        Set domShippingRestrictionsObj = _
            Server.CreateObject(strMsxmlDomDocument)
        domShippingRestrictionsObj.async = False
        domShippingRestrictionsObj.appendChild( _
            domShippingRestrictionsObj.createElement("shipping-restrictions"))
    End If

    ' Add the shipping restrictions to the XML
    Set domShippingRestrictionsRoot = _
        domShippingRestrictionsObj.documentElement
    Set domAreasRoot = domAreasObj.documentElement
    domShippingRestrictionsRoot.appendChild(domAreasRoot.cloneNode(true))    

    Set addAreas = domShippingRestrictionsObj

    ' Release objects used to create the <allowed-areas> or
    ' <excluded-areas> element
    Set domAreasObj = Nothing
    Set domAreas = Nothing
    Set domAreasRoot = Nothing
    Set domCountry = Nothing
    Set domCountryRoot = Nothing
    Set domState = Nothing
    Set domStateRoot = Nothing
    Set domZip = Nothing
    Set domZipRoot = Nothing
    Set domShippingRestrictionsRoot = Nothing

End Function

createFlatRateShipping

Definition:

The createFlatRateShipping function is a wrapper function that calls the createShipping function. The createShipping function, in turn, creates and returns a <flat-rate-shipping> XML DOM.

Parameters:

Parameter Name Definition
attrName The attrName parameter contains a string that can be used to identify a particular shipping option.
elemPrice The elemPrice parameter specifies the numeric cost of the shipping option.
domShippingRestrictionsObj The domShippingRestrictionsObj parameter contains well-formed XML that identifies areas where the shipping option is either available or unavailable. This XML can be obtained by calling the addAreas function.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Functions that call createFlatRateShipping:

createShipping

Code:

Function createFlatRateShipping(attrName, elemPrice, domShippingRestrictionsObj)

    Set createFlatRateShipping = _
        createShipping("flat-rate-shipping", attrName, elemPrice, _
            domShippingRestrictionsObj)

End Function

createMerchantCalculatedShipping

Definition:

The createMerchantCalculatedShipping function is a wrapper function that calls the createShipping function. The createShipping function, in turn, creates and returns a <merchant-calculated-shipping> XML DOM.

Parameters:

Parameter Name Definition
attrName The attrName parameter contains a string that can be used to identify a particular shipping option.
elemPrice The elemPrice parameter specifies the numeric cost of the shipping option.
domShippingRestrictionsObj The domShippingRestrictionsObj parameter contains well-formed XML that identifies areas where the shipping option is either available or unavailable. This XML can be obtained by calling the addAreas function.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createMerchantCalculatedShipping(attrName, elemPrice, _
    domShippingRestrictionsObj)

Set createMerchantCalculatedShipping = _
        createShipping("merchant-calculated-shipping", attrName, elemPrice, _
            domShippingRestrictionsObj)

End Function

createPickup

Definition:

The createPickup function is a wrapper function that calls the createShipping function. The createShipping function, in turn, creates and returns a <pickup> XML DOM.

Parameters:

Parameter Name Definition
attrName The attrName parameter contains a string that can be used to identify a particular shipping option.
elemPrice The elemPrice parameter specifies the numeric cost of the shipping option.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createPickup(attrName, elemPrice)

Set createPickup = _
        createShipping("pickup", attrName, elemPrice, "")

End Function

createShipping

Definition:

The createShipping function creates and returns <flat-rate-shipping>, <merchant-calculated-shipping> or <pickup> XML DOM objects. Each call to this function identifies the type of shipping option, the cost of the shipping option as well as a name that can be used to identify the shipping option. The function also accepts shipping restrictions for <flat-rate-shipping> and <merchant-calculated-shipping>.

Parameters:

Parameter Name Definition
shippingType The shippingType parameter indicates the type of shipping option for which XML is being created. Valid values for this parameter are flat-rate-shipping, merchant-calculated-shipping and pickup.
attrName The attrName parameter contains a string that can be used to identify a particular shipping option.
elemPrice The elemPrice parameter specifies the numeric cost of the shipping option.
domShippingRestrictionsObj The domShippingRestrictionsObj parameter contains well-formed XML that identifies areas where the shipping option is either available or unavailable. This XML can be obtained by calling the addAreas function.

Functions that call createShipping:

createFlatRateShipping
createMerchantCalculatedShipping
createPickup

Code:

Function createShipping(shippingType, attrName, elemPrice, _
    domShippingRestrictionsObj)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createFlatRateShipping()"

    ' Verify that there are values for all required parameters
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "attrName", attrName
    checkForError errorType, strFunctionName, "elemPrice", elemPrice
    checkForError errorType, strFunctionName, "attrCurrency", attrCurrency
    
    ' Define the variables used to create the shipping information
    Dim domShippingObj
    Dim domShipping
    Dim domShippingRoot
    Dim domPrice
    Dim domShippingRestrictionsRoot
    Dim domShippingMethodsRoot

    ' Create a new parent element using the shippingType as the element name
    Set domShippingObj = Server.CreateObject(strMsxmlDomDocument)
    domShippingObj.async = False
    Set domShipping = _
        domShippingObj.appendChild(domShippingObj.createElement(shippingType))

    ' Set the name and price for the shipping option
    domShipping.setAttribute "name", attrName
    Set domPrice = _
        domShipping.appendChild(domShippingObj.createElement("price"))
    domPrice.setAttribute "currency", attrCurrency
    domPrice.Text = elemPrice

    ' Add shipping-restrictions for <flat-rate-shipping> and
    ' <merchant-calculated-shipping>
    If (shippingType = "flat-rate-shipping" _
        Or shippingType = "merchant-calculated-shipping") _
        And IsObject(domShippingRestrictionsObj) _
    Then
        Set domShippingRestrictionsRoot = _
            domShippingRestrictionsObj.documentElement
        domShipping.appendChild(domShippingRestrictionsRoot.cloneNode(true))
    End If

    ' Create a <shipping-methods> element if one has not already been created
    If Not(IsObject(domShippingMethodsObj)) Then
        Set domShippingMethodsObj = Server.CreateObject(strMsxmlDomDocument)
        domShippingMethodsObj.async = False
        domShippingMethodsObj.appendChild( _
            domShippingMethodsObj.createElement("shipping-methods"))
    End If

    ' Add the shipping method to the XML request
    Set domShippingMethodsRoot = domShippingMethodsObj.documentElement
    Set domShippingRoot = domShippingObj.documentElement
    domShippingMethodsRoot.appendChild(domShippingRoot.cloneNode(true))

    Set createShipping = domShippingObj

    ' Release the variables used to create the shipping information
    Set domShippingObj = Nothing
    Set domShipping = Nothing
    Set domShippingRoot = Nothing
    Set domPrice = Nothing
    Set domShippingRestrictionsRoot = Nothing
    Set domShippingMethodsRoot = Nothing

End Function

createMerchantCalculations

Definition:

The createMerchantCalculations function creates and returns a <merchant-calculations> XML block.

Parameters:

Parameter Name Definition
elemMerchantCalculationsUrl The elemMerchantCalculationsUrl parameter identifies a URL on your site to which Google Checkout should send Merchant Calculations API requests.
elemAcceptMerchantCoupons The elemAcceptMerchantCoupons function contains a Boolean value that indicates whether Google Checkout should display an option for customers to enter coupon codes for an order.
elemAcceptGiftCertificates The elemAcceptGiftCertificates function contains a Boolean value that indicates whether Google Checkout should display an option for customers to enter gift certificate codes for an order.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createMerchantCalculations(elemMerchantCalculationsUrl, _
    elemAcceptMerchantCoupons, elemAcceptGiftCertificates)
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createMerchantCalculations()"

    ' Verify that the elemMerchantCalculationsUrl parameter has a value
    errorType = "MISSING_PARAM"
    checkForError errorType, strFunctionName, "elemMerchantCalculationsUrl", _
        elemMerchantCalculationsUrl

    ' Define the variables used to create the <merchant-calculations> element
    Dim domMerchantCalculations
    Dim domMerchantCalculationsUrl
    Dim domAcceptMerchantCoupons
    Dim domAcceptGiftCertificates

    ' Create the <merchant-calculations> element
    Set domMerchantCalculationsObj = Server.CreateObject(strMsxmlDomDocument)
    domMerchantCalculationsObj.async = False
    Set domMerchantCalculations = domMerchantCalculationsObj.appendChild( _
        domMerchantCalculationsObj.createElement("merchant-calculations"))

    ' Create the <merchant-calculations-url> element
    Set domMerchantCalculationsUrl = domMerchantCalculations.appendChild( _
        domMerchantCalculationsObj.createElement("merchant-calculations-url"))
    domMerchantCalculationsUrl.Text = elemMerchantCalculationsUrl

    ' Create the <accepts-merchant-coupons> element
    If elemAcceptMerchantCoupons <> "" Then

        Set domAcceptMerchantCoupons = domMerchantCalculations.appendChild( _
            domMerchantCalculationsObj.createElement( _
                "accept-merchant-coupons"))

        domAcceptMerchantCoupons.Text = elemAcceptMerchantCoupons

    End If

    ' Create the <accepts-gift-certificates> element
    If elemAcceptGiftCertificates <> "" Then

        Set domAcceptGiftCertificates = domMerchantCalculations.appendChild( _
            domMerchantCalculationsObj.createElement( _
                "accept-gift-certificates"))

        domAcceptGiftCertificates.Text = elemAcceptGiftCertificates

    End If
    
    Set createMerchantCalculations = domMerchantCalculationsObj

    ' Release the variables used to create the <merchant-calculations> element
    Set domMerchantCalculations = Nothing
    Set domMerchantCalculationsUrl = Nothing
    Set domAcceptMerchantCoupons = Nothing
    Set domAcceptGiftCertificates = Nothing

End Function

createMerchantCheckoutFlowSupport

Definition:

The createMerchantCheckoutFlowSupport function builds a <merchant-checkout-flow-support> XML block. This XML contains information about taxes, shipping and other custom calculations to be used in the checkout process. The XML also contains URLs used during the checkout process, such as URLs for the customer to edit her shopping cart or to continue shopping.

Parameters:

Parameter Name Definition
elemEditCartUrl The elemEditCartUrl parameter contains a URL that the customer could click to edit her shopping cart.
elemContinueShoppingUrl The elemContinueShoppingUrl parameter contains a URL that the customer could click to postpone the checkout process and continue shopping.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createMerchantCheckoutFlowSupport(elemEditCartUrl, _
    elemContinueShoppingUrl, elemRequestBuyerPhoneNumber)

    ' Define objects used to create the <merchant-checkout-flow-support> XML
    Dim domMerchantCFS
    Dim domEditCartUrl
    Dim domContinueShoppingUrl
    Dim domRequestBuyerPhoneNumber
    Dim domShippingMethodsRoot
    Dim domTaxTablesRoot
    Dim domMerchantCalculationsRoot

    ' Create the <merchant-checkout-flow-support> element
    Set domMerchantCFSObj = Server.CreateObject(strMsxmlDomDocument)
    domMerchantCFSObj.async = False
    Set domMerchantCFS = domMerchantCFSObj.appendChild( _
        domMerchantCFSObj.createElement("merchant-checkout-flow-support"))

    ' Add the <edit-cart-url> element
    If elemEditCartUrl <> "" Then
        Set domEditCartUrl = domMerchantCFS.appendChild( _
            domMerchantCFSObj.createElement("edit-cart-url"))
        domEditCartUrl.Text = elemEditCartUrl
    End If
    
    ' Add the <continue-shopping-url> element
    If elemContinueShoppingUrl <> "" Then
        Set domContinueShoppingUrl = domMerchantCFS.appendChild( _
            domMerchantCFSObj.createElement("continue-shopping-url"))
        domContinueShoppingUrl.Text = elemContinueShoppingUrl
    End If

    ' Add the <request-buyer-phone-number> element
    If elemRequestBuyerPhoneNumber <> "" Then
        Set domRequestBuyerPhoneNumber = domMerchantCFS.appendChild( _
            domMerchantCFSObj.createElement("request-buyer-phone-number"))
        domRequestBuyerPhoneNumber.Text = elemRequestBuyerPhoneNumber
    End If

    ' Add the <shipping-methods> element
    If IsObject(domShippingMethodsObj) Then
        Set domShippingMethodsRoot = domShippingMethodsObj.documentElement
        domMerchantCFS.appendChild(domShippingMethodsRoot.cloneNode(true))
    End If

    ' Add the <tax-tables> element
    If IsObject(domTaxTablesObj) Then
        Set domTaxTablesRoot = domTaxTablesObj.documentElement
        domMerchantCFS.appendChild(domTaxTablesRoot.cloneNode(true))
    End If

    ' Add the <merchant-calculations> element
    If IsObject(domMerchantCalculationsObj) Then
        Set domMerchantCalculationsRoot = _
            domMerchantCalculationsObj.documentElement
        domMerchantCFS.appendChild(domMerchantCalculationsRoot.cloneNode(true))
    End If

    Set createMerchantCheckoutFlowSupport = domMerchantCFSObj

    ' Release objects used to create the <merchant-checkout-flow-support> XML
    Set domMerchantCFS = Nothing
    Set domEditCartUrl = Nothing
    Set domContinueShoppingUrl = Nothing
    Set domRequestBuyerPhoneNumber = Nothing
    Set domShippingMethodsObj = Nothing
    Set domShippingMethodsRoot = Nothing
    Set domTaxTablesObj = Nothing
    Set domTaxTablesRoot = Nothing
    Set domMerchantCalculationsObj = Nothing
    Set domMerchantCalculationsRoot = Nothing

End Function

createCheckoutShoppingCart

Definition:

The createCheckoutShoppingCart function returns the <checkout-shopping-cart> XML structure, which contains all of the items and checkout-related information for an order.

See Sample Usage:

CheckoutShoppingCartDemo
CheckoutShoppingCartDemoAlternativeMethod

Code:

Function createCheckoutShoppingCart()
    
    ' Check for errors
    Dim strFunctionName
    Dim errorType

    strFunctionName = "createCheckoutShoppingCart()"

    ' Verify that there is a <shopping-cart> XML DOM and a
    ' <merchant-checkout-flow-support> XML DOM
    errorType = "MISSING_PARAM"
    If Not(IsObject(domShoppingCartObj)) Then
        errorHandler errorType, strFunctionName, "domShoppingCartObj", _
            domShoppingCartObj
    End If

    ' Define the variables used to create the <checkout-shopping-cart> element
    Dim domCheckoutShoppingCart
    Dim domShoppingCartRoot
    Dim domCFSRoot
    Dim domCFS
    Dim domMerchantCFSRoot
    
    ' Create the <checkout-flow-support> element and add
    ' the <merchant-checkout-flow-support> element as a child element
    Set domCFSObj = Server.CreateObject(strMsxmlDomDocument)
    domCFSObj.async = False
    Set domCFS = _
        domCFSObj.appendChild(domCFSObj.createElement("checkout-flow-support"))

    Set domMerchantCFSRoot = domMerchantCFSObj.documentElement
    domCFS.appendChild(domMerchantCFSRoot.cloneNode(true))

    Set domCheckoutShoppingCartObj = Server.CreateObject(strMsxmlDomDocument)
    domCheckoutShoppingCartObj.async = False

    domCheckoutShoppingCartObj.appendChild( _
        domCheckoutShoppingCartObj.createProcessingInstruction( _
            "xml", strXmlVersionEncoding))

    ' Create the <checkout-shopping-cart> element
    Set domCheckoutShoppingCart = domCheckoutShoppingCartObj.appendChild( _
        domCheckoutShoppingCartObj.createElement("checkout-shopping-cart"))
    domCheckoutShoppingCart.setAttribute "xmlns", strXmlns

    ' Add the <shopping-cart> element as a child element of the
    ' <checkout-shopping-cart> element
    Set domShoppingCartRoot = domShoppingCartObj.documentElement
    domCheckoutShoppingCart.appendChild(domShoppingCartRoot.cloneNode(true))

    Set domCFSRoot = domCFSObj.documentElement
    domCheckoutShoppingCart.appendChild(domCFSRoot.cloneNode(true))

    createCheckoutShoppingCart = domCheckoutShoppingCartObj.xml

    ' Release the variables used to create the <checkout-shopping-cart> element
    Set domShoppingCartObj = Nothing
    Set domCheckoutShoppingCart = Nothing
    Set domShoppingCartRoot = Nothing
    Set domCFSObj = Nothing
    Set domCFSRoot = Nothing
    Set domCFS = Nothing
    Set domMerchantCFSObj = Nothing
    Set domMerchantCFSRoot = Nothing

End Function