From 742bea86a85d542c35d74157e785cd7dd94469f1 Mon Sep 17 00:00:00 2001 From: liveevil Date: Tue, 11 Apr 2017 19:01:39 +0530 Subject: [PATCH 1/2] Sample code for API updates. --- .../get-transaction-details.py | 6 ++- .../get-transaction-list-for-customer.py | 44 +++++++++++++++++++ TransactionReporting/get-transaction-list.py | 2 + .../get-unsettled-transaction-list.py | 6 ++- list_of_sample_codes.txt | 1 + 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 TransactionReporting/get-transaction-list-for-customer.py diff --git a/TransactionReporting/get-transaction-details.py b/TransactionReporting/get-transaction-details.py index fc36f2a..d4398dd 100644 --- a/TransactionReporting/get-transaction-details.py +++ b/TransactionReporting/get-transaction-details.py @@ -32,12 +32,14 @@ def get_transaction_details(transId): print('Settle Amount : %s' % transactionDetailsResponse.transaction.settleAmount) if hasattr(transactionDetailsResponse.transaction, 'tax') == True: print('Tax : %s' % transactionDetailsResponse.transaction.tax.amount) + if hasattr(transactionDetailsResponse.transaction, 'profile'): + print('Customer Profile Id : %s' % transactionDetailsResponse.transaction.profile.customerProfileId) - if transactionDetailsResponse.messages: + if transactionDetailsResponse.messages is not None: print('Message Code : %s' % transactionDetailsResponse.messages.message[0]['code'].text) print('Message Text : %s' % transactionDetailsResponse.messages.message[0]['text'].text) else: - if transactionDetailsResponse.messages: + if transactionDetailsResponse.messages is not None: print('Failed to get transaction details.\nCode:%s \nText:%s' % (transactionDetailsResponse.messages.message[0]['code'].text,transactionDetailsResponse.messages.message[0]['text'].text)) return transactionDetailsResponse diff --git a/TransactionReporting/get-transaction-list-for-customer.py b/TransactionReporting/get-transaction-list-for-customer.py new file mode 100644 index 0000000..d52132f --- /dev/null +++ b/TransactionReporting/get-transaction-list-for-customer.py @@ -0,0 +1,44 @@ +import os, sys +import imp + +from authorizenet import apicontractsv1 +from authorizenet.apicontrollers import * +constants = imp.load_source('modulename', 'constants.py') +from decimal import * + +def get_transaction_list_for_customer(customerProfileId): + merchantAuth = apicontractsv1.merchantAuthenticationType() + merchantAuth.name = constants.apiLoginId + merchantAuth.transactionKey = constants.transactionKey + + transactionListForCustomerRequest = apicontractsv1.getTransactionListForCustomerRequest() + transactionListForCustomerRequest.merchantAuthentication = merchantAuth + transactionListForCustomerRequest.customerProfileId = customerProfileId + + transactionListForCustomerController = getTransactionListForCustomerController(transactionListForCustomerRequest) + + transactionListForCustomerController.execute() + + transactionListForCustomerResponse = transactionListForCustomerController.getresponse() + + if transactionListForCustomerResponse is not None: + if transactionListForCustomerResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: + print('Successfully got transaction list!') + + for transaction in transactionListForCustomerResponse.transactions.transaction: + print('Transaction Id : %s' % transaction.transId) + print('Transaction Status : %s' % transaction.transactionStatus) + print('Amount Type : %s' % transaction.accountType) + print('Settle Amount : %s' % transaction.settleAmount) + + if transactionListForCustomerResponse.messages is not None: + print('Message Code : %s' % transactionListForCustomerResponse.messages.message[0]['code'].text) + print('Message Text : %s' % transactionListForCustomerResponse.messages.message[0]['text'].text) + else: + if transactionListForCustomerResponse.messages is not None: + print('Failed to get transaction list.\nCode:%s \nText:%s' % (transactionListForCustomerResponse.messages.message[0]['code'].text,transactionListForCustomerResponse.messages.message[0]['text'].text)) + + return transactionListForCustomerResponse + +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): + get_transaction_list_for_customer('36152127') diff --git a/TransactionReporting/get-transaction-list.py b/TransactionReporting/get-transaction-list.py index af95cea..9dc6438 100644 --- a/TransactionReporting/get-transaction-list.py +++ b/TransactionReporting/get-transaction-list.py @@ -30,6 +30,8 @@ def get_transaction_list(): print('Transaction Status : %s' % transaction.transactionStatus) print('Amount Type : %s' % transaction.accountType) print('Settle Amount : %s' % transaction.settleAmount) + if hasattr(transaction, 'profile'): + print('Customer Profile Id : %s' % transaction.profile.customerProfileId) if transactionListResponse.messages is not None: print('Message Code : %s' % transactionListResponse.messages.message[0]['code'].text) diff --git a/TransactionReporting/get-unsettled-transaction-list.py b/TransactionReporting/get-unsettled-transaction-list.py index 9a7c7ff..9829e58 100644 --- a/TransactionReporting/get-unsettled-transaction-list.py +++ b/TransactionReporting/get-unsettled-transaction-list.py @@ -29,12 +29,14 @@ def get_unsettled_transaction_list(): print('Transaction Status : %s' % transaction.transactionStatus) print('Amount Type : %s' % transaction.accountType) print('Settle Amount : %s' % transaction.settleAmount) + if hasattr(transaction, 'profile'): + print('Customer Profile Id : %s' % transaction.profile.customerProfileId) - if unsettledTransactionListResponse.messages: + if unsettledTransactionListResponse.messages is not None: print('Message Code : %s' % unsettledTransactionListResponse.messages.message[0]['code'].text) print('Message Text : %s' % unsettledTransactionListResponse.messages.message[0]['text'].text) else: - if unsettledTransactionListResponse.messages: + if unsettledTransactionListResponse.messages is not None: print('Failed to get unsettled transaction list.\nCode:%s \nText:%s' % (unsettledTransactionListResponse.messages.message[0]['code'].text,unsettledTransactionListResponse.messages.message[0]['text'].text)) return unsettledTransactionListResponse diff --git a/list_of_sample_codes.txt b/list_of_sample_codes.txt index f083ab8..016b08d 100644 --- a/list_of_sample_codes.txt +++ b/list_of_sample_codes.txt @@ -47,6 +47,7 @@ get_batch_statistics 1 1 get_settled_batch_list 1 1 get_transaction_details 1 0 get_transaction_list 1 1 +get_transaction_list_for_customer 1 1 get_unsettled_transaction_list 1 0 create_visa_checkout_transaction 1 0 decrypt_visa_checkout_data 1 0 From 597369ff76a9ff446e75465097d9e1f2901bc2c0 Mon Sep 17 00:00:00 2001 From: Akshay Agarwal Date: Wed, 12 Apr 2017 11:18:56 +0530 Subject: [PATCH 2/2] Rename get-transaction-list-for-customer Update and rename get-transaction-list-for-customer.py to get-customer-profile-transaction-list.py for review on #71 --- ...r-customer.py => get-customer-profile-transaction-list.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename TransactionReporting/{get-transaction-list-for-customer.py => get-customer-profile-transaction-list.py} (94%) diff --git a/TransactionReporting/get-transaction-list-for-customer.py b/TransactionReporting/get-customer-profile-transaction-list.py similarity index 94% rename from TransactionReporting/get-transaction-list-for-customer.py rename to TransactionReporting/get-customer-profile-transaction-list.py index d52132f..6705b19 100644 --- a/TransactionReporting/get-transaction-list-for-customer.py +++ b/TransactionReporting/get-customer-profile-transaction-list.py @@ -6,7 +6,7 @@ constants = imp.load_source('modulename', 'constants.py') from decimal import * -def get_transaction_list_for_customer(customerProfileId): +def get_customer_profile_transaction_list(customerProfileId): merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = constants.apiLoginId merchantAuth.transactionKey = constants.transactionKey @@ -41,4 +41,4 @@ def get_transaction_list_for_customer(customerProfileId): return transactionListForCustomerResponse if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): - get_transaction_list_for_customer('36152127') + get_customer_profile_transaction_list('36152127')