Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tps_purchase_voucher(data):
- transaction = TransactionList.Transaction()
- transaction.transactionTypeId = 4
- transaction.tpsVersionId = 1 #Purchase Voucher transaction type
- transaction.requestId = 'Testing'
- transaction.remarks = "Purchase Voucher"
- transaction.fromAccountId = 35
- transaction.currencyId = settings.DEFAULT_CURRENCY
- transaction.toAccountId = int(data['toAccountId'])
- transaction.amount = float(data['amount'])
- transaction.VoucherParameters.sku = data['sku']
- transaction.VoucherParameters.phoneNumber = data['phoneNumber']
- try:
- urllib_request = urllib2.Request(TPS_SERVER_POST_ADDRESS, transaction.SerializeToString())
- response = urllib2.urlopen(urllib_request).read()
- transaction_response = TransactionResponseList.TransactionResponse()
- transaction_response.ParseFromString(response)
- except Exception as e:
- return False
- return transaction_response.success
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement