LitleOnline 8.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/DESCRIPTION +5 -0
- data/LICENSE +22 -0
- data/README.md +69 -0
- data/Rakefile +92 -0
- data/SETUP.md +47 -0
- data/bin/Setup.rb +103 -0
- data/bin/sample_driver.rb +49 -0
- data/index.html +176 -0
- data/index.html.1 +176 -0
- data/lib/Checker.rb +56 -0
- data/lib/Communications.rb +85 -0
- data/lib/Configuration.rb +45 -0
- data/lib/LitleOnline.rb +52 -0
- data/lib/LitleOnlineRequest.rb +399 -0
- data/lib/LitleXmlMapper.rb +48 -0
- data/lib/Obj2xml.rb +37 -0
- data/lib/XMLFields.rb +378 -0
- data/test/certification/certTest1_base.rb +948 -0
- data/test/certification/certTest2_authenhanced.rb +571 -0
- data/test/certification/certTest3_authreversal.rb +184 -0
- data/test/certification/certTest4_echeck.rb +279 -0
- data/test/certification/certTest5_token.rb +222 -0
- data/test/certification/ts_all.rb +31 -0
- data/test/functional/test_auth.rb +135 -0
- data/test/functional/test_authReversal.rb +68 -0
- data/test/functional/test_capture.rb +71 -0
- data/test/functional/test_captureGivenAuth.rb +161 -0
- data/test/functional/test_credit.rb +154 -0
- data/test/functional/test_echeckCredit.rb +116 -0
- data/test/functional/test_echeckRedeposit.rb +78 -0
- data/test/functional/test_echeckSale.rb +157 -0
- data/test/functional/test_echeckVerification.rb +92 -0
- data/test/functional/test_forceCapture.rb +105 -0
- data/test/functional/test_sale.rb +198 -0
- data/test/functional/test_token.rb +102 -0
- data/test/functional/test_xmlfields.rb +403 -0
- data/test/functional/ts_all.rb +39 -0
- data/test/unit/test_Checker.rb +58 -0
- data/test/unit/test_LitleOnlineRequest.rb +288 -0
- data/test/unit/test_auth.rb +168 -0
- data/test/unit/test_authReversal.rb +41 -0
- data/test/unit/test_capture.rb +40 -0
- data/test/unit/test_captureGivenAuth.rb +108 -0
- data/test/unit/test_credit.rb +117 -0
- data/test/unit/test_echeckCredit.rb +45 -0
- data/test/unit/test_echeckRedeposit.rb +76 -0
- data/test/unit/test_echeckSale.rb +45 -0
- data/test/unit/test_echeckVerification.rb +75 -0
- data/test/unit/test_forceCapture.rb +122 -0
- data/test/unit/test_sale.rb +249 -0
- data/test/unit/test_token.rb +70 -0
- data/test/unit/test_xmlfields.rb +173 -0
- data/test/unit/ts_unit.rb +41 -0
- metadata +166 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2012 Litle & Co.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
|
26
|
+
#test driver for running all tests
|
27
|
+
require_relative 'test_xmlfields'
|
28
|
+
require_relative 'test_sale'
|
29
|
+
require_relative 'test_auth'
|
30
|
+
require_relative 'test_authReversal'
|
31
|
+
require_relative 'test_credit'
|
32
|
+
require_relative 'test_token'
|
33
|
+
require_relative 'test_forceCapture'
|
34
|
+
require_relative 'test_capture'
|
35
|
+
require_relative 'test_captureGivenAuth'
|
36
|
+
require_relative 'test_echeckRedeposit'
|
37
|
+
require_relative 'test_echeckSale'
|
38
|
+
require_relative 'test_echeckCredit'
|
39
|
+
require_relative 'test_echeckVerification'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2011 Litle & Co.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require 'lib/LitleOnline'
|
26
|
+
require 'lib/LitleOnlineRequest'
|
27
|
+
require 'test/unit'
|
28
|
+
require 'mocha'
|
29
|
+
|
30
|
+
class CheckerTest < Test::Unit::TestCase
|
31
|
+
def test_purge_null
|
32
|
+
hash = {'a'=>'one','b'=>nil,'c'=>{},'d'=>{'e'=>'two'},'f'=>'throwFlag'}
|
33
|
+
Checker.purge_null(hash)
|
34
|
+
assert_equal 2, hash.length
|
35
|
+
assert_equal 'one', hash['a']
|
36
|
+
assert_equal 'two', hash['d']['e']
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_required_missing
|
40
|
+
hash = {'a'=>'REQUIRED','b'=>'2'}
|
41
|
+
exception = assert_raise(RuntimeError){Checker.required_missing(hash)}
|
42
|
+
assert_match /Missing Required Field: a!!!!/, exception.message
|
43
|
+
|
44
|
+
hash = {'a'=>'1','b'=>'2'}
|
45
|
+
assert_nothing_raised {Checker.required_missing(hash)}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_choice
|
49
|
+
assert_nothing_raised {Checker.choice({})}
|
50
|
+
|
51
|
+
assert_nothing_raised {Checker.choice({'a'=>'1'})}
|
52
|
+
assert_nothing_raised {Checker.choice({'a'=>'1','b'=>nil})}
|
53
|
+
|
54
|
+
exception = assert_raise(RuntimeError) {Checker.choice({'a'=>'1','b'=>'2'})}
|
55
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2011 Litle & Co.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require 'lib/LitleOnline'
|
26
|
+
require 'lib/LitleOnlineRequest'
|
27
|
+
require 'test/unit'
|
28
|
+
require 'mocha'
|
29
|
+
|
30
|
+
class Newtest < Test::Unit::TestCase
|
31
|
+
def test_set_merchant_id
|
32
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}})
|
33
|
+
litle = LitleOnlineRequest.new
|
34
|
+
assert_equal '2', litle.send(:get_merchant_id, {'merchantId'=>'2'})
|
35
|
+
assert_equal '1', litle.send(:get_merchant_id, {'NotMerchantId'=>'2'})
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_simple
|
39
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
40
|
+
hash = {
|
41
|
+
'reportGroup'=>'Planets',
|
42
|
+
'orderId'=>'12344',
|
43
|
+
'amount'=>'106',
|
44
|
+
'orderSource'=>'ecommerce',
|
45
|
+
'card'=>{
|
46
|
+
'type'=>'VI',
|
47
|
+
'number' =>'4100000000000001',
|
48
|
+
'expDate' =>'1210'
|
49
|
+
}}
|
50
|
+
|
51
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest .*/m),kind_of(Hash))
|
52
|
+
XMLObject.expects(:new)
|
53
|
+
|
54
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_authorization_missing_attributes
|
58
|
+
hash={
|
59
|
+
'reportGroup'=>'Planets',
|
60
|
+
'amount'=>'106',
|
61
|
+
|
62
|
+
'orderSource'=>'ecommerce',
|
63
|
+
'card'=>{
|
64
|
+
'type'=>'VI',
|
65
|
+
'number' =>'4100000000000001',
|
66
|
+
'expDate' =>'1210'
|
67
|
+
}}
|
68
|
+
|
69
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
70
|
+
assert_match /Missing Required Field: orderId!!!!/, exception.message
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_authorization_attributes
|
74
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
75
|
+
hash={
|
76
|
+
'reportGroup'=>'Planets',
|
77
|
+
'id' => '003',
|
78
|
+
'orderId'=>'12344',
|
79
|
+
'amount'=>'106',
|
80
|
+
'orderSource'=>'ecommerce',
|
81
|
+
'card'=>{
|
82
|
+
'type'=>'VI',
|
83
|
+
'number' =>'4100000000000001',
|
84
|
+
'expDate' =>'1210'
|
85
|
+
}}
|
86
|
+
|
87
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization id="003" reportGroup="Planets".*/m),kind_of(Hash))
|
88
|
+
XMLObject.expects(:new)
|
89
|
+
|
90
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_authorization_elements
|
94
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
95
|
+
hash={
|
96
|
+
'reportGroup'=>'Planets',
|
97
|
+
'id' => '004',
|
98
|
+
'orderId'=>'12344',
|
99
|
+
'amount'=>'106',
|
100
|
+
'orderSource'=>'ecommerce',
|
101
|
+
'card'=>{
|
102
|
+
'type'=>'VI',
|
103
|
+
'number' =>'4100000000000001',
|
104
|
+
'expDate' =>'1210'
|
105
|
+
}}
|
106
|
+
|
107
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<orderId>12344.*<amount>106.*<orderSource>ecommerce.*/m),kind_of(Hash))
|
108
|
+
XMLObject.expects(:new)
|
109
|
+
|
110
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_authorization_card_field
|
114
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
115
|
+
hash={
|
116
|
+
'reportGroup'=>'Planets',
|
117
|
+
'id' => '005',
|
118
|
+
'orderId'=>'12344',
|
119
|
+
'amount'=>'106',
|
120
|
+
'orderSource'=>'ecommerce',
|
121
|
+
'card'=>{
|
122
|
+
'type'=>'VI',
|
123
|
+
'number' =>'4100000000000001',
|
124
|
+
'expDate' =>'1210'
|
125
|
+
}}
|
126
|
+
|
127
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
|
128
|
+
XMLObject.expects(:new)
|
129
|
+
|
130
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_sale_card_field
|
134
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
135
|
+
hash={
|
136
|
+
'reportGroup'=>'Planets',
|
137
|
+
'id' => '006',
|
138
|
+
'orderId'=>'12344',
|
139
|
+
'amount'=>'106',
|
140
|
+
'orderSource'=>'ecommerce',
|
141
|
+
'card'=>{
|
142
|
+
'type'=>'VI',
|
143
|
+
'number' =>'4100000000000001',
|
144
|
+
'expDate' =>'1210'
|
145
|
+
}}
|
146
|
+
|
147
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*<sale.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
|
148
|
+
XMLObject.expects(:new)
|
149
|
+
|
150
|
+
response = LitleOnlineRequest.new.sale(hash)
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_capture_amountUnsetShouldNotBeInXML
|
154
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
155
|
+
hash={
|
156
|
+
'id' => '006',
|
157
|
+
'reportGroup'=>'Planets',
|
158
|
+
'litleTxnId'=>'123456789012345678',
|
159
|
+
}
|
160
|
+
|
161
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
162
|
+
XMLObject.expects(:new)
|
163
|
+
|
164
|
+
response = LitleOnlineRequest.new.capture(hash)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_force_capture_amountUnsetShouldNotBeInXML
|
168
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
169
|
+
hash={
|
170
|
+
'id' => '006',
|
171
|
+
'orderId'=>'12344',
|
172
|
+
'reportGroup'=>'Planets',
|
173
|
+
'orderSource'=>'ecommerce',
|
174
|
+
'litleTxnId'=>'123456789012345678',
|
175
|
+
}
|
176
|
+
|
177
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
178
|
+
XMLObject.expects(:new)
|
179
|
+
|
180
|
+
response = LitleOnlineRequest.new.forceCapture(hash)
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_amount_is_not_required_in_echeck_credit
|
184
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
185
|
+
hash={
|
186
|
+
'id' => '006',
|
187
|
+
'orderId'=>'12344',
|
188
|
+
'reportGroup'=>'Planets',
|
189
|
+
'orderSource'=>'ecommerce',
|
190
|
+
'litleTxnId'=>'123456789012345678',
|
191
|
+
}
|
192
|
+
|
193
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
194
|
+
XMLObject.expects(:new)
|
195
|
+
|
196
|
+
response = LitleOnlineRequest.new.echeckCredit(hash)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_amount_is_not_required_in_echeck_sale
|
200
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
201
|
+
hash={
|
202
|
+
'id' => '006',
|
203
|
+
'orderId'=>'12344',
|
204
|
+
'reportGroup'=>'Planets',
|
205
|
+
'orderSource'=>'ecommerce',
|
206
|
+
'litleTxnId'=>'123456789012345678',
|
207
|
+
}
|
208
|
+
|
209
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
210
|
+
XMLObject.expects(:new)
|
211
|
+
|
212
|
+
response = LitleOnlineRequest.new.echeckSale(hash)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_choice_between_card_token
|
216
|
+
start_hash = {
|
217
|
+
'orderId'=>'12344',
|
218
|
+
'merchantId'=>'101',
|
219
|
+
'reportGroup'=>'Planets',
|
220
|
+
'amount'=>'101',
|
221
|
+
'orderSource'=>'ecommerce'
|
222
|
+
}
|
223
|
+
|
224
|
+
card_only = {
|
225
|
+
'card' => {
|
226
|
+
'type' => 'VI',
|
227
|
+
'number' => '1111222233334444'
|
228
|
+
}
|
229
|
+
}
|
230
|
+
token_only = {
|
231
|
+
'token'=> {
|
232
|
+
'litleToken' => '1111222233334444'
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
XMLObject.expects(:new)
|
237
|
+
Communications.expects(:http_post).with(regexp_matches(/.*card.*/m))
|
238
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*token.*/m)),kind_of(Hash))
|
239
|
+
LitleOnlineRequest.new.authorization(start_hash.merge(card_only))
|
240
|
+
|
241
|
+
XMLObject.expects(:new)
|
242
|
+
Communications.expects(:http_post).with(regexp_matches(/.*token.*/m))
|
243
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*card.*/m)),kind_of(Hash))
|
244
|
+
LitleOnlineRequest.new.authorization(start_hash.merge(token_only))
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_orderId_required
|
248
|
+
start_hash = {
|
249
|
+
#'orderId'=>'12344',
|
250
|
+
'merchantId'=>'101',
|
251
|
+
'reportGroup'=>'Planets',
|
252
|
+
'amount'=>'101',
|
253
|
+
'orderSource'=>'ecommerce',
|
254
|
+
'card' => {
|
255
|
+
'type' => 'VI',
|
256
|
+
'number' => '1111222233334444'
|
257
|
+
}
|
258
|
+
}
|
259
|
+
exception = assert_raise(RuntimeError) {LitleOnlineRequest.new.authorization(start_hash)}
|
260
|
+
assert_match /Missing Required Field: orderId!!!!/, exception.message
|
261
|
+
|
262
|
+
XMLObject.expects(:new)
|
263
|
+
Communications.expects(:http_post).with(regexp_matches(/.*orderId.*/m),kind_of(Hash))
|
264
|
+
assert_nothing_raised {LitleOnlineRequest.new.authorization(start_hash.merge({'orderId'=>'1234'}))}
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_ssn_optional
|
268
|
+
start_hash = {
|
269
|
+
'orderId'=>'12344',
|
270
|
+
'merchantId'=>'101',
|
271
|
+
'reportGroup'=>'Planets',
|
272
|
+
'amount'=>'101',
|
273
|
+
'orderSource'=>'ecommerce',
|
274
|
+
'card' => {
|
275
|
+
'type' => 'VI',
|
276
|
+
'number' => '1111222233334444'
|
277
|
+
},
|
278
|
+
}
|
279
|
+
XMLObject.expects(:new)
|
280
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*ssn.*/m)),kind_of(Hash))
|
281
|
+
assert_nothing_raised {LitleOnlineRequest.new.authorization(start_hash)}
|
282
|
+
|
283
|
+
XMLObject.expects(:new)
|
284
|
+
Communications.expects(:http_post).with(regexp_matches(/.*ssn.*/m),kind_of(Hash))
|
285
|
+
assert_nothing_raised {LitleOnlineRequest.new.authorization(start_hash.merge({'customerInfo'=>{'ssn'=>'000112222'} }))}
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2012 Litle & Co.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require 'lib/LitleOnline'
|
26
|
+
require 'test/unit'
|
27
|
+
|
28
|
+
#test Authorization Transaction
|
29
|
+
class TestAuth < Test::Unit::TestCase
|
30
|
+
def test_noOrderId
|
31
|
+
hash = {
|
32
|
+
'merchantId' => '101',
|
33
|
+
'version'=>'8.8',
|
34
|
+
'reportGroup'=>'Planets',
|
35
|
+
'litleTxnId'=>'123456',
|
36
|
+
'amount'=>'106',
|
37
|
+
'orderSource'=>'ecommerce',
|
38
|
+
'card'=>{
|
39
|
+
'type'=>'VI',
|
40
|
+
'number' =>'4100000000000001',
|
41
|
+
'expDate' =>'1210'
|
42
|
+
}}
|
43
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
44
|
+
assert_match /Missing Required Field: orderId!!!!/, exception.message
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_noAmount
|
48
|
+
hash = {
|
49
|
+
'merchantId' => '101',
|
50
|
+
'version'=>'8.8',
|
51
|
+
'reportGroup'=>'Planets',
|
52
|
+
'litleTxnId'=>'123456',
|
53
|
+
'orderId'=>'12344',
|
54
|
+
'orderSource'=>'ecommerce',
|
55
|
+
'card'=>{
|
56
|
+
'type'=>'VI',
|
57
|
+
'number' =>'4100000000000001',
|
58
|
+
'expDate' =>'1210'
|
59
|
+
}}
|
60
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
61
|
+
assert_match /Missing Required Field: amount!!!!/, exception.message
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_noOrderSource
|
65
|
+
hash = {
|
66
|
+
'merchantId' => '101',
|
67
|
+
'version'=>'8.8',
|
68
|
+
'reportGroup'=>'Planets',
|
69
|
+
'litleTxnId'=>'123456',
|
70
|
+
'orderId'=>'12344',
|
71
|
+
'amount'=>'106',
|
72
|
+
'card'=>{
|
73
|
+
'type'=>'VI',
|
74
|
+
'number' =>'4100000000000001',
|
75
|
+
'expDate' =>'1210'
|
76
|
+
}}
|
77
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
78
|
+
assert_match /Missing Required Field: orderSource!!!!/, exception.message
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_BothChoicesCardandPaypal
|
82
|
+
hash = {
|
83
|
+
'merchantId' => '101',
|
84
|
+
'version'=>'8.8',
|
85
|
+
'reportGroup'=>'Planets',
|
86
|
+
'orderId'=>'12344',
|
87
|
+
'amount'=>'106',
|
88
|
+
'orderSource'=>'ecommerce',
|
89
|
+
'card'=>{
|
90
|
+
'type'=>'VI',
|
91
|
+
'number' =>'4100000000000001',
|
92
|
+
'expDate' =>'1210'
|
93
|
+
},
|
94
|
+
'paypal'=>{
|
95
|
+
'payerId'=>'1234',
|
96
|
+
'token'=>'1234',
|
97
|
+
'transactionId'=>'123456'
|
98
|
+
}}
|
99
|
+
|
100
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
101
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_threeChoicesCardandPaypageandPaypal
|
105
|
+
hash = {
|
106
|
+
'merchantId' => '101',
|
107
|
+
'version'=>'8.8',
|
108
|
+
'reportGroup'=>'Planets',
|
109
|
+
'orderId'=>'12344',
|
110
|
+
'amount'=>'106',
|
111
|
+
'orderSource'=>'ecommerce',
|
112
|
+
'card'=>{
|
113
|
+
'type'=>'VI',
|
114
|
+
'number' =>'4100000000000001',
|
115
|
+
'expDate' =>'1210'
|
116
|
+
},
|
117
|
+
'paypage'=> {
|
118
|
+
'paypageRegistrationId'=>'1234',
|
119
|
+
'expDate'=>'1210',
|
120
|
+
'cardValidationNum'=>'555',
|
121
|
+
'type'=>'VI'},
|
122
|
+
'paypal'=>{
|
123
|
+
'payerId'=>'1234',
|
124
|
+
'token'=>'1234',
|
125
|
+
'transactionId'=>'123456'
|
126
|
+
}}
|
127
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
128
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_allChoicesCardandPaypageandPaypalandToken
|
132
|
+
hash = {
|
133
|
+
'merchantId' => '101',
|
134
|
+
'version'=>'8.8',
|
135
|
+
'reportGroup'=>'Planets',
|
136
|
+
'litleTxnId'=>'123456',
|
137
|
+
'orderId'=>'12344',
|
138
|
+
'amount'=>'106',
|
139
|
+
'orderSource'=>'ecommerce',
|
140
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
141
|
+
'bypassVelocityCheckcardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
142
|
+
'card'=>{
|
143
|
+
'type'=>'VI',
|
144
|
+
'number' =>'4100000000000001',
|
145
|
+
'expDate' =>'1210'
|
146
|
+
},
|
147
|
+
'paypage'=> {
|
148
|
+
'paypageRegistrationId'=>'1234',
|
149
|
+
'expDate'=>'1210',
|
150
|
+
'cardValidationNum'=>'555',
|
151
|
+
'type'=>'VI'},
|
152
|
+
'paypal'=>{
|
153
|
+
'payerId'=>'1234',
|
154
|
+
'token'=>'1234',
|
155
|
+
'transactionId'=>'123456'},
|
156
|
+
'token'=> {
|
157
|
+
'litleToken'=>'1234',
|
158
|
+
'expDate'=>'1210',
|
159
|
+
'cardValidationNum'=>'555',
|
160
|
+
'type'=>'VI'
|
161
|
+
}}
|
162
|
+
|
163
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
|
164
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|