Python:Google Checkout 签名函数
我正在尝试将 Google Checkout 集成到我的网站中。我创建了以下函数来生成所需的 hmac-sha-1 签名:
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
我将此代码基于 http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#create_checkout_cart
但是,我无法让我的购物车验证签名。我不断收到以下错误:“购物车签名错误”
有人知道如何解决此问题吗?
I am attempting to integrate Google Checkout into my website. I have created the following function for generating the hmac-sha-1 signature requred:
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
I based this code off of the requirements outlined on http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#create_checkout_cart
However, I cannot get my cart to validate the signature. I keep receiving the following error: "Bad Signature on Cart"
Does anyone know how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。我使用的是商户 ID,而不是商户密钥。
Figured it out. I was using the Merchant ID instead of the Merchant Key.