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

只愿长相守 提交于 2019-11-27 02:15:16

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!