E-xact Knowledge Base

Sample code for generating the hash for Hosted Checkout using Python

To generate x_fp_hash using Python, please see the snippet below:

----------------------------------------------------------------------------------------------

import hmac
import hashlib

# Instantiate hmac with Transaction key (HMAC-MD5)
# digest_maker = hmac.new('V0WX5fK~o6eEhr7hbs3ZeyxS', '', hashlib.md5)

# Instantiate hmac with Transaction key (HMAC-SHA1)
digest_maker = hmac.new('V0WX5fK~o6eEhr7hbs3ZeyxS', '', hashlib.sha1)

# %(x_login)^%(x_fp_sequence)^%(x_fp_timestamp)^%(x_amount)^%(x_currency)

data =  '%(x_login)s^%(x_fp_sequence)s^%(x_fp_timestamp)s^%(x_amount)s^%(x_currency)s' \
   %  {'x_login': 'WSP-ACTIV-70', 'x_fp_sequence' : '123',\
       'x_fp_timestamp' : '1228774539', 'x_amount' : '100.00', 'x_currency' : ''}

digest_maker.update(data)
x_fp_hash = digest_maker.hexdigest()
print x_fp_hash



------------------------------------------------------------------------------------------------


Article Details

Last Updated
20th of May, 2010

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions (0 votes)

No users have voted.

How would you rate this answer?



Thank you for rating this answer.

Continue