2010-10-10 5 views
0

Je tente d'intégrer Google Checkout à mon site Web. J'ai créé la fonction suivante pour générer la signature HMAC-sha-1 requred:Python: fonction de signature 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 

Je basé ce code hors des exigences énoncées sur http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API.html#create_checkout_cart

Cependant, je ne peux pas obtenir mon panier pour valider la signature . Je reçois toujours l'erreur suivante: "Bad Signature on Cart"

Est-ce que quelqu'un sait comment résoudre ce problème?

Répondre

0

Compris. J'utilisais l'identifiant du marchand au lieu de la clé du marchand.