Skip to content

Commit 742bea8

Browse files
Sample code for API updates.
1 parent e2533d2 commit 742bea8

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

TransactionReporting/get-transaction-details.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ def get_transaction_details(transId):
3232
print('Settle Amount : %s' % transactionDetailsResponse.transaction.settleAmount)
3333
if hasattr(transactionDetailsResponse.transaction, 'tax') == True:
3434
print('Tax : %s' % transactionDetailsResponse.transaction.tax.amount)
35+
if hasattr(transactionDetailsResponse.transaction, 'profile'):
36+
print('Customer Profile Id : %s' % transactionDetailsResponse.transaction.profile.customerProfileId)
3537

36-
if transactionDetailsResponse.messages:
38+
if transactionDetailsResponse.messages is not None:
3739
print('Message Code : %s' % transactionDetailsResponse.messages.message[0]['code'].text)
3840
print('Message Text : %s' % transactionDetailsResponse.messages.message[0]['text'].text)
3941
else:
40-
if transactionDetailsResponse.messages:
42+
if transactionDetailsResponse.messages is not None:
4143
print('Failed to get transaction details.\nCode:%s \nText:%s' % (transactionDetailsResponse.messages.message[0]['code'].text,transactionDetailsResponse.messages.message[0]['text'].text))
4244

4345
return transactionDetailsResponse
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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')

TransactionReporting/get-transaction-list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def get_transaction_list():
3030
print('Transaction Status : %s' % transaction.transactionStatus)
3131
print('Amount Type : %s' % transaction.accountType)
3232
print('Settle Amount : %s' % transaction.settleAmount)
33+
if hasattr(transaction, 'profile'):
34+
print('Customer Profile Id : %s' % transaction.profile.customerProfileId)
3335

3436
if transactionListResponse.messages is not None:
3537
print('Message Code : %s' % transactionListResponse.messages.message[0]['code'].text)

TransactionReporting/get-unsettled-transaction-list.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ def get_unsettled_transaction_list():
2929
print('Transaction Status : %s' % transaction.transactionStatus)
3030
print('Amount Type : %s' % transaction.accountType)
3131
print('Settle Amount : %s' % transaction.settleAmount)
32+
if hasattr(transaction, 'profile'):
33+
print('Customer Profile Id : %s' % transaction.profile.customerProfileId)
3234

33-
if unsettledTransactionListResponse.messages:
35+
if unsettledTransactionListResponse.messages is not None:
3436
print('Message Code : %s' % unsettledTransactionListResponse.messages.message[0]['code'].text)
3537
print('Message Text : %s' % unsettledTransactionListResponse.messages.message[0]['text'].text)
3638
else:
37-
if unsettledTransactionListResponse.messages:
39+
if unsettledTransactionListResponse.messages is not None:
3840
print('Failed to get unsettled transaction list.\nCode:%s \nText:%s' % (unsettledTransactionListResponse.messages.message[0]['code'].text,unsettledTransactionListResponse.messages.message[0]['text'].text))
3941

4042
return unsettledTransactionListResponse

list_of_sample_codes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ get_batch_statistics 1 1
4747
get_settled_batch_list 1 1
4848
get_transaction_details 1 0
4949
get_transaction_list 1 1
50+
get_transaction_list_for_customer 1 1
5051
get_unsettled_transaction_list 1 0
5152
create_visa_checkout_transaction 1 0
5253
decrypt_visa_checkout_data 1 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy