LitleOnline 8.18.0 → 8.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG +5 -1
- data/CHANGELOG~ +81 -0
- data/Rakefile +2 -2
- data/Rakefile~ +93 -0
- data/lib/LitleOnlineRequest.rb +2 -2
- data/lib/LitleOnlineRequest.rb~ +198 -0
- data/lib/LitleRequest.rb +3 -3
- data/lib/LitleRequest.rb~ +513 -0
- data/lib/LitleTransaction.rb +6 -4
- data/lib/LitleTransaction.rb~ +297 -0
- data/lib/XMLFields.rb +15 -3
- data/lib/XMLFields.rb~ +1380 -0
- data/test/functional/ts_all.rb~ +44 -0
- data/test/unit/test_LitleOnlineRequest.rb +3 -3
- data/test/unit/test_LitleOnlineRequest.rb~ +296 -0
- data/test/unit/test_sale.rb +3 -3
- data/test/unit/test_sale.rb~ +390 -0
- data/test/unit/test_xmlfields.rb +20 -0
- data/test/unit/test_xmlfields.rb~ +2515 -0
- metadata +107 -81
@@ -0,0 +1,44 @@
|
|
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
|
+
require 'lib/LitleOnline'
|
27
|
+
|
28
|
+
#test driver for running all tests
|
29
|
+
require_relative 'test_xmlfields'
|
30
|
+
require_relative 'test_sale'
|
31
|
+
require_relative 'test_auth'
|
32
|
+
require_relative 'test_authReversal'
|
33
|
+
require_relative 'test_credit'
|
34
|
+
require_relative 'test_token'
|
35
|
+
require_relative 'test_forceCapture'
|
36
|
+
require_relative 'test_capture'
|
37
|
+
require_relative 'test_captureGivenAuth'
|
38
|
+
require_relative 'test_echeckRedeposit'
|
39
|
+
require_relative 'test_echeckSale'
|
40
|
+
require_relative 'test_echeckCredit'
|
41
|
+
require_relative 'test_echeckVerification'
|
42
|
+
require_relative 'test_echeckVoid'
|
43
|
+
require_relative 'test_updateCardValidationNumOnToken'
|
44
|
+
|
@@ -244,7 +244,7 @@ module LitleOnline
|
|
244
244
|
#Explicit - used for integrations
|
245
245
|
assert_equal 'ActiveMerchant;3.2', litle.send(:get_merchant_sdk, {'merchantSdk'=>'ActiveMerchant;3.2'})
|
246
246
|
#Implicit - used raw when nothing is specified
|
247
|
-
assert_equal 'Ruby;8.
|
247
|
+
assert_equal 'Ruby;8.19.0', litle.send(:get_merchant_sdk, {'NotMerchantSdk'=>'ActiveMerchant;3.2'})
|
248
248
|
end
|
249
249
|
|
250
250
|
def test_sale_paypal_order_complete_typo
|
@@ -274,7 +274,7 @@ module LitleOnline
|
|
274
274
|
'litleTxnId' => '006'
|
275
275
|
}
|
276
276
|
|
277
|
-
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*version="8\.
|
277
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*version="8\.19".*/m),kind_of(Hash))
|
278
278
|
XMLObject.expects(:new)
|
279
279
|
|
280
280
|
response = LitleOnlineRequest.new.void(hash)
|
@@ -293,4 +293,4 @@ module LitleOnline
|
|
293
293
|
end
|
294
294
|
|
295
295
|
end
|
296
|
-
end
|
296
|
+
end
|
@@ -0,0 +1,296 @@
|
|
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/setup'
|
29
|
+
|
30
|
+
module LitleOnline
|
31
|
+
|
32
|
+
class TestLitleOnlineRequest < Test::Unit::TestCase
|
33
|
+
def test_set_merchant_id
|
34
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}})
|
35
|
+
litle = LitleOnlineRequest.new
|
36
|
+
assert_equal '2', litle.send(:get_merchant_id, {'merchantId'=>'2'})
|
37
|
+
assert_equal '1', litle.send(:get_merchant_id, {'NotMerchantId'=>'2'})
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_simple
|
41
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
42
|
+
hash = {
|
43
|
+
'reportGroup'=>'Planets',
|
44
|
+
'orderId'=>'12344',
|
45
|
+
'amount'=>'106',
|
46
|
+
'orderSource'=>'ecommerce',
|
47
|
+
'card'=>{
|
48
|
+
'type'=>'VI',
|
49
|
+
'number' =>'4100000000000001',
|
50
|
+
'expDate' =>'1210'
|
51
|
+
}}
|
52
|
+
|
53
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest .*/m),kind_of(Hash))
|
54
|
+
XMLObject.expects(:new)
|
55
|
+
|
56
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_authorization_attributes
|
60
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
61
|
+
hash={
|
62
|
+
'reportGroup'=>'Planets',
|
63
|
+
'id' => '003',
|
64
|
+
'orderId'=>'12344',
|
65
|
+
'amount'=>'106',
|
66
|
+
'orderSource'=>'ecommerce',
|
67
|
+
'card'=>{
|
68
|
+
'type'=>'VI',
|
69
|
+
'number' =>'4100000000000001',
|
70
|
+
'expDate' =>'1210'
|
71
|
+
}}
|
72
|
+
|
73
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization ((reportGroup="Planets" id="003")|(id="003" reportGroup="Planets")).*/m),kind_of(Hash))
|
74
|
+
XMLObject.expects(:new)
|
75
|
+
|
76
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_authorization_elements
|
80
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
81
|
+
hash={
|
82
|
+
'reportGroup'=>'Planets',
|
83
|
+
'id' => '004',
|
84
|
+
'orderId'=>'12344',
|
85
|
+
'amount'=>'106',
|
86
|
+
'orderSource'=>'ecommerce',
|
87
|
+
'card'=>{
|
88
|
+
'type'=>'VI',
|
89
|
+
'number' =>'4100000000000001',
|
90
|
+
'expDate' =>'1210'
|
91
|
+
}}
|
92
|
+
|
93
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<orderId>12344.*<amount>106.*<orderSource>ecommerce.*/m),kind_of(Hash))
|
94
|
+
XMLObject.expects(:new)
|
95
|
+
|
96
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_authorization_card_field
|
100
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
101
|
+
hash={
|
102
|
+
'reportGroup'=>'Planets',
|
103
|
+
'id' => '005',
|
104
|
+
'orderId'=>'12344',
|
105
|
+
'amount'=>'106',
|
106
|
+
'orderSource'=>'ecommerce',
|
107
|
+
'card'=>{
|
108
|
+
'type'=>'VI',
|
109
|
+
'number' =>'4100000000000001',
|
110
|
+
'expDate' =>'1210'
|
111
|
+
}}
|
112
|
+
|
113
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
|
114
|
+
XMLObject.expects(:new)
|
115
|
+
|
116
|
+
response = LitleOnlineRequest.new.authorization(hash)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_sale_card_field
|
120
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
121
|
+
hash = {
|
122
|
+
'reportGroup'=>'Planets',
|
123
|
+
'id' => '006',
|
124
|
+
'orderId'=>'12344',
|
125
|
+
'amount'=>'106',
|
126
|
+
'orderSource'=>'ecommerce',
|
127
|
+
'card'=>{
|
128
|
+
'type'=>'VI',
|
129
|
+
'number' =>'4100000000000001',
|
130
|
+
'expDate' =>'1210'
|
131
|
+
}}
|
132
|
+
|
133
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*<sale.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
|
134
|
+
XMLObject.expects(:new)
|
135
|
+
|
136
|
+
response = LitleOnlineRequest.new.sale(hash)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_capture_amount_unset_should_not_be_in_xml
|
140
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
141
|
+
hash={
|
142
|
+
'id' => '006',
|
143
|
+
'reportGroup'=>'Planets',
|
144
|
+
'litleTxnId'=>'123456789012345678'
|
145
|
+
}
|
146
|
+
|
147
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
148
|
+
XMLObject.expects(:new)
|
149
|
+
|
150
|
+
response = LitleOnlineRequest.new.capture(hash)
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_force_capture_amount_unset_should_not_be_in_xml
|
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
|
+
'orderId'=>'12344',
|
158
|
+
'reportGroup'=>'Planets',
|
159
|
+
'orderSource'=>'ecommerce',
|
160
|
+
'litleTxnId'=>'123456789012345678'
|
161
|
+
}
|
162
|
+
|
163
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
164
|
+
XMLObject.expects(:new)
|
165
|
+
|
166
|
+
response = LitleOnlineRequest.new.force_capture(hash)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_amount_is_not_required_in_echeck_credit
|
170
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
171
|
+
hash={
|
172
|
+
'id' => '006',
|
173
|
+
'orderId'=>'12344',
|
174
|
+
'reportGroup'=>'Planets',
|
175
|
+
'orderSource'=>'ecommerce',
|
176
|
+
'litleTxnId'=>'123456789012345678',
|
177
|
+
}
|
178
|
+
|
179
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
180
|
+
XMLObject.expects(:new)
|
181
|
+
|
182
|
+
response = LitleOnlineRequest.new.echeck_credit(hash)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_amount_is_not_required_in_echeck_sale
|
186
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
187
|
+
hash={
|
188
|
+
'id' => '006',
|
189
|
+
'orderId'=>'12344',
|
190
|
+
'reportGroup'=>'Planets',
|
191
|
+
'orderSource'=>'ecommerce',
|
192
|
+
'litleTxnId'=>'123456789012345678',
|
193
|
+
}
|
194
|
+
|
195
|
+
Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
|
196
|
+
XMLObject.expects(:new)
|
197
|
+
|
198
|
+
response = LitleOnlineRequest.new.echeck_sale(hash)
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_choice_between_card_token
|
202
|
+
start_hash = {
|
203
|
+
'orderId'=>'12344',
|
204
|
+
'merchantId'=>'101',
|
205
|
+
'reportGroup'=>'Planets',
|
206
|
+
'amount'=>'101',
|
207
|
+
'orderSource'=>'ecommerce'
|
208
|
+
}
|
209
|
+
|
210
|
+
card_only = {
|
211
|
+
'card' => {
|
212
|
+
'type' => 'VI',
|
213
|
+
'number' => '1111222233334444'
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
XMLObject.expects(:new)
|
218
|
+
Communications.expects(:http_post).with(regexp_matches(/.*card.*/m),kind_of(Hash))
|
219
|
+
LitleOnlineRequest.new.authorization(start_hash.merge(card_only))
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_choice_between_card_token2
|
223
|
+
start_hash = {
|
224
|
+
'orderId'=>'12344',
|
225
|
+
'merchantId'=>'101',
|
226
|
+
'reportGroup'=>'Planets',
|
227
|
+
'amount'=>'101',
|
228
|
+
'orderSource'=>'ecommerce'
|
229
|
+
}
|
230
|
+
|
231
|
+
token_only = {
|
232
|
+
'token'=> {
|
233
|
+
'litleToken' => '1111222233334444'
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
XMLObject.expects(:new)
|
238
|
+
Communications.expects(:http_post).with(regexp_matches(/.*token.*/m),kind_of(Hash))
|
239
|
+
LitleOnlineRequest.new.authorization(start_hash.merge(token_only))
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_set_merchant_sdk
|
243
|
+
litle = LitleOnlineRequest.new
|
244
|
+
#Explicit - used for integrations
|
245
|
+
assert_equal 'ActiveMerchant;3.2', litle.send(:get_merchant_sdk, {'merchantSdk'=>'ActiveMerchant;3.2'})
|
246
|
+
#Implicit - used raw when nothing is specified
|
247
|
+
assert_equal 'Ruby;8.19.0', litle.send(:get_merchant_sdk, {'NotMerchantSdk'=>'ActiveMerchant;3.2'})
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_sale_paypal_order_complete_typo
|
251
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
252
|
+
hash={
|
253
|
+
'reportGroup'=>'Planets',
|
254
|
+
'id' => '006',
|
255
|
+
'orderId'=>'12344',
|
256
|
+
'amount'=>'106',
|
257
|
+
'orderSource'=>'ecommerce',
|
258
|
+
'payPalOrderComplete'=>'true',
|
259
|
+
'card'=>{
|
260
|
+
'type'=>'VI',
|
261
|
+
'number' =>'4100000000000001',
|
262
|
+
'expDate' =>'1210'
|
263
|
+
}}
|
264
|
+
|
265
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*<sale.*<payPalOrderComplete>true<\/payPalOrderComplete>.*/m),kind_of(Hash))
|
266
|
+
XMLObject.expects(:new)
|
267
|
+
|
268
|
+
response = LitleOnlineRequest.new.sale(hash)
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_version_matches_sdk_major_and_minor_version_ignoring_config
|
272
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
273
|
+
hash={
|
274
|
+
'litleTxnId' => '006'
|
275
|
+
}
|
276
|
+
|
277
|
+
Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*version="8\.19".*/m),kind_of(Hash))
|
278
|
+
XMLObject.expects(:new)
|
279
|
+
|
280
|
+
response = LitleOnlineRequest.new.void(hash)
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_void_response_contains_recycling
|
284
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
285
|
+
hash={
|
286
|
+
'litleTxnId' => '123'
|
287
|
+
}
|
288
|
+
|
289
|
+
Communications.expects(:http_post).with(kind_of(String),kind_of(Hash)).returns('<litleOnlineResponse><voidResponse><recycling><creditLitleTxnId>65</creditLitleTxnId></recycling></voidResponse></litleOnlineResponse>')
|
290
|
+
|
291
|
+
response = LitleOnlineRequest.new.void(hash)
|
292
|
+
assert_equal '65', response.voidResponse.recycling.creditLitleTxnId
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
end
|
data/test/unit/test_sale.rb
CHANGED
@@ -326,11 +326,11 @@ module LitleOnline
|
|
326
326
|
'recurringRequest'=>{
|
327
327
|
'subscription'=>{
|
328
328
|
'planCode'=>'abc123',
|
329
|
-
'
|
329
|
+
'numberOfPayments'=>'12'
|
330
330
|
}
|
331
331
|
}
|
332
332
|
}
|
333
|
-
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><recurringRequest><subscription><planCode>abc123<\/planCode><
|
333
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><recurringRequest><subscription><planCode>abc123<\/planCode><numberOfPayments>12<\/numberOfPayments><\/subscription><\/recurringRequest>.*/m), is_a(Hash))
|
334
334
|
LitleOnlineRequest.new.sale(hash)
|
335
335
|
end
|
336
336
|
|
@@ -387,4 +387,4 @@ module LitleOnline
|
|
387
387
|
end
|
388
388
|
|
389
389
|
end
|
390
|
-
end
|
390
|
+
end
|
@@ -0,0 +1,390 @@
|
|
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
|
+
require 'mocha/setup'
|
28
|
+
|
29
|
+
module LitleOnline
|
30
|
+
class TestSale < Test::Unit::TestCase
|
31
|
+
|
32
|
+
def test_both_choices_fraud_check_and_card_holder
|
33
|
+
hash = {
|
34
|
+
'merchantId' => '101',
|
35
|
+
'version'=>'8.8',
|
36
|
+
'reportGroup'=>'Planets',
|
37
|
+
'litleTxnId'=>'123456',
|
38
|
+
'orderId'=>'12344',
|
39
|
+
'amount'=>'106',
|
40
|
+
'orderSource'=>'ecommerce',
|
41
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
42
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
43
|
+
'card'=>{
|
44
|
+
'type'=>'VI',
|
45
|
+
'number' =>'4100000000000002',
|
46
|
+
'expDate' =>'1210'
|
47
|
+
}}
|
48
|
+
|
49
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
50
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_both_choices_card_and_paypal
|
54
|
+
hash = {
|
55
|
+
'merchantId' => '101',
|
56
|
+
'version'=>'8.8',
|
57
|
+
'reportGroup'=>'Planets',
|
58
|
+
'litleTxnId'=>'123456',
|
59
|
+
'orderId'=>'12344',
|
60
|
+
'amount'=>'106',
|
61
|
+
'orderSource'=>'ecommerce',
|
62
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
63
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
64
|
+
'card'=>{
|
65
|
+
'type'=>'VI',
|
66
|
+
'number' =>'4100000000000002',
|
67
|
+
'expDate' =>'1210'
|
68
|
+
},
|
69
|
+
'paypal'=>{
|
70
|
+
'payerId'=>'1234',
|
71
|
+
'token'=>'1234',
|
72
|
+
'transactionId'=>'123456'
|
73
|
+
}}
|
74
|
+
|
75
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
76
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_both_choices_card_and_token
|
80
|
+
hash = {
|
81
|
+
'merchantId' => '101',
|
82
|
+
'version'=>'8.8',
|
83
|
+
'reportGroup'=>'Planets',
|
84
|
+
'litleTxnId'=>'123456',
|
85
|
+
'orderId'=>'12344',
|
86
|
+
'amount'=>'106',
|
87
|
+
'orderSource'=>'ecommerce',
|
88
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
89
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
90
|
+
'card'=>{
|
91
|
+
'type'=>'VI',
|
92
|
+
'number' =>'4100000000000002',
|
93
|
+
'expDate' =>'1210'
|
94
|
+
},
|
95
|
+
'token'=> {
|
96
|
+
'litleToken'=>'1234567890123',
|
97
|
+
'expDate'=>'1210',
|
98
|
+
'cardValidationNum'=>'555',
|
99
|
+
'type'=>'VI'
|
100
|
+
}}
|
101
|
+
|
102
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
103
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_both_choices_card_and_paypage
|
107
|
+
hash = {
|
108
|
+
'merchantId' => '101',
|
109
|
+
'version'=>'8.8',
|
110
|
+
'reportGroup'=>'Planets',
|
111
|
+
'litleTxnId'=>'123456',
|
112
|
+
'orderId'=>'12344',
|
113
|
+
'amount'=>'106',
|
114
|
+
'orderSource'=>'ecommerce',
|
115
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
116
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
117
|
+
'card'=>{
|
118
|
+
'type'=>'VI',
|
119
|
+
'number' =>'4100000000000002',
|
120
|
+
'expDate' =>'1210'
|
121
|
+
},
|
122
|
+
'paypage'=> {
|
123
|
+
'paypageRegistrationId'=>'1234',
|
124
|
+
'expDate'=>'1210',
|
125
|
+
'cardValidationNum'=>'555',
|
126
|
+
'type'=>'VI'
|
127
|
+
}}
|
128
|
+
|
129
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
130
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_three_choices_card_and_paypage_and_paypal
|
134
|
+
hash = {
|
135
|
+
'merchantId' => '101',
|
136
|
+
'version'=>'8.8',
|
137
|
+
'reportGroup'=>'Planets',
|
138
|
+
'litleTxnId'=>'123456',
|
139
|
+
'orderId'=>'12344',
|
140
|
+
'amount'=>'106',
|
141
|
+
'orderSource'=>'ecommerce',
|
142
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
143
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
144
|
+
'card'=>{
|
145
|
+
'type'=>'VI',
|
146
|
+
'number' =>'4100000000000002',
|
147
|
+
'expDate' =>'1210'
|
148
|
+
},
|
149
|
+
'paypage'=> {
|
150
|
+
'paypageRegistrationId'=>'1234',
|
151
|
+
'expDate'=>'1210',
|
152
|
+
'cardValidationNum'=>'555',
|
153
|
+
'type'=>'VI'},
|
154
|
+
'paypal'=>{
|
155
|
+
'payerId'=>'1234',
|
156
|
+
'token'=>'1234',
|
157
|
+
'transactionId'=>'123456'
|
158
|
+
}}
|
159
|
+
|
160
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
161
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_all_choices_card_and_paypage_and_paypal_and_token
|
165
|
+
hash = {
|
166
|
+
'merchantId' => '101',
|
167
|
+
'version'=>'8.8',
|
168
|
+
'reportGroup'=>'Planets',
|
169
|
+
'litleTxnId'=>'123456',
|
170
|
+
'orderId'=>'12344',
|
171
|
+
'amount'=>'106',
|
172
|
+
'orderSource'=>'ecommerce',
|
173
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
174
|
+
'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
175
|
+
'card'=>{
|
176
|
+
'type'=>'VI',
|
177
|
+
'number' =>'4100000000000002',
|
178
|
+
'expDate' =>'1210'
|
179
|
+
},
|
180
|
+
'paypage'=> {
|
181
|
+
'paypageRegistrationId'=>'1234',
|
182
|
+
'expDate'=>'1210',
|
183
|
+
'cardValidationNum'=>'555',
|
184
|
+
'type'=>'VI'},
|
185
|
+
'paypal'=>{
|
186
|
+
'payerId'=>'1234',
|
187
|
+
'token'=>'1234',
|
188
|
+
'transactionId'=>'123456'},
|
189
|
+
'token'=> {
|
190
|
+
'litleToken'=>'1234567890123',
|
191
|
+
'expDate'=>'1210',
|
192
|
+
'cardValidationNum'=>'555',
|
193
|
+
'type'=>'VI'
|
194
|
+
}}
|
195
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
196
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_merchant_data_sale
|
200
|
+
hash = {
|
201
|
+
'merchantId' => '101',
|
202
|
+
'version'=>'8.12',
|
203
|
+
'orderId'=>'1',
|
204
|
+
'amount'=>'0',
|
205
|
+
'orderSource'=>'ecommerce',
|
206
|
+
'reportGroup'=>'Planets',
|
207
|
+
'merchantData'=> {
|
208
|
+
'affiliate'=>'bar'
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
XMLObject.expects(:new)
|
213
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<merchantData>.*?<affiliate>bar<\/affiliate>.*?<\/merchantData>.*/m),kind_of(Hash))
|
214
|
+
LitleOnlineRequest.new.sale(hash)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_invalid_embedded_field_values
|
218
|
+
#becasue there are sub fields under fraud check that are not specified
|
219
|
+
hash = {
|
220
|
+
'merchantId' => '101',
|
221
|
+
'version'=>'8.8',
|
222
|
+
'reportGroup'=>'Planets',
|
223
|
+
'litleTxnId'=>'123456',
|
224
|
+
'orderId'=>'12344',
|
225
|
+
'amount'=>'106',
|
226
|
+
'orderSource'=>'ecommerce',
|
227
|
+
'fraudCheck'=>'one',
|
228
|
+
'cardholderAuthentication'=>'two',
|
229
|
+
'card'=>{
|
230
|
+
'type'=>'VI',
|
231
|
+
'number' =>'4100000000000000',
|
232
|
+
}}
|
233
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
234
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_fraud_filter_override
|
238
|
+
hash = {
|
239
|
+
'merchantId' => '101',
|
240
|
+
'version'=>'8.12',
|
241
|
+
'orderId'=>'1',
|
242
|
+
'amount'=>'0',
|
243
|
+
'orderSource'=>'ecommerce',
|
244
|
+
'reportGroup'=>'Planets',
|
245
|
+
'fraudFilterOverride'=> 'false'
|
246
|
+
}
|
247
|
+
|
248
|
+
XMLObject.expects(:new)
|
249
|
+
Communications.expects(:http_post).with(regexp_matches(/.*<sale.*?<fraudFilterOverride>false<\/fraudFilterOverride>.*?<\/sale>.*/m),kind_of(Hash))
|
250
|
+
LitleOnlineRequest.new.sale(hash)
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_illegal_card_type
|
254
|
+
hash = {
|
255
|
+
'merchantId' => '101',
|
256
|
+
'version'=>'8.8',
|
257
|
+
'reportGroup'=>'Planets',
|
258
|
+
'litleTxnId'=>'123456',
|
259
|
+
'orderId'=>'12344',
|
260
|
+
'amount'=>'106',
|
261
|
+
'orderSource'=>'ecommerce',
|
262
|
+
'card'=>{
|
263
|
+
'type'=>'NO',
|
264
|
+
'number' =>'4100000000000002',
|
265
|
+
'expDate' =>'1210'
|
266
|
+
}}
|
267
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
|
268
|
+
assert_match /If card type is specified, it must be in /, exception.message
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_logged_in_user
|
272
|
+
hash = {
|
273
|
+
'loggedInUser' => 'gdake',
|
274
|
+
'merchantSdk' => 'Ruby;8.14.0',
|
275
|
+
'merchantId' => '101',
|
276
|
+
'version'=>'8.8',
|
277
|
+
'reportGroup'=>'Planets',
|
278
|
+
'litleTxnId'=>'123456',
|
279
|
+
'orderId'=>'12344',
|
280
|
+
'amount'=>'106',
|
281
|
+
'orderSource'=>'ecommerce',
|
282
|
+
'card'=>{
|
283
|
+
'type'=>'VI',
|
284
|
+
'number' =>'4100000000000002',
|
285
|
+
'expDate' =>'1210'
|
286
|
+
}}
|
287
|
+
|
288
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
289
|
+
LitleOnlineRequest.new.sale(hash)
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_surcharge_amount
|
293
|
+
hash = {
|
294
|
+
'orderId' => '12344',
|
295
|
+
'amount' => '2',
|
296
|
+
'surchargeAmount' => '1',
|
297
|
+
'orderSource' => 'ecommerce',
|
298
|
+
'reportGroup' => 'Planets'
|
299
|
+
}
|
300
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
301
|
+
LitleOnlineRequest.new.sale(hash)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_surcharge_amount_optional
|
305
|
+
hash = {
|
306
|
+
'orderId' => '12344',
|
307
|
+
'amount' => '2',
|
308
|
+
'orderSource' => 'ecommerce',
|
309
|
+
'reportGroup' => 'Planets'
|
310
|
+
}
|
311
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
312
|
+
LitleOnlineRequest.new.sale(hash)
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_recurringRequest
|
316
|
+
hash = {
|
317
|
+
'card'=>{
|
318
|
+
'type'=>'VI',
|
319
|
+
'number'=>'4100000000000001',
|
320
|
+
'expDate'=>'1213',
|
321
|
+
},
|
322
|
+
'orderId'=>'12344',
|
323
|
+
'amount'=>'2',
|
324
|
+
'orderSource'=>'ecommerce',
|
325
|
+
'fraudFilterOverride'=>'true',
|
326
|
+
'recurringRequest'=>{
|
327
|
+
'subscription'=>{
|
328
|
+
'planCode'=>'abc123',
|
329
|
+
'numberOfPaymentsRemaining'=>'12'
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}
|
333
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><recurringRequest><subscription><planCode>abc123<\/planCode><numberOfPaymentsRemaining>12<\/numberOfPaymentsRemaining><\/subscription><\/recurringRequest>.*/m), is_a(Hash))
|
334
|
+
LitleOnlineRequest.new.sale(hash)
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_recurringRequest_optional
|
338
|
+
hash = {
|
339
|
+
'card'=>{
|
340
|
+
'type'=>'VI',
|
341
|
+
'number'=>'4100000000000001',
|
342
|
+
'expDate'=>'1213',
|
343
|
+
},
|
344
|
+
'orderId'=>'12344',
|
345
|
+
'amount'=>'2',
|
346
|
+
'orderSource'=>'ecommerce',
|
347
|
+
'fraudFilterOverride'=>'true',
|
348
|
+
}
|
349
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><\/sale>.*/m), is_a(Hash))
|
350
|
+
LitleOnlineRequest.new.sale(hash)
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_litleInternalRecurringRequest
|
354
|
+
hash = {
|
355
|
+
'card'=>{
|
356
|
+
'type'=>'VI',
|
357
|
+
'number'=>'4100000000000001',
|
358
|
+
'expDate'=>'1213',
|
359
|
+
},
|
360
|
+
'orderId'=>'12344',
|
361
|
+
'amount'=>'2',
|
362
|
+
'orderSource'=>'ecommerce',
|
363
|
+
'fraudFilterOverride'=>'true',
|
364
|
+
'litleInternalRecurringRequest'=>{
|
365
|
+
'subscriptionId'=>'1234567890123456789',
|
366
|
+
'recurringTxnId'=>'1234567890123456789',
|
367
|
+
},
|
368
|
+
}
|
369
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><litleInternalRecurringRequest><subscriptionId>1234567890123456789<\/subscriptionId><recurringTxnId>1234567890123456789<\/recurringTxnId><\/litleInternalRecurringRequest>.*/m), is_a(Hash))
|
370
|
+
LitleOnlineRequest.new.sale(hash)
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_litleInternalRecurringRequest_optional
|
374
|
+
hash = {
|
375
|
+
'card'=>{
|
376
|
+
'type'=>'VI',
|
377
|
+
'number'=>'4100000000000001',
|
378
|
+
'expDate'=>'1213',
|
379
|
+
},
|
380
|
+
'orderId'=>'12344',
|
381
|
+
'amount'=>'2',
|
382
|
+
'orderSource'=>'ecommerce',
|
383
|
+
'fraudFilterOverride'=>'true',
|
384
|
+
}
|
385
|
+
LitleXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><\/sale>.*/m), is_a(Hash))
|
386
|
+
LitleOnlineRequest.new.sale(hash)
|
387
|
+
end
|
388
|
+
|
389
|
+
end
|
390
|
+
end
|