|
| 1 | +import os |
| 2 | +import sys |
| 3 | +from authorizenet import apicontractsv1 |
| 4 | +from authorizenet.apicontrollers import getAUJobDetailsController |
| 5 | +from authorizenet.constants import constants |
| 6 | + |
| 7 | +def get_account_updater_job_details(): |
| 8 | + merchantAuth = apicontractsv1.merchantAuthenticationType() |
| 9 | + merchantAuth.name = constants.apiLoginId |
| 10 | + merchantAuth.transactionKey = constants.transactionKey |
| 11 | + |
| 12 | + paging = apicontractsv1.Paging() |
| 13 | + # Paging limit can be up to 1000 for this request |
| 14 | + paging.limit = 1000 |
| 15 | + paging.offset = 2 |
| 16 | + request = apicontractsv1.getAUJobDetailsRequest() |
| 17 | + request.merchantAuthentication = merchantAuth |
| 18 | + request.paging = paging |
| 19 | + request.month = "2018-08" |
| 20 | + request.modifiedTypeFilter = "all" |
| 21 | + request.refId = "123456" |
| 22 | + controller = getAUJobDetailsController(request) |
| 23 | + controller.execute() |
| 24 | + response = controller.getresponse() |
| 25 | + |
| 26 | + if response is not None: |
| 27 | + if response.messages.resultCode == apicontractsv1.messageTypeEnum.Ok: |
| 28 | + |
| 29 | + if hasattr(response, 'auDetails'): |
| 30 | + print('SUCCESS: Get Account Updater job details for Month :' + request.month) |
| 31 | + if response.messages is not None: |
| 32 | + print('Message Code: %s' % response.messages.message[0]['code'].text) |
| 33 | + print('Message Text: %s' % response.messages.message[0]['text'].text) |
| 34 | + print('Total Number In Results: %s' % response.totalNumInResultSet) |
| 35 | + print('\n') |
| 36 | + |
| 37 | + for details in response.auDetails.auDelete: |
| 38 | + print('Deleted Profile:') |
| 39 | + # auDelete Start |
| 40 | + print('Customer Profile ID: %s' % details.customerProfileID) |
| 41 | + print('Customer Payment Profile ID: %s' % details.customerPaymentProfileID) |
| 42 | + print('First Name: %s' % details.firstName) |
| 43 | + print('Last Name: %s' % details.lastName) |
| 44 | + print('AU Reason Code: %s' % details.auReasonCode) |
| 45 | + print('Reason Description: %s' % details.reasonDescription) |
| 46 | + print('Update Time UTC: %s' % details.updateTimeUTC) |
| 47 | + print(' ') |
| 48 | + # fetching card details: |
| 49 | + print('Card Details:') |
| 50 | + print('Card Number: %s' % details.creditCard.cardNumber) |
| 51 | + print('Card Type: %s' % details.creditCard.cardType) |
| 52 | + print('Expiration Date: %s' % details.creditCard.expirationDate) |
| 53 | + # auDelete End |
| 54 | + print('\n') |
| 55 | + |
| 56 | + for details in response.auDetails.auUpdate: |
| 57 | + |
| 58 | + # auUpdate Start |
| 59 | + print('Updated Profile:') |
| 60 | + print('Customer Profile ID: %s' % details.customerProfileID) |
| 61 | + print('Customer Payment Profile ID: %s' % details.customerPaymentProfileID) |
| 62 | + print('First Name: %s' % details.firstName) |
| 63 | + print('Last Name: %s' % details.lastName) |
| 64 | + print('AU Reason Code: %s' % details.auReasonCode) |
| 65 | + print('Reason Description: %s' % details.reasonDescription) |
| 66 | + print('Update Time UTC: %s' % details.updateTimeUTC) |
| 67 | + # fetching Old card details: |
| 68 | + print('Old Card details:') |
| 69 | + print('old Card Number: %s' % details.oldCreditCard.cardNumber) |
| 70 | + print('old Card Type: %s' % details.oldCreditCard.cardType) |
| 71 | + print('old Expiration Date: %s' % details.oldCreditCard.expirationDate) |
| 72 | + # fetching New card details: |
| 73 | + print('Old Card details:') |
| 74 | + print('new Card Number: %s' % details.newCreditCard.cardNumber) |
| 75 | + print('new Card Type: %s' % details.newCreditCard.cardType) |
| 76 | + print('new Expiration Date: %s' % details.newCreditCard.expirationDate) |
| 77 | + |
| 78 | + else: |
| 79 | + print('Failed to get Get Account Updater job details for Month :' + request.month) |
| 80 | + print('Message Code: %s' % response.messages.message[0]['code'].text) |
| 81 | + print('Message Text: %s' % response.messages.message[0]['text'].text) |
| 82 | + |
| 83 | + else: |
| 84 | + print('Failed to get Get Account Updater job details for Month :' + request.month) |
| 85 | + print('Message Code: %s' % response.messages.message[0]['code'].text) |
| 86 | + print('Message Text: %s' % response.messages.message[0]['text'].text) |
| 87 | + else: |
| 88 | + print('No response received') |
| 89 | + |
| 90 | + |
| 91 | +if(os.path.basename(__file__) == os.path.basename(sys.argv[0])): |
| 92 | + get_account_updater_job_details() |
| 93 | + |
0 commit comments