Skip to content

Commit e7af23e

Browse files
author
srathod
committed
- Added sample codes for the following:
1. get-batch-statistics 2. get-hosted-profile-page 3. get-settled-batch-list.py 4. get-transaction-details.py 5. get-transaction-list.py
1 parent 3d1bd84 commit e7af23e

5 files changed

Lines changed: 187 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
5+
merchantAuth = apicontractsv1.merchantAuthenticationType()
6+
merchantAuth.name = '5KP3u95bQpv'
7+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
8+
9+
setting = apicontractsv1.settingType()
10+
setting.settingName = apicontractsv1.settingNameEnum.hostedProfileReturnUrl
11+
setting.settingValue = "https://returnurl.com/return/"
12+
13+
settings = apicontractsv1.ArrayOfSetting()
14+
settings.setting.append(setting)
15+
16+
profilePageRequest = apicontractsv1.getHostedProfilePageRequest()
17+
profilePageRequest.merchantAuthentication = merchantAuth
18+
profilePageRequest.customerProfileId = "36152116"
19+
profilePageRequest.hostedProfileSettings = settings
20+
21+
profilePageController = getHostedProfilePageController(profilePageRequest)
22+
23+
profilePageController.execute()
24+
25+
profilePageResponse = profilePageController.getresponse()
26+
27+
if profilePageResponse is not None:
28+
if profilePageResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
29+
print('Successfully got hosted profile page!')
30+
31+
print('Token : %s' % profilePageResponse.token)
32+
33+
if profilePageResponse.messages:
34+
print('Message Code : %s' % profilePageResponse.messages.message[0].code)
35+
print('Message Text : %s' % profilePageResponse.messages.message[0].text)
36+
else:
37+
if profilePageResponse.messages:
38+
print('Failed to get batch statistics.\nCode:%s \nText:%s' % (profilePageResponse.messages.message[0].code,profilePageResponse.messages.message[0].text))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
5+
merchantAuth = apicontractsv1.merchantAuthenticationType()
6+
merchantAuth.name = '5KP3u95bQpv'
7+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
8+
9+
batchStatisticsRequest = apicontractsv1.getBatchStatisticsRequest()
10+
batchStatisticsRequest.merchantAuthentication = merchantAuth
11+
batchStatisticsRequest.batchId = "4532808"
12+
13+
batchStatisticsController = getBatchStatisticsController(batchStatisticsRequest)
14+
15+
batchStatisticsController.execute()
16+
17+
batchStatisticsResponse = batchStatisticsController.getresponse()
18+
19+
if batchStatisticsResponse is not None:
20+
if batchStatisticsResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
21+
print('Successfully got batch statistics!')
22+
23+
print('Batch Id : %s' % batchStatisticsResponse.batch.batchId)
24+
print('Batch Settlement State : %s' % batchStatisticsResponse.batch.settlementState)
25+
print('Batch Payment Method : %s' % batchStatisticsResponse.batch.paymentMethod)
26+
27+
for statistic in batchStatisticsResponse.batch.statistics.statistic:
28+
print('Account Type : %s' % statistic.accountType)
29+
print('Charge Amount : %s' % statistic.chargeAmount)
30+
print('Refund Amount : %s' % statistic.refundAmount)
31+
print('Decline Count : %s' % statistic.declineCount)
32+
33+
if batchStatisticsResponse.messages:
34+
print('Message Code : %s' % batchStatisticsResponse.messages.message[0].code)
35+
print('Message Text : %s' % batchStatisticsResponse.messages.message[0].text)
36+
else:
37+
if batchStatisticsResponse.messages:
38+
print('Failed to get batch statistics.\nCode:%s \nText:%s' % (batchStatisticsResponse.messages.message[0].code,batchStatisticsResponse.messages.message[0].text))
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
from datetime import datetime, timedelta
5+
6+
merchantAuth = apicontractsv1.merchantAuthenticationType()
7+
merchantAuth.name = '5KP3u95bQpv'
8+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
9+
10+
settledBatchListRequest = apicontractsv1.getSettledBatchListRequest()
11+
settledBatchListRequest.merchantAuthentication = merchantAuth
12+
settledBatchListRequest.firstSettlementDate = datetime.now() - timedelta(days=31)
13+
settledBatchListRequest.lastSettlementDate = datetime.now()
14+
15+
settledBatchListController = getSettledBatchListController(settledBatchListRequest)
16+
17+
settledBatchListController.execute()
18+
19+
settledBatchListResponse = settledBatchListController.getresponse()
20+
21+
if settledBatchListResponse is not None:
22+
if settledBatchListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
23+
print('Successfully got settled batch list!')
24+
25+
for batchItem in settledBatchListResponse.batchList.batch:
26+
print('Batch Id : %s' % batchItem.batchId)
27+
print('Settlement State : %s' % batchItem.settlementState)
28+
print('Payment Method : %s' % batchItem.paymentMethod)
29+
print('Product : %s' % batchItem.product)
30+
31+
if batchItem.statistics:
32+
for statistic in batchItem.statistics.statistic:
33+
print('Account Type : %s' % statistic.accountType)
34+
print('Charge Amount : %s' % statistic.chargeAmount)
35+
print('Refund Amount : %s' % statistic.refundAmount)
36+
print('Decline Count : %s' % statistic.declineCount)
37+
38+
if settledBatchListResponse.messages:
39+
print('Message Code : %s' % settledBatchListResponse.messages.message[0].code)
40+
print('Message Text : %s' % settledBatchListResponse.messages.message[0].text)
41+
else:
42+
if settledBatchListResponse.messages:
43+
print('Failed to get settled batch list.\nCode:%s \nText:%s' % (settledBatchListResponse.messages.message[0].code,settledBatchListResponse.messages.message[0].text))
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
5+
merchantAuth = apicontractsv1.merchantAuthenticationType()
6+
merchantAuth.name = '5KP3u95bQpv'
7+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
8+
9+
transactionDetailsRequest = apicontractsv1.getTransactionDetailsRequest()
10+
transactionDetailsRequest.merchantAuthentication = merchantAuth
11+
transactionDetailsRequest.transId = "2239287784"
12+
13+
transactionDetailsController = getTransactionDetailsController(transactionDetailsRequest)
14+
15+
transactionDetailsController.execute()
16+
17+
transactionDetailsResponse = transactionDetailsController.getresponse()
18+
19+
if transactionDetailsResponse is not None:
20+
if transactionDetailsResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
21+
print('Successfully got transaction details!')
22+
23+
print('Transaction Id : %s' % transactionDetailsResponse.transaction.transId)
24+
print('Transaction Type : %s' % transactionDetailsResponse.transaction.transactionType)
25+
print('Transaction Status : %s' % transactionDetailsResponse.transaction.transactionStatus)
26+
print('Auth Amount : %s' % transactionDetailsResponse.transaction.authAmount)
27+
print('Settle Amount : %s' % transactionDetailsResponse.transaction.settleAmount)
28+
29+
if transactionDetailsResponse.messages:
30+
print('Message Code : %s' % transactionDetailsResponse.messages.message[0].code)
31+
print('Message Text : %s' % transactionDetailsResponse.messages.message[0].text)
32+
else:
33+
if transactionDetailsResponse.messages:
34+
print('Failed to get transaction details.\nCode:%s \nText:%s' % (transactionDetailsResponse.messages.message[0].code,transactionDetailsResponse.messages.message[0].text))
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
5+
merchantAuth = apicontractsv1.merchantAuthenticationType()
6+
merchantAuth.name = '5KP3u95bQpv'
7+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
8+
9+
transactionListRequest = apicontractsv1.getTransactionListRequest()
10+
transactionListRequest.merchantAuthentication = merchantAuth
11+
transactionListRequest.batchId = "4551107"
12+
13+
transactionListController = getTransactionListController(transactionListRequest)
14+
15+
transactionListController.execute()
16+
17+
transactionListResponse = transactionListController.getresponse()
18+
19+
if transactionListResponse is not None:
20+
if transactionListResponse.messages.resultCode == apicontractsv1.messageTypeEnum.Ok:
21+
print('Successfully got transaction list!')
22+
23+
for transaction in transactionListResponse.transactions.transaction:
24+
print('Transaction Id : %s' % transaction.transId)
25+
print('Transaction Status : %s' % transaction.transactionStatus)
26+
print('Amount Type : %s' % transaction.accountType)
27+
print('Settle Amount : %s' % transaction.settleAmount)
28+
29+
if transactionListResponse.messages:
30+
print('Message Code : %s' % transactionListResponse.messages.message[0].code)
31+
print('Message Text : %s' % transactionListResponse.messages.message[0].text)
32+
else:
33+
if transactionListResponse.messages:
34+
print('Failed to get transaction list.\nCode:%s \nText:%s' % (transactionListResponse.messages.message[0].code,transactionListResponse.messages.message[0].text))

0 commit comments

Comments
 (0)