forked from AuthorizeNet/sample-code-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-subscription.py
More file actions
36 lines (27 loc) · 1.3 KB
/
get-subscription.py
File metadata and controls
36 lines (27 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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_subscription(subscriptionId):
merchantAuth = apicontractsv1.merchantAuthenticationType()
merchantAuth.name = constants.apiLoginId
merchantAuth.transactionKey = constants.transactionKey
getSubscription = apicontractsv1.ARBGetSubscriptionRequest()
getSubscription.merchantAuthentication = merchantAuth
getSubscription.subscriptionId = subscriptionId
getSubscription.includeTransactions = True
getSubscriptionController = ARBGetSubscriptionController(getSubscription)
getSubscriptionController.execute()
response = getSubscriptionController.getresponse()
if (response.messages.resultCode=="Ok"):
print ("Subscription Name : %s" % response.subscription.name)
print ("Subscription Amount: %s" % response.subscription.amount)
for transaction in response.subscription.arbTransactions.arbTransaction:
print "Transaction id: %d" % transaction.transId
else:
print ("response code: %s" % response.messages.resultCode)
return response
if(os.path.basename(__file__) == os.path.basename(sys.argv[0])):
get_subscription(constants.subscriptionId)