|
| 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_unsettled_transaction_list(): |
| 10 | + merchantAuth = apicontractsv1.merchantAuthenticationType() |
| 11 | + merchantAuth.name = constants.apiLoginId |
| 12 | + merchantAuth.transactionKey = constants.transactionKey |
| 13 | + |
| 14 | + unsettledTransactionListRequest = apicontractsv1.getUnsettledTransactionListRequest() |
| 15 | + unsettledTransactionListRequest.merchantAuthentication = merchantAuth |
| 16 | + |
| 17 | + unsettledTransactionListController = getUnsettledTransactionListController(unsettledTransactionListRequest) |
| 18 | + |
| 19 | + unsettledTransactionListController.execute() |
| 20 | + |
| 21 | + unsettledTransactionListResponse = unsettledTransactionListController.getresponse() |
| 22 | + |
| 23 | + if unsettledTransactionListResponse is not None: |
| 24 | + if unsettledTransactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: |
| 25 | + print('Successfully got unsettled transaction list!') |
| 26 | + |
| 27 | + for transaction in unsettledTransactionListResponse.transactions.transaction: |
| 28 | + print('Transaction Id : %s' % transaction.transId) |
| 29 | + print('Transaction Status : %s' % transaction.transactionStatus) |
| 30 | + print('Amount Type : %s' % transaction.accountType) |
| 31 | + print('Settle Amount : %s' % transaction.settleAmount) |
| 32 | + |
| 33 | + if unsettledTransactionListResponse.messages: |
| 34 | + print('Message Code : %s' % unsettledTransactionListResponse.messages.message[0]['code'].text) |
| 35 | + print('Message Text : %s' % unsettledTransactionListResponse.messages.message[0]['text'].text) |
| 36 | + else: |
| 37 | + if unsettledTransactionListResponse.messages: |
| 38 | + print('Failed to get unsettled transaction list.\nCode:%s \nText:%s' % (unsettledTransactionListResponse.messages.message[0]['code'].text,unsettledTransactionListResponse.messages.message[0]['text'].text)) |
| 39 | + |
| 40 | + return unsettledTransactionListResponse |
| 41 | + |
| 42 | +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): |
| 43 | + get_unsettled_transaction_list() |
0 commit comments