2010-10-10 42 views
0

我正在嘗試將Google Checkout集成到我的網站中。我創建了下面的函數生成requred的HMAC-SHA-1簽名:我根據這個代碼斷概述了http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#create_checkout_cartPython:Google Checkout簽名功能

但是要求

def make_signature(cart_xml): 
    import hmac 
    import hashlib 
    import base64 

    # The number is a psuedo-merchantID, cart_xml contains a string with the 
    # shopping cart xml as outlined on google's documentation. 
    signature = hmac.new("711348421531236", cart_xml, hashlib.sha1) 
    signature = base64.b64encode(signature.digest()) 

    return signature 

,我不能讓我的車驗證簽名。我不斷收到以下錯誤:「購物車上的壞簽名」

有誰知道如何解決此問題?

回答

0

想通了。我使用的是商戶ID而不是商戶密鑰。