|
| 1 | +import os, sys |
| 2 | +import imp |
| 3 | + |
| 4 | +from authorizenet import apicontractsv1 |
| 5 | +from authorizenet.apicontrollers import * |
| 6 | +constants = imp.load_source('modulename', 'constants.py') |
| 7 | +from decimal import * |
| 8 | + |
| 9 | +def get_transaction_list_for_customer(customerProfileId): |
| 10 | + merchantAuth = apicontractsv1.merchantAuthenticationType() |
| 11 | + merchantAuth.name = constants.apiLoginId |
| 12 | + merchantAuth.transactionKey = constants.transactionKey |
| 13 | + |
| 14 | + transactionListForCustomerRequest = apicontractsv1.getTransactionListForCustomerRequest() |
| 15 | + transactionListForCustomerRequest.merchantAuthentication = merchantAuth |
| 16 | + transactionListForCustomerRequest.customerProfileId = customerProfileId |
| 17 | + |
| 18 | + transactionListForCustomerController = getTransactionListForCustomerController(transactionListForCustomerRequest) |
| 19 | + |
| 20 | + transactionListForCustomerController.execute() |
| 21 | + |
| 22 | + transactionListForCustomerResponse = transactionListForCustomerController.getresponse() |
| 23 | + |
| 24 | + if transactionListForCustomerResponse is not None: |
| 25 | + if transactionListForCustomerResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: |
| 26 | + print('Successfully got transaction list!') |
| 27 | + |
| 28 | + for transaction in transactionListForCustomerResponse.transactions.transaction: |
| 29 | + print('Transaction Id : %s' % transaction.transId) |
| 30 | + print('Transaction Status : %s' % transaction.transactionStatus) |
| 31 | + print('Amount Type : %s' % transaction.accountType) |
| 32 | + print('Settle Amount : %s' % transaction.settleAmount) |
| 33 | + |
| 34 | + if transactionListForCustomerResponse.messages is not None: |
| 35 | + print('Message Code : %s' % transactionListForCustomerResponse.messages.message[0]['code'].text) |
| 36 | + print('Message Text : %s' % transactionListForCustomerResponse.messages.message[0]['text'].text) |
| 37 | + else: |
| 38 | + if transactionListForCustomerResponse.messages is not None: |
| 39 | + print('Failed to get transaction list.\nCode:%s \nText:%s' % (transactionListForCustomerResponse.messages.message[0]['code'].text,transactionListForCustomerResponse.messages.message[0]['text'].text)) |
| 40 | + |
| 41 | + return transactionListForCustomerResponse |
| 42 | + |
| 43 | +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): |
| 44 | + get_transaction_list_for_customer('36152127') |
0 commit comments