1
|
|
|
''' |
2
|
|
|
Created on Jul 15, 2015 |
3
|
|
|
|
4
|
|
|
@author: egodolja |
5
|
|
|
''' |
6
|
|
|
|
7
|
|
|
import unittest |
8
|
|
|
import datetime |
9
|
|
|
from decimal import * |
10
|
|
|
import random |
11
|
|
|
import test |
12
|
|
|
|
13
|
|
|
try: |
14
|
|
|
from ConfigParser import SafeConfigParser |
15
|
|
|
except ImportError: |
16
|
|
|
from configparser import SafeConfigParser |
17
|
|
|
|
18
|
|
|
from authorizenet import apicontractsv1, apicontrollersbase |
19
|
|
|
from authorizenet.utility import * |
20
|
|
|
#from authorizenet.apicontractsv1 import CTD_ANON |
21
|
|
|
from authorizenet import utility |
22
|
|
|
|
23
|
|
|
class ApiTestBase(unittest.TestCase): |
24
|
|
|
|
25
|
|
|
def setUp(self): |
26
|
|
|
utility.helper.setpropertyfile('anet_python_sdk_properties.ini') |
27
|
|
|
|
28
|
|
|
self.amount = str(round(random.random()*100, 2)) |
29
|
|
|
|
30
|
|
|
self.merchantAuthentication = apicontractsv1.merchantAuthenticationType() |
31
|
|
|
|
32
|
|
|
self.merchantAuthentication.name = utility.helper.getproperty('api.login.id') |
33
|
|
|
if self.merchantAuthentication.name == None: |
34
|
|
|
self.merchantAuthentication.name = utility.helper.getproperty('api_login_id') |
35
|
|
|
|
36
|
|
|
self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction.key') |
37
|
|
|
if self.merchantAuthentication.transactionKey == None: |
38
|
|
|
self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction_key') |
39
|
|
|
|
40
|
|
|
self.ref_id = 'Sample' |
41
|
|
|
|
42
|
|
|
self.dateOne = datetime.date(2020, 8, 30) |
43
|
|
|
# self.interval = CTD_ANON() |
44
|
|
|
# self.interval.length = 1 |
45
|
|
|
# self.interval.unit = 'months' |
46
|
|
|
self.paymentScheduleOne = apicontractsv1.paymentScheduleType() |
47
|
|
|
self.paymentScheduleOne.interval = apicontractsv1.paymentScheduleTypeInterval() |
48
|
|
|
|
49
|
|
|
self.paymentScheduleOne.interval.length = 1 |
50
|
|
|
self.paymentScheduleOne.interval.unit = 'months' |
51
|
|
|
|
52
|
|
|
self.paymentScheduleOne.startDate = self.dateOne |
53
|
|
|
self.paymentScheduleOne.totalOccurrences = 12 |
54
|
|
|
self.paymentScheduleOne.trialOccurrences = 1 |
55
|
|
|
|
56
|
|
|
self.creditCardOne = apicontractsv1.creditCardType() |
57
|
|
|
self.creditCardOne.cardNumber = "4111111111111111" |
58
|
|
|
self.creditCardOne.expirationDate = "2020-12" |
59
|
|
|
|
60
|
|
|
self.payment = apicontractsv1.paymentType() |
61
|
|
|
self.payment.creditCard = self.creditCardOne |
62
|
|
|
|
63
|
|
|
self.customerOne = apicontractsv1.nameAndAddressType() |
64
|
|
|
self.customerOne.firstName = "John" + str(random.randint(0, 10000)) |
65
|
|
|
self.customerOne.lastName = "Smith" |
66
|
|
|
|
67
|
|
|
self.customerData = apicontractsv1.customerDataType() |
68
|
|
|
self.customerData.id = "99999456654" |
69
|
|
|
|
70
|
|
|
self.subscriptionOne = apicontractsv1.ARBSubscriptionType() |
71
|
|
|
self.subscriptionOne.paymentSchedule = self.paymentScheduleOne |
72
|
|
|
self.subscriptionOne.amount = Decimal(str(round(random.random()*100, 2))) |
73
|
|
|
self.subscriptionOne.trialAmount = Decimal(str(round(random.random()*100, 2))) |
74
|
|
|
self.subscriptionOne.payment = self.payment |
75
|
|
|
self.subscriptionOne.billTo = self.customerOne |
76
|
|
|
|
77
|
|
|
self.order = apicontractsv1.orderType() |
78
|
|
|
self.order.invoiceNumber = "INV-21345" |
79
|
|
|
self.order.description = "Product description" |
80
|
|
|
|
81
|
|
|
self.billTo = apicontractsv1.customerAddressType() |
82
|
|
|
self.billTo.firstName = "Ellen" |
83
|
|
|
self.billTo.lastName = "Johnson" |
84
|
|
|
self.billTo.company = "Souveniropolis" |
85
|
|
|
self.billTo.address = "14 Main St" |
86
|
|
|
self.billTo.city = "Seattle" |
87
|
|
|
self.billTo.state = "WA" |
88
|
|
|
self.billTo.zip = "98122" |
89
|
|
|
self.billTo.country = "USA" |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|