2013-02-04 61 views
0

我試圖爲我的網站創建Google付款付款。在這個環節Google Checkout「XML代碼併發送客戶端到服務器」Ruby on Rails

https://developers.google.com/checkout/developer/interactive_demo

我創造了我的代碼怎麼會一個演示,這裏是我的選擇

enter image description here

然後在網頁生成的代碼:

<!-- Sell digital goods with description-based delivery of download instructions (with tax, no shipping) --> 
    <?xml version="1.0" encoding="UTF-8"?> 
    <checkout-shopping-cart xmlns="http://checkout.google.com/schema/2"> 
    <shopping-cart> 
     <items> 
     <item> 
      <item-name>Super Software 5000</item-name> 
      <item-description>Super Software 5000 improves download speeds.</item-description> 
      <unit-price currency="USD">1.00</unit-price> 
      <quantity>1</quantity> 

      <digital-content> 
      <display-disposition>OPTIMISTIC</display-disposition> 
      <description> 
       It may take up to 24 hours to process your new storage. You will 
       be able to see your increased storage on your 
       &lt;a href=&quot;http://login.example.com&quot;&gt;account page&lt;/a&gt;. 
      </description> 
      </digital-content> 

     </item> 
     </items> 
    </shopping-cart> 
    <checkout-flow-support> 
     <merchant-checkout-flow-support/> 
    </checkout-flow-support> 
    </checkout-shopping-cart> 

    <!-- No tax code --> 

    <!-- No shipping code --> 
You need to encode and sign the above XML code before posting it. 

任何人都可以解釋對我來說,我必須做的這個XML代碼我必須把它放在我的rails項目上?

我知道這個代碼,進入我的觀點,但我必須把XML?感謝您的幫助

<form method="POST" 
     action="https://sandbox.google.com/checkout/api/checkout/v2/checkout/Merchant/REPLACE_WITH_YOUR_SANDBOX_MERCHANT_ID"> 

    <input type="hidden" name="cart" value="REPLACE_WITH_ENCODED_CART"> 
    <input type="hidden" name="signature" value="REPLACE_WITH_SIGNATURE"> 

    <!-- Button code --> 
    <input type="image" name="Google Checkout" 
     alt="Fast checkout through Google" 
     src="http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=REPLACE_WITH_YOUR_SANDBOX_MERCHANT_ID&w=180&h=46&style=white&variant=text&loc=en_US" 
     height="46" 
     width="180"> 
</form> 

回答

0
  1. XML節說明什麼(XML代表你checkout-shopping-cartyou need to generate(使用任何平臺/語言,你的情況RR),使用Base64編碼,並最終爲它創建一個HMAC-SHA-1簽名(你也將base64編碼)。

  2. HTML部分向您顯示您將放置base64編碼的XML和簽名的位置。在這種情況下,這是一個直接HTML FORM POST到谷歌 - 注意佔位符:

    • <input type="hidden" name="cart" value="REPLACE_WITH_ENCODED_CART">
    • <input type="hidden" name="signature" value="REPLACE_WITH_SIGNATURE">
相關問題