Google Checkout - XML API associate callback serial number with original order
Asked Answered
D

1

9

Via the XML API, how do you associate an Google Checkout callback serial number with the original order?

On the same line - What does the serial number in the "Option B - Submit a Server-to-Server Checkout API Request" section of the XML API doc correspond to (format: serial-number="981283ea-c324-44bb-a10c-fc3b2eba5707")? Does it relate to the serial sent by the callback URL (numeric-only)?

Deguzman answered 26/7, 2010 at 10:4 Comment(0)
E
8

The way I've done this in the past is using the <merchanrt-private-data> tag in the original cart, so something like:

<checkout-shopping-cart xmlns='http://checkout.google.com/schema/2'>
 <shopping-cart>
  <merchant-private-data>
   <merchant-note>[some secret about the cart on my system]</merchant-note>
  </merchant-private-data>
  <items>
   ...
  </items>
 </shopping-cart>
</checkout-shopping-cart>

Then, after Google has called back with a serial number, I use the Notification History API to retrieve the order details, which then includes my private data, something like:

<new-order-notification xmlns="http://checkout.google.com/schema/2" serial-number="[serial number from google]">
 <buyer-billing-address>
  ...
 </buyer-billing-address>
 <timestamp>...</timestamp>
 <google-order-number>...</google-order-number>
 <order-summary>
  <total-chargeback-amount currency="GBP">...</total-chargeback-amount>
  <google-order-number>...</google-order-number>
  <total-charge-amount currency="GBP">...</total-charge-amount>
  <total-refund-amount currency="GBP">...</total-refund-amount>
  <purchase-date>...</purchase-date>
  <archived>false</archived>
  <shopping-cart>
   <merchant-private-data>
    <merchant-note>[the secret about the cart from my system]</merchant-note>
   </merchant-private-data>
   <items>
   </items>
  </shopping-cart>
  <order-adjustment>
   ...
  </order-adjustment>
  <promotions />
  <buyer-id>...</buyer-id>
  <buyer-marketing-preferences>
   <email-allowed>false</email-allowed>
  </buyer-marketing-preferences>
  <buyer-shipping-address>
   ...
  </buyer-shipping-address>
  <order-total currency="GBP">...</order-total>
  <fulfillment-order-state>NEW</fulfillment-order-state>
  <financial-order-state>REVIEWING</financial-order-state>
 </order-summary>
 <shopping-cart>
  <merchant-private-data>
    <merchant-note>[the secret about the cart from my system]</merchant-note>
  </merchant-private-data>
  <items>
  </items>
 </shopping-cart>
 <order-adjustment>
  ...
 </order-adjustment>
 <promotions />
 <buyer-id>...</buyer-id>
 <buyer-marketing-preferences>
  <email-allowed>false</email-allowed>
 </buyer-marketing-preferences>
 <buyer-shipping-address>
  ...
 </buyer-shipping-address>
 <order-total currency="GBP">...</order-total>
 <fulfillment-order-state>NEW</fulfillment-order-state>
 <financial-order-state>REVIEWING</financial-order-state>
</new-order-notification>

I can then use the secret to match the orders up to the details I'd stored in the database previously.

Engedi answered 12/2, 2011 at 17:3 Comment(3)
Do you know of a good example of how to process this XML? When I try and use the API getMerchantPrivateData returns an AnyMultiple and I can't seem to get the data out of it.Sundowner
@Sundowner it sounds like you're using some kind of wrapper around the XML API which only returns XML, and not objects - you may be better to ask a new question, and specify what libraries you're usingEngedi
@RowlandShaw This saved my life. I don't understand why google don't mention this in the doc.Haymaker

© 2022 - 2024 — McMap. All rights reserved.