Advertisement
six519

Untitled

Nov 18th, 2011
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def tps_purchase_voucher(data):
  2.  
  3. transaction = TransactionList.Transaction()
  4. transaction.transactionTypeId = 4
  5. transaction.tpsVersionId = 1 #Purchase Voucher transaction type
  6. transaction.requestId = 'Testing'
  7. transaction.remarks = "Purchase Voucher"
  8. transaction.fromAccountId = 35
  9. transaction.currencyId = settings.DEFAULT_CURRENCY
  10. transaction.toAccountId = int(data['toAccountId'])
  11. transaction.amount = float(data['amount'])
  12. transaction.VoucherParameters.sku = data['sku']
  13. transaction.VoucherParameters.phoneNumber = data['phoneNumber']
  14.  
  15. try:
  16. urllib_request = urllib2.Request(TPS_SERVER_POST_ADDRESS, transaction.SerializeToString())
  17. response = urllib2.urlopen(urllib_request).read()
  18. transaction_response = TransactionResponseList.TransactionResponse()
  19. transaction_response.ParseFromString(response)
  20. except Exception as e:
  21. return False
  22.  
  23. return transaction_response.success
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement