Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sha
- from time import gmtime, strftime
- import urllib2, urllib
- def getTPSTimeString():
- return strftime("%Y%m%d%H%M",gmtime())[0:11]
- def voucher_catalogue(str_timestamp = None):
- voucherServer = 'http://tct-testing-tps.hk.kitesystems.com:8080/voucher-testing2/api/catalogue'
- sha1 = sha.new()
- if str_timestamp is not None:
- sha1.update(str(str_timestamp))
- else:
- sha1.update(str(""))
- sha1.update('WALLET_TO_VOUCHER')
- sha1.update('492DDE365315631F')
- sha1.update(str(getTPSTimeString()))
- cat_request = CatalogueRequest()
- if str_timestamp is not None:
- cat_request.timestamp = str_timestamp
- else:
- cat_request.timestamp = ""
- cat_request.appName = 'WALLET_TO_VOUCHER'
- cat_request.sessionControl = str(sha1.hexdigest())
- try:
- urllib_request = urllib2.Request(voucherServer,cat_request.SerializeToString())
- response = urllib2.urlopen(urllib_request).read()
- catalogue = Catalogue()
- catalogue.ParseFromString(response)
- if not catalogue.success:
- return False
- else:
- return catalogue
- except Exception as e:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement