|
| 1 | +"""http://developer.authorize.net/api/reference/#recurring-billing-get-a-list-of-subscriptions""" |
| 2 | +import os |
| 3 | +import sys |
| 4 | +import imp |
| 5 | + |
| 6 | +from authorizenet import apicontractsv1 |
| 7 | +from authorizenet.apicontrollers import ARBGetSubscriptionListController |
| 8 | +constants = imp.load_source('modulename', 'constants.py') |
| 9 | + |
| 10 | +def get_list_of_subscriptions(): |
| 11 | + """get list of subscriptions""" |
| 12 | + merchantAuth = apicontractsv1.merchantAuthenticationType() |
| 13 | + merchantAuth.name = constants.apiLoginId |
| 14 | + merchantAuth.transactionKey = constants.transactionKey |
| 15 | + |
| 16 | + sorting = apicontractsv1.ARBGetSubscriptionListSorting() |
| 17 | + sorting.orderBy = apicontractsv1.ARBGetSubscriptionListOrderFieldEnum.id |
| 18 | + sorting.orderDescending = "false" |
| 19 | + |
| 20 | + paging = apicontractsv1.Paging() |
| 21 | + paging.limit = 100 |
| 22 | + paging.offset = 1 |
| 23 | + |
| 24 | + request = apicontractsv1.ARBGetSubscriptionListRequest() |
| 25 | + request.merchantAuthentication = merchantAuth |
| 26 | + request.refId = "Sample" |
| 27 | + request.searchType = apicontractsv1.ARBGetSubscriptionListSearchTypeEnum.subscriptionInactive |
| 28 | + request.sorting = sorting |
| 29 | + request.paging = paging |
| 30 | + |
| 31 | + controller = ARBGetSubscriptionListController(request) |
| 32 | + controller.execute() |
| 33 | + |
| 34 | + response = controller.getresponse() |
| 35 | + |
| 36 | + if response.messages.resultCode == "Ok": |
| 37 | + print "SUCCESS" |
| 38 | + print "Message Code : %s" % response.messages.message[0]['code'].text |
| 39 | + print "Message text : %s" % response.messages.message[0]['text'].text |
| 40 | + print "Total Number In Results : %s" % response.totalNumInResultSet |
| 41 | + else: |
| 42 | + print "ERROR" |
| 43 | + print "Message Code : %s" % response.messages.message[0]['code'].text |
| 44 | + print "Message text : %s" % response.messages.message[0]['text'].text |
| 45 | + |
| 46 | + return response |
| 47 | + |
| 48 | +if os.path.basename(__file__) == os.path.basename(sys.argv[0]): |
| 49 | + get_list_of_subscriptions() |
0 commit comments