0

I have a Google Wallet/Checkout BuyNow button with code similar to the following (generated from the site tools):

<form action="..." id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" target="_top">
  ...
            <select name="item_selection_1">
                <option value="1">$10 Gift Certificate</option>
                ... other options ...
            </select>
            <input name="item_option_name_1" type="hidden" value="$10 Gift Certificate"/>
            <input name="item_option_price_1" type="hidden" value="10.0"/>
            <input name="item_option_description_1" type="hidden" value="A $10 Gift Certificate"/>
            <input name="item_option_quantity_1" type="hidden" value="1"/>
            <input name="item_option_currency_1" type="hidden" value="USD"/>
            <input name="shopping-cart.item-options.items.item-1.digital-content.url" type="hidden" value="https://example.com/gift-certificate?id=1234&amount=25"/>
            ...
            <input alt="" src="https://checkout.google.com/buttons/buy.gif?merchant_id=...&amp;w=117&amp;h=48&amp;style=trans&amp;variant=text&amp;loc=en_US" type="image"/>
   ...
</form>

Now, when the buyer clicks the button, they can purchase the item and are directed to the digital content URL, but I don't know how I can make the connection to the particular item they purchased. I could put a dynamic id as a URL parameter for the digital content URL, but I still can't see how to connect that to the Google Checkout order number.

For example, I'm using the Notification & Notification History APIs and see a sequence of notifications after purchase, including the notification with information about the buyer and a shopping cart:

<shopping-cart>
<items>
  <item>
    <digital-content>
      <url>https://example.com/gift-certificate?id=1224&amount=25</url>
    </digital-content>
    <item-name> $25 Gift Certificate</item-name>
    <item-description>A $25 Gift Certificate</item-description>
    <quantity>1</quantity>
    <unit-price currency="USD">25.0</unit-price>
  </item>
</items>

I can see that I could parse out the id parameter from the digital-content url, but that seems messy.

Is there a nice way to just include an extra hidden form field and have that value passed through to the notification? (even with a single item BuyNow button?)

Thanks.

4

1 回答 1

2

可以使用以下方式传递商家 ID 甚至任意私有数据:

...
<input type="hidden" name="shopping-cart.item-options.items.item-1.merchant-item-id" value="SKU123">
<input type="hidden" name="shopping-cart.item-options.items.item-1.merchant-private-item-data" value="<opts><token>a5f6b4c</token></opts>">
...

(merchant-private-item-data 不需要是 XML,但如果您使用 Rails google4r-checkout Gem,使用上述 XML 会导致通知将其解析为项目哈希属性:@private_data={" opts"=>{"token"=>"a5f6b4c"}} )

于 2012-11-13T03:17:32.127 回答