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
|
|
|
from ConfigParser import SafeConfigParser |
14
|
|
|
from authorizenet import apicontractsv1, apicontrollersbase |
15
|
|
|
from authorizenet.utility import * |
16
|
|
|
from authorizenet.apicontractsv1 import CTD_ANON |
17
|
|
|
from authorizenet import utility |
18
|
|
|
|
19
|
|
|
class ApiTestBase(unittest.TestCase): |
20
|
|
|
|
21
|
|
|
def setUp(self): |
22
|
|
|
utility.helper.setpropertyfile('anet_python_sdk_properties.ini') |
23
|
|
|
|
24
|
|
|
self.amount = str(round(random.random()*100, 2)) |
25
|
|
|
|
26
|
|
|
self.merchantAuthentication = apicontractsv1.merchantAuthenticationType() |
27
|
|
|
self.merchantAuthentication.name = utility.helper.getproperty('api.login.id') |
28
|
|
|
self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction.key') |
29
|
|
|
self.ref_id = 'Sample' |
30
|
|
|
|
31
|
|
|
self.dateOne = datetime.date(2020, 8, 30) |
32
|
|
|
self.interval = CTD_ANON() |
33
|
|
|
self.interval.length = 1 |
34
|
|
|
self.interval.unit = 'months' |
35
|
|
|
self.paymentScheduleOne = apicontractsv1.paymentScheduleType() |
36
|
|
|
self.paymentScheduleOne.interval = self.interval |
37
|
|
|
self.paymentScheduleOne.startDate = self.dateOne |
38
|
|
|
self.paymentScheduleOne.totalOccurrences = 12 |
39
|
|
|
self.paymentScheduleOne.trialOccurrences = 1 |
40
|
|
|
|
41
|
|
|
self.creditCardOne = apicontractsv1.creditCardType() |
42
|
|
|
self.creditCardOne.cardNumber = "4111111111111111" |
43
|
|
|
self.creditCardOne.expirationDate = "2020-12" |
44
|
|
|
|
45
|
|
|
self.payment = apicontractsv1.paymentType() |
46
|
|
|
self.payment.creditCard = self.creditCardOne |
47
|
|
|
|
48
|
|
|
self.customerOne = apicontractsv1.nameAndAddressType() |
49
|
|
|
self.customerOne.firstName = "John" |
50
|
|
|
self.customerOne.lastName = "Smith" |
51
|
|
|
|
52
|
|
|
self.customerData = apicontractsv1.customerDataType() |
53
|
|
|
self.customerData.id = "99999456654" |
54
|
|
|
|
55
|
|
|
self.subscriptionOne = apicontractsv1.ARBSubscriptionType() |
56
|
|
|
self.subscriptionOne.paymentSchedule = self.paymentScheduleOne |
57
|
|
|
self.subscriptionOne.amount = Decimal(str(round(random.random()*100, 2))) |
58
|
|
|
self.subscriptionOne.trialAmount = Decimal ('0.03') |
59
|
|
|
self.subscriptionOne.payment = self.payment |
60
|
|
|
self.subscriptionOne.billTo = self.customerOne |
61
|
|
|
|
62
|
|
|
self.order = apicontractsv1.orderType() |
63
|
|
|
self.order.invoiceNumber = "INV-21345" |
64
|
|
|
self.order.description = "Product description" |
65
|
|
|
|
66
|
|
|
self.billTo = apicontractsv1.customerAddressType() |
67
|
|
|
self.billTo.firstName = "Ellen" |
68
|
|
|
self.billTo.lastName = "Johnson" |
69
|
|
|
self.billTo.company = "Souveniropolis" |
70
|
|
|
self.billTo.address = "14 Main St" |
71
|
|
|
self.billTo.city = "Seattle" |
72
|
|
|
self.billTo.state = "WA" |
73
|
|
|
self.billTo.zip = "98122" |
74
|
|
|
self.billTo.country = "USA" |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|