LitleOnline 9.3.0 → 9.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +5 -2
- data/Rakefile +1 -1
- data/lib/Communications.rb +1 -1
- data/lib/LitleBatchRequest.rb +268 -150
- data/lib/LitleListeners.rb +119 -44
- data/lib/LitleOnlineRequest.rb +1 -1
- data/lib/LitleTransaction.rb +219 -112
- data/lib/XMLFields.rb +166 -18
- data/test/certification/certTest_batchAll.rb +282 -68
- data/test/unit/test_LitleAUBatch.rb +28 -0
- data/test/unit/test_LitleBatchRequest.rb +243 -109
- data/test/unit/test_LitleOnlineRequest.rb +1 -1
- metadata +2 -2
@@ -212,5 +212,33 @@ module LitleOnline
|
|
212
212
|
|
213
213
|
assert_equal 5, counts[:numAccountUpdates]
|
214
214
|
end
|
215
|
+
|
216
|
+
def test_AU_batch_with_token
|
217
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
218
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(7)
|
219
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').at_most(5)
|
220
|
+
File.expects(:rename).once
|
221
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once
|
222
|
+
File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
|
223
|
+
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
224
|
+
File.expects(:directory?).returns(false).once
|
225
|
+
|
226
|
+
batch = LitleAUBatch.new
|
227
|
+
batch.create_new_batch('/usr/local/Batches/')
|
228
|
+
|
229
|
+
accountUpdateHash = {
|
230
|
+
'reportGroup'=>'Planets',
|
231
|
+
'id'=>'12345',
|
232
|
+
'customerId'=>'0987',
|
233
|
+
'token'=>{'litleToken'=>'1234567890123'
|
234
|
+
}}
|
235
|
+
|
236
|
+
5.times(){ batch.account_update(accountUpdateHash ) }
|
237
|
+
|
238
|
+
batch.close_batch()
|
239
|
+
counts = batch.get_counts_and_amounts
|
240
|
+
|
241
|
+
assert_equal 5, counts[:numAccountUpdates]
|
242
|
+
end
|
215
243
|
end
|
216
244
|
end
|
@@ -22,25 +22,22 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
22
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
|
-
require File.expand_path("../../../lib/LitleOnline",__FILE__)
|
26
|
-
|
25
|
+
require File.expand_path("../../../lib/LitleOnline",__FILE__)
|
27
26
|
require 'test/unit'
|
28
27
|
require 'mocha/setup'
|
29
28
|
|
30
29
|
module LitleOnline
|
31
|
-
|
32
30
|
class TestLitleBatchRequest < Test::Unit::TestCase
|
33
31
|
def test_create_new_batch
|
34
32
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
35
33
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').twice
|
36
34
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
37
35
|
File.expects(:directory?).returns(false).once
|
38
|
-
|
36
|
+
|
39
37
|
batch = LitleBatchRequest.new
|
40
38
|
batch.create_new_batch('/usr/local/Batches/')
|
41
39
|
end
|
42
|
-
|
43
|
-
|
40
|
+
|
44
41
|
def test_add_authorization
|
45
42
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
46
43
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
@@ -57,25 +54,25 @@ module LitleOnline
|
|
57
54
|
'type'=>'VI',
|
58
55
|
'number' =>'4100000000000001',
|
59
56
|
'expDate' =>'1210'
|
60
|
-
|
61
|
-
|
57
|
+
}}
|
58
|
+
|
62
59
|
batch = LitleBatchRequest.new
|
63
60
|
batch.create_new_batch('/usr/local/Batches/')
|
64
|
-
|
61
|
+
|
65
62
|
2.times(){ batch.authorization(authHash) }
|
66
63
|
counts = batch.get_counts_and_amounts
|
67
|
-
|
64
|
+
|
68
65
|
assert_equal 2, counts[:auth][:numAuths]
|
69
66
|
assert_equal 212, counts[:auth][:authAmount]
|
70
|
-
end
|
71
|
-
|
67
|
+
end
|
68
|
+
|
72
69
|
def test_add_sale
|
73
70
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
74
71
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
75
72
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
76
73
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
77
74
|
File.expects(:directory?).returns(true).once
|
78
|
-
|
75
|
+
|
79
76
|
saleHash = {
|
80
77
|
'reportGroup'=>'Planets',
|
81
78
|
'id' => '006',
|
@@ -86,24 +83,24 @@ module LitleOnline
|
|
86
83
|
'type'=>'VI',
|
87
84
|
'number' =>'4100000000000001',
|
88
85
|
'expDate' =>'1210'
|
89
|
-
|
90
|
-
|
86
|
+
}}
|
87
|
+
|
91
88
|
batch = LitleBatchRequest.new
|
92
89
|
batch.create_new_batch('D:\Batches\\')
|
93
90
|
batch.sale(saleHash)
|
94
|
-
|
91
|
+
|
95
92
|
counts = batch.get_counts_and_amounts
|
96
93
|
assert_equal 1, counts[:sale][:numSales]
|
97
94
|
assert_equal 6000, counts[:sale][:saleAmount]
|
98
95
|
end
|
99
|
-
|
96
|
+
|
100
97
|
def test_add_credit
|
101
98
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
102
99
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
103
100
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
104
101
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
105
102
|
File.expects(:directory?).returns(true).once
|
106
|
-
|
103
|
+
|
107
104
|
creditHash = {
|
108
105
|
'merchantId' => '101',
|
109
106
|
'version'=>'8.8',
|
@@ -116,23 +113,23 @@ module LitleOnline
|
|
116
113
|
'number' =>'4100000000000001',
|
117
114
|
'expDate' =>'1210'
|
118
115
|
}}
|
119
|
-
|
116
|
+
|
120
117
|
batch = LitleBatchRequest.new
|
121
118
|
batch.create_new_batch('D:\Batches\\')
|
122
119
|
batch.credit(creditHash)
|
123
|
-
|
120
|
+
|
124
121
|
counts = batch.get_counts_and_amounts
|
125
122
|
assert_equal 1, counts[:credit][:numCredits]
|
126
123
|
assert_equal 106, counts[:credit][:creditAmount]
|
127
124
|
end
|
128
|
-
|
125
|
+
|
129
126
|
def test_add_auth_reversal
|
130
127
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
131
128
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
132
129
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
133
130
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
134
131
|
File.expects(:directory?).returns(true).once
|
135
|
-
|
132
|
+
|
136
133
|
authReversalHash = {
|
137
134
|
'merchantId' => '101',
|
138
135
|
'version'=>'8.8',
|
@@ -140,24 +137,24 @@ module LitleOnline
|
|
140
137
|
'litleTxnId'=>'12345678000',
|
141
138
|
'amount'=>'106',
|
142
139
|
'payPalNotes'=>'Notes'
|
143
|
-
|
144
|
-
|
140
|
+
}
|
141
|
+
|
145
142
|
batch = LitleBatchRequest.new
|
146
143
|
batch.create_new_batch('D:\Batches\\')
|
147
144
|
batch.auth_reversal(authReversalHash)
|
148
|
-
|
145
|
+
|
149
146
|
counts = batch.get_counts_and_amounts
|
150
147
|
assert_equal 1, counts[:authReversal][:numAuthReversals]
|
151
148
|
assert_equal 106, counts[:authReversal][:authReversalAmount]
|
152
149
|
end
|
153
|
-
|
150
|
+
|
154
151
|
def test_add_register_token_request
|
155
152
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
156
153
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
157
154
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
158
155
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
159
156
|
File.expects(:directory?).returns(true).once
|
160
|
-
|
157
|
+
|
161
158
|
registerTokenHash = {
|
162
159
|
'merchantId' => '101',
|
163
160
|
'version'=>'8.8',
|
@@ -165,11 +162,11 @@ module LitleOnline
|
|
165
162
|
'orderId'=>'12344',
|
166
163
|
'accountNumber'=>'1233456789103801'
|
167
164
|
}
|
168
|
-
|
165
|
+
|
169
166
|
batch = LitleBatchRequest.new
|
170
167
|
batch.create_new_batch('D:\Batches\\')
|
171
168
|
batch.register_token_request(registerTokenHash)
|
172
|
-
|
169
|
+
|
173
170
|
counts = batch.get_counts_and_amounts
|
174
171
|
assert_equal 1, counts[:numTokenRegistrations]
|
175
172
|
end
|
@@ -180,18 +177,18 @@ module LitleOnline
|
|
180
177
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
181
178
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
182
179
|
File.expects(:directory?).returns(true).once
|
183
|
-
|
180
|
+
|
184
181
|
hash = {
|
185
182
|
'merchantId' => '101',
|
186
183
|
'version'=>'8.8',
|
187
184
|
'reportGroup'=>'Planets',
|
188
185
|
'subscriptionId'=>'100'
|
189
|
-
|
186
|
+
}
|
190
187
|
|
191
188
|
batch = LitleBatchRequest.new
|
192
189
|
batch.create_new_batch('D:\Batches\\')
|
193
190
|
batch.cancel_subscription(hash)
|
194
|
-
|
191
|
+
|
195
192
|
counts = batch.get_counts_and_amounts
|
196
193
|
assert_equal 1, counts[:numCancelSubscriptions]
|
197
194
|
end
|
@@ -202,30 +199,31 @@ module LitleOnline
|
|
202
199
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
203
200
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
204
201
|
File.expects(:directory?).returns(true).once
|
205
|
-
|
202
|
+
|
206
203
|
hash = {
|
207
204
|
'merchantId' => '101',
|
208
205
|
'version'=>'8.8',
|
209
206
|
'reportGroup'=>'Planets',
|
210
207
|
'subscriptionId'=>'100',
|
211
|
-
|
208
|
+
'planCode'=>'planCodeString',
|
212
209
|
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
|
213
|
-
|
210
|
+
}
|
214
211
|
|
215
212
|
batch = LitleBatchRequest.new
|
216
213
|
batch.create_new_batch('D:\Batches\\')
|
217
214
|
batch.update_subscription(hash)
|
218
|
-
|
215
|
+
|
219
216
|
counts = batch.get_counts_and_amounts
|
220
217
|
assert_equal 1, counts[:numUpdateSubscriptions]
|
221
218
|
end
|
219
|
+
|
222
220
|
def test_add_update_card_validation_num_on_token
|
223
221
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
224
222
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
225
223
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
226
224
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
227
225
|
File.expects(:directory?).returns(true).once
|
228
|
-
|
226
|
+
|
229
227
|
updateCardHash = {
|
230
228
|
'merchantId' => '101',
|
231
229
|
'version'=>'8.8',
|
@@ -234,22 +232,22 @@ module LitleOnline
|
|
234
232
|
'litleToken'=>'1233456789103801',
|
235
233
|
'cardValidationNum'=>'123'
|
236
234
|
}
|
237
|
-
|
235
|
+
|
238
236
|
batch = LitleBatchRequest.new
|
239
237
|
batch.create_new_batch('D:\Batches\\')
|
240
238
|
batch.update_card_validation_num_on_token(updateCardHash)
|
241
|
-
|
239
|
+
|
242
240
|
counts = batch.get_counts_and_amounts
|
243
241
|
assert_equal 1, counts[:numUpdateCardValidationNumOnTokens]
|
244
242
|
end
|
245
|
-
|
243
|
+
|
246
244
|
def test_add_force_capture
|
247
245
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
248
246
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
249
247
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
250
248
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
251
249
|
File.expects(:directory?).returns(true).once
|
252
|
-
|
250
|
+
|
253
251
|
forceCaptHash = {
|
254
252
|
'merchantId' => '101',
|
255
253
|
'version'=>'8.8',
|
@@ -263,23 +261,23 @@ module LitleOnline
|
|
263
261
|
'number' =>'4100000000000001',
|
264
262
|
'expDate' =>'1210'
|
265
263
|
}}
|
266
|
-
|
264
|
+
|
267
265
|
batch = LitleBatchRequest.new
|
268
266
|
batch.create_new_batch('D:\Batches\\')
|
269
267
|
batch.force_capture(forceCaptHash)
|
270
|
-
|
268
|
+
|
271
269
|
counts = batch.get_counts_and_amounts
|
272
270
|
assert_equal 1, counts[:forceCapture][:numForceCaptures]
|
273
271
|
assert_equal 106, counts[:forceCapture][:forceCaptureAmount]
|
274
272
|
end
|
275
|
-
|
273
|
+
|
276
274
|
def test_add_capture
|
277
275
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
278
276
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
279
277
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
280
278
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
281
279
|
File.expects(:directory?).returns(true).once
|
282
|
-
|
280
|
+
|
283
281
|
captHash = {
|
284
282
|
'merchantId' => '101',
|
285
283
|
'version'=>'8.8',
|
@@ -287,23 +285,23 @@ module LitleOnline
|
|
287
285
|
'litleTxnId'=>'123456000',
|
288
286
|
'amount'=>'106',
|
289
287
|
}
|
290
|
-
|
288
|
+
|
291
289
|
batch = LitleBatchRequest.new
|
292
290
|
batch.create_new_batch('D:\Batches\\')
|
293
291
|
batch.capture(captHash)
|
294
|
-
|
292
|
+
|
295
293
|
counts = batch.get_counts_and_amounts
|
296
294
|
assert_equal 1, counts[:capture][:numCaptures]
|
297
295
|
assert_equal 106, counts[:capture][:captureAmount]
|
298
296
|
end
|
299
|
-
|
297
|
+
|
300
298
|
def test_add_capture_given_auth
|
301
299
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
302
300
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
303
301
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
304
302
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
305
303
|
File.expects(:directory?).returns(true).once
|
306
|
-
|
304
|
+
|
307
305
|
captGivenAuthHash = {
|
308
306
|
'merchantId' => '101',
|
309
307
|
'version'=>'8.8',
|
@@ -320,23 +318,23 @@ module LitleOnline
|
|
320
318
|
'number' =>'4100000000000000',
|
321
319
|
'expDate' =>'1210'
|
322
320
|
}}
|
323
|
-
|
321
|
+
|
324
322
|
batch = LitleBatchRequest.new
|
325
323
|
batch.create_new_batch('D:\Batches\\')
|
326
324
|
batch.capture_given_auth(captGivenAuthHash)
|
327
|
-
|
325
|
+
|
328
326
|
counts = batch.get_counts_and_amounts
|
329
327
|
assert_equal 1, counts[:captureGivenAuth][:numCaptureGivenAuths]
|
330
328
|
assert_equal 106, counts[:captureGivenAuth][:captureGivenAuthAmount]
|
331
329
|
end
|
332
|
-
|
330
|
+
|
333
331
|
def test_add_echeck_verification
|
334
332
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
335
333
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
336
334
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
337
335
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
338
336
|
File.expects(:directory?).returns(true).once
|
339
|
-
|
337
|
+
|
340
338
|
echeckVerificationHash = {
|
341
339
|
'merchantId' => '101',
|
342
340
|
'version'=>'8.8',
|
@@ -347,23 +345,23 @@ module LitleOnline
|
|
347
345
|
'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
|
348
346
|
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
|
349
347
|
}
|
350
|
-
|
348
|
+
|
351
349
|
batch = LitleBatchRequest.new
|
352
350
|
batch.create_new_batch('D:\Batches\\')
|
353
351
|
batch.echeck_verification(echeckVerificationHash)
|
354
|
-
|
352
|
+
|
355
353
|
counts = batch.get_counts_and_amounts
|
356
354
|
assert_equal 1, counts[:echeckVerification][:numEcheckVerification]
|
357
355
|
assert_equal 123456, counts[:echeckVerification][:echeckVerificationAmount]
|
358
356
|
end
|
359
|
-
|
357
|
+
|
360
358
|
def test_add_echeck_credit
|
361
359
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
362
360
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
363
361
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
364
362
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
365
363
|
File.expects(:directory?).returns(true).once
|
366
|
-
|
364
|
+
|
367
365
|
echeckCreditHash = {
|
368
366
|
'merchantId' => '101',
|
369
367
|
'version'=>'8.8',
|
@@ -371,45 +369,45 @@ module LitleOnline
|
|
371
369
|
'litleTxnId'=>'123456789101112',
|
372
370
|
'amount'=>'12'
|
373
371
|
}
|
374
|
-
|
372
|
+
|
375
373
|
batch = LitleBatchRequest.new
|
376
374
|
batch.create_new_batch('D:\Batches\\')
|
377
375
|
batch.echeck_credit(echeckCreditHash)
|
378
|
-
|
376
|
+
|
379
377
|
counts = batch.get_counts_and_amounts
|
380
378
|
assert_equal 1, counts[:echeckCredit][:numEcheckCredit]
|
381
379
|
assert_equal 12, counts[:echeckCredit][:echeckCreditAmount]
|
382
380
|
end
|
383
|
-
|
381
|
+
|
384
382
|
def test_add_echeck_redeposit
|
385
383
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
386
384
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
387
385
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
388
386
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
389
387
|
File.expects(:directory?).returns(true).once
|
390
|
-
|
388
|
+
|
391
389
|
echeckRedeopsitHash = {
|
392
390
|
'merchantId' => '101',
|
393
391
|
'version'=>'8.8',
|
394
392
|
'reportGroup'=>'Planets',
|
395
393
|
'litleTxnId'=>'123456'
|
396
394
|
}
|
397
|
-
|
395
|
+
|
398
396
|
batch = LitleBatchRequest.new
|
399
397
|
batch.create_new_batch('D:\Batches\\')
|
400
398
|
batch.echeck_redeposit(echeckRedeopsitHash)
|
401
|
-
|
399
|
+
|
402
400
|
counts = batch.get_counts_and_amounts
|
403
401
|
assert_equal 1, counts[:numEcheckRedeposit]
|
404
402
|
end
|
405
|
-
|
403
|
+
|
406
404
|
def test_add_echeck_sale
|
407
405
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
408
406
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
409
407
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
410
408
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
411
409
|
File.expects(:directory?).returns(true).once
|
412
|
-
|
410
|
+
|
413
411
|
echeckSaleHash = {
|
414
412
|
'merchantId' => '101',
|
415
413
|
'version'=>'8.8',
|
@@ -421,16 +419,16 @@ module LitleOnline
|
|
421
419
|
'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
|
422
420
|
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
|
423
421
|
}
|
424
|
-
|
422
|
+
|
425
423
|
batch = LitleBatchRequest.new
|
426
424
|
batch.create_new_batch('D:\Batches\\')
|
427
425
|
batch.echeck_sale(echeckSaleHash)
|
428
|
-
|
426
|
+
|
429
427
|
counts = batch.get_counts_and_amounts
|
430
428
|
assert_equal 1, counts[:echeckSale][:numEcheckSales]
|
431
429
|
assert_equal 123456, counts[:echeckSale][:echeckSalesAmount]
|
432
430
|
end
|
433
|
-
|
431
|
+
|
434
432
|
def test_close_batch
|
435
433
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
436
434
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
@@ -440,7 +438,7 @@ module LitleOnline
|
|
440
438
|
File.expects(:rename).once
|
441
439
|
File.expects(:delete).once
|
442
440
|
File.expects(:directory?).returns(true).once
|
443
|
-
|
441
|
+
|
444
442
|
saleHash = {
|
445
443
|
'reportGroup'=>'Planets',
|
446
444
|
'id' => '006',
|
@@ -451,17 +449,17 @@ module LitleOnline
|
|
451
449
|
'type'=>'VI',
|
452
450
|
'number' =>'4100000000000001',
|
453
451
|
'expDate' =>'1210'
|
454
|
-
|
452
|
+
}}
|
455
453
|
|
456
454
|
batch = LitleBatchRequest.new
|
457
|
-
batch.create_new_batch('D:\Batches\\')
|
455
|
+
batch.create_new_batch('D:\Batches\\')
|
458
456
|
|
459
457
|
batch.sale(saleHash)
|
460
458
|
batch.close_batch()
|
461
|
-
end
|
462
|
-
|
459
|
+
end
|
460
|
+
|
463
461
|
def test_open_existing_batch
|
464
|
-
|
462
|
+
|
465
463
|
saleHash = {
|
466
464
|
'reportGroup'=>'Planets',
|
467
465
|
'id' => '006',
|
@@ -472,20 +470,18 @@ module LitleOnline
|
|
472
470
|
'type'=>'VI',
|
473
471
|
'number' =>'4100000000000001',
|
474
472
|
'expDate' =>'1210'
|
475
|
-
|
476
|
-
|
473
|
+
}}
|
474
|
+
|
477
475
|
open = sequence('open')
|
478
476
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(2).in_sequence(open)
|
479
|
-
|
477
|
+
|
480
478
|
File.expects(:file?).returns(false).once.in_sequence(open)
|
481
479
|
File.expects(:directory?).returns(true).in_sequence(open)
|
482
480
|
File.expects(:file?).returns(false).in_sequence(open)
|
483
481
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(open)
|
484
482
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(open)
|
485
483
|
File.expects(:file?).returns(true).in_sequence(open)
|
486
|
-
|
487
|
-
|
488
|
-
|
484
|
+
|
489
485
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'rb').returns({:numAccountUpdates => 0}).once.in_sequence(open)
|
490
486
|
File.expects(:rename).once.in_sequence(open)
|
491
487
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once.in_sequence(open)
|
@@ -497,7 +493,7 @@ module LitleOnline
|
|
497
493
|
batch2.open_existing_batch(batch1.get_batch_name)
|
498
494
|
batch2.close_batch()
|
499
495
|
end
|
500
|
-
|
496
|
+
|
501
497
|
def test_build_batch_header
|
502
498
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
503
499
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
@@ -506,29 +502,29 @@ module LitleOnline
|
|
506
502
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'w').once
|
507
503
|
File.expects(:delete).once
|
508
504
|
File.expects(:directory?).returns(true).once
|
509
|
-
|
505
|
+
|
510
506
|
batch = LitleBatchRequest.new
|
511
507
|
batch.get_counts_and_amounts.expects(:[]).returns(hash = Hash.new).at_least(25)
|
512
508
|
hash.expects(:[]).returns('a').at_least(20)
|
513
|
-
|
509
|
+
|
514
510
|
batch.create_new_batch('/usr/local/Batches')
|
515
511
|
batch.close_batch()
|
516
512
|
end
|
517
|
-
|
513
|
+
|
518
514
|
def test_create_new_batch_missing_separator
|
519
515
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
520
516
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
521
517
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').once
|
522
|
-
|
518
|
+
|
523
519
|
batch = LitleBatchRequest.new
|
524
520
|
batch.create_new_batch('/usr/local')
|
525
|
-
|
521
|
+
|
526
522
|
assert batch.get_batch_name.include?('/usr/local/')
|
527
523
|
end
|
528
|
-
|
524
|
+
|
529
525
|
def test_create_new_batch_name_collision
|
530
526
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
531
|
-
|
527
|
+
|
532
528
|
fileExists = sequence('fileExists')
|
533
529
|
File.expects(:file?).with(regexp_matches(/.*\/usr\/local\//)).returns(false).in_sequence(fileExists)
|
534
530
|
File.expects(:file?).with(regexp_matches(/.*batch_.*\d.*/)).returns(true).in_sequence(fileExists)
|
@@ -536,33 +532,32 @@ module LitleOnline
|
|
536
532
|
File.expects(:file?).with(regexp_matches(/.*batch_.*\d.*/)).returns(false).in_sequence(fileExists)
|
537
533
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(fileExists)
|
538
534
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(fileExists)
|
539
|
-
|
540
|
-
|
535
|
+
|
541
536
|
batch = LitleBatchRequest.new
|
542
537
|
batch.create_new_batch('/usr/local/')
|
543
538
|
end
|
544
|
-
|
539
|
+
|
545
540
|
def test_create_new_batch_when_full
|
546
541
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
547
|
-
|
542
|
+
|
548
543
|
batch = LitleBatchRequest.new
|
549
544
|
addTxn = sequence('addTxn')
|
550
|
-
|
545
|
+
|
551
546
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(addTxn)
|
552
547
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(addTxn)
|
553
548
|
batch.create_new_batch('/usr/local')
|
554
|
-
|
549
|
+
|
555
550
|
batch.get_counts_and_amounts.expects(:[]).with(:sale).returns({:numSales => 10, :saleAmount => 20}).twice.in_sequence(addTxn)
|
556
551
|
batch.get_counts_and_amounts.expects(:[]).with(:total).returns(499999).in_sequence(addTxn)
|
557
|
-
|
552
|
+
|
558
553
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(addTxn)
|
559
554
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').in_sequence(addTxn)
|
560
555
|
batch.get_counts_and_amounts.expects(:[]).with(:total).returns(100000).in_sequence(addTxn)
|
561
|
-
|
556
|
+
|
562
557
|
batch.expects(:close_batch).once.in_sequence(addTxn)
|
563
558
|
batch.expects(:initialize).once.in_sequence(addTxn)
|
564
559
|
batch.expects(:create_new_batch).once.in_sequence(addTxn)
|
565
|
-
|
560
|
+
|
566
561
|
saleHash = {
|
567
562
|
'reportGroup'=>'Planets',
|
568
563
|
'id' => '006',
|
@@ -573,12 +568,12 @@ module LitleOnline
|
|
573
568
|
'type'=>'VI',
|
574
569
|
'number' =>'4100000000000001',
|
575
570
|
'expDate' =>'1210'
|
576
|
-
|
577
|
-
|
571
|
+
}}
|
572
|
+
|
578
573
|
batch.sale(saleHash)
|
579
|
-
|
574
|
+
|
580
575
|
end
|
581
|
-
|
576
|
+
|
582
577
|
def test_complete_batch
|
583
578
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
584
579
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(9)
|
@@ -588,7 +583,7 @@ module LitleOnline
|
|
588
583
|
File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
|
589
584
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
590
585
|
File.expects(:directory?).returns(false).once
|
591
|
-
|
586
|
+
|
592
587
|
authHash = {
|
593
588
|
'reportGroup'=>'Planets',
|
594
589
|
'orderId'=>'12344',
|
@@ -598,8 +593,8 @@ module LitleOnline
|
|
598
593
|
'type'=>'VI',
|
599
594
|
'number' =>'4100000000000001',
|
600
595
|
'expDate' =>'1210'
|
601
|
-
|
602
|
-
|
596
|
+
}}
|
597
|
+
|
603
598
|
saleHash = {
|
604
599
|
'reportGroup'=>'Planets',
|
605
600
|
'id' => '006',
|
@@ -610,8 +605,8 @@ module LitleOnline
|
|
610
605
|
'type'=>'VI',
|
611
606
|
'number' =>'4100000000000001',
|
612
607
|
'expDate' =>'1210'
|
613
|
-
|
614
|
-
|
608
|
+
}}
|
609
|
+
|
615
610
|
updateCardHash = {
|
616
611
|
'merchantId' => '101',
|
617
612
|
'version'=>'8.8',
|
@@ -622,10 +617,10 @@ module LitleOnline
|
|
622
617
|
'litleToken'=>'1233456789103801',
|
623
618
|
'cardValidationNum'=>'123'
|
624
619
|
}
|
625
|
-
|
620
|
+
|
626
621
|
batch = LitleBatchRequest.new
|
627
622
|
batch.create_new_batch('/usr/local/Batches/')
|
628
|
-
|
623
|
+
|
629
624
|
5.times(){ batch.authorization(authHash) }
|
630
625
|
2.times(){ batch.sale(saleHash) }
|
631
626
|
|
@@ -633,11 +628,150 @@ module LitleOnline
|
|
633
628
|
#puts "PID: " + pid.to_s + " size: " + size.to_s
|
634
629
|
batch.close_batch()
|
635
630
|
counts = batch.get_counts_and_amounts
|
636
|
-
|
631
|
+
|
637
632
|
assert_equal 5, counts[:auth][:numAuths]
|
638
633
|
#assert_equal 212, counts[:auth][:authAmount]
|
639
634
|
assert_equal 2, counts[:sale][:numSales]
|
640
635
|
#assert_equal 6000, counts[:sale][:saleAmount]
|
641
636
|
end
|
637
|
+
|
638
|
+
def test_PFIF_instruction_txn
|
639
|
+
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'9.3'}).once
|
640
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(12)
|
641
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').at_most(10)
|
642
|
+
File.expects(:rename).once
|
643
|
+
File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once
|
644
|
+
File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
|
645
|
+
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
646
|
+
File.expects(:directory?).returns(false).once
|
647
|
+
|
648
|
+
submerchantCreditHash = {
|
649
|
+
'reportGroup'=>'Planets',
|
650
|
+
'orderId'=>'12344',
|
651
|
+
'fundingSubmerchantId'=>'123456',
|
652
|
+
'submerchantName'=>'001',
|
653
|
+
'fundsTransferId'=>'1234567',
|
654
|
+
'amount'=>'106',
|
655
|
+
'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
|
656
|
+
}
|
657
|
+
|
658
|
+
vendorCreditHash = {
|
659
|
+
'reportGroup'=>'Planets',
|
660
|
+
'orderId'=>'12344',
|
661
|
+
'fundingSubmerchantId'=>'123456',
|
662
|
+
'vendorName'=>'001',
|
663
|
+
'fundsTransferId'=>'1234567',
|
664
|
+
'amount'=>'107',
|
665
|
+
'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
|
666
|
+
}
|
667
|
+
|
668
|
+
payFacCreditHash = {
|
669
|
+
'reportGroup'=>'Planets',
|
670
|
+
'orderId'=>'12344',
|
671
|
+
'fundingSubmerchantId'=>'123456',
|
672
|
+
'fundsTransferId'=>'1234567',
|
673
|
+
'amount'=>'108',
|
674
|
+
}
|
675
|
+
|
676
|
+
reserveCreditHash = {
|
677
|
+
'reportGroup'=>'Planets',
|
678
|
+
'orderId'=>'12344',
|
679
|
+
'fundingSubmerchantId'=>'123456',
|
680
|
+
'fundsTransferId'=>'1234567',
|
681
|
+
'amount'=>'109',
|
682
|
+
}
|
683
|
+
|
684
|
+
physicalCheckCreditHash = {
|
685
|
+
'reportGroup'=>'Planets',
|
686
|
+
'orderId'=>'12344',
|
687
|
+
'fundingSubmerchantId'=>'123456',
|
688
|
+
'fundsTransferId'=>'1234567',
|
689
|
+
'amount'=>'110',
|
690
|
+
}
|
691
|
+
|
692
|
+
submerchantDebitHash = {
|
693
|
+
'reportGroup'=>'Planets',
|
694
|
+
'orderId'=>'12344',
|
695
|
+
'fundingSubmerchantId'=>'123456',
|
696
|
+
'submerchantName'=>'001',
|
697
|
+
'fundsTransferId'=>'1234567',
|
698
|
+
'amount'=>'106',
|
699
|
+
'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
|
700
|
+
}
|
701
|
+
|
702
|
+
vendorDebitHash = {
|
703
|
+
'reportGroup'=>'Planets',
|
704
|
+
'orderId'=>'12344',
|
705
|
+
'fundingSubmerchantId'=>'123456',
|
706
|
+
'vendorName'=>'001',
|
707
|
+
'fundsTransferId'=>'1234567',
|
708
|
+
'amount'=>'107',
|
709
|
+
'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
|
710
|
+
}
|
711
|
+
|
712
|
+
payFacDebitHash = {
|
713
|
+
'reportGroup'=>'Planets',
|
714
|
+
'orderId'=>'12344',
|
715
|
+
'fundingSubmerchantId'=>'123456',
|
716
|
+
'fundsTransferId'=>'1234567',
|
717
|
+
'amount'=>'108',
|
718
|
+
}
|
719
|
+
|
720
|
+
reserveDebitHash = {
|
721
|
+
'reportGroup'=>'Planets',
|
722
|
+
'orderId'=>'12344',
|
723
|
+
'fundingSubmerchantId'=>'123456',
|
724
|
+
'fundsTransferId'=>'1234567',
|
725
|
+
'amount'=>'109',
|
726
|
+
}
|
727
|
+
|
728
|
+
physicalCheckDebitHash = {
|
729
|
+
'reportGroup'=>'Planets',
|
730
|
+
'orderId'=>'12344',
|
731
|
+
'fundingSubmerchantId'=>'123456',
|
732
|
+
'fundsTransferId'=>'1234567',
|
733
|
+
'amount'=>'110',
|
734
|
+
}
|
735
|
+
batch = LitleBatchRequest.new
|
736
|
+
batch.create_new_batch('/usr/local/Batches/')
|
737
|
+
|
738
|
+
batch.submerchant_credit(submerchantCreditHash)
|
739
|
+
batch.payFac_credit(payFacCreditHash)
|
740
|
+
batch.vendor_credit(vendorCreditHash)
|
741
|
+
batch.reserve_credit(reserveCreditHash)
|
742
|
+
batch.physical_check_credit(physicalCheckCreditHash)
|
743
|
+
batch.submerchant_debit(submerchantDebitHash)
|
744
|
+
batch.payFac_debit(payFacDebitHash)
|
745
|
+
batch.vendor_debit(vendorDebitHash)
|
746
|
+
batch.reserve_debit(reserveDebitHash)
|
747
|
+
batch.physical_check_debit(physicalCheckDebitHash)
|
748
|
+
|
749
|
+
#pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
|
750
|
+
#puts "PID: " + pid.to_s + " size: " + size.to_s
|
751
|
+
batch.close_batch()
|
752
|
+
counts = batch.get_counts_and_amounts
|
753
|
+
|
754
|
+
assert_equal 1, counts[:submerchantCredit ][:numSubmerchantCredit ]
|
755
|
+
assert_equal 1, counts[:payFacCredit ][:numPayFacCredit ]
|
756
|
+
assert_equal 1, counts[:reserveCredit ][:numReserveCredit ]
|
757
|
+
assert_equal 1, counts[:vendorCredit ][:numVendorCredit ]
|
758
|
+
assert_equal 1, counts[:physicalCheckCredit ][:numPhysicalCheckCredit ]
|
759
|
+
assert_equal 106, counts[:submerchantCredit ][:submerchantCreditAmount ]
|
760
|
+
assert_equal 108, counts[:payFacCredit ][:payFacCreditAmount ]
|
761
|
+
assert_equal 109, counts[:reserveCredit ][:reserveCreditAmount ]
|
762
|
+
assert_equal 107, counts[:vendorCredit ][:vendorCreditAmount ]
|
763
|
+
assert_equal 110, counts[:physicalCheckCredit ][:physicalCheckCreditAmount ]
|
764
|
+
|
765
|
+
assert_equal 1, counts[:submerchantDebit ][:numSubmerchantDebit ]
|
766
|
+
assert_equal 1, counts[:payFacDebit ][:numPayFacDebit ]
|
767
|
+
assert_equal 1, counts[:reserveDebit ][:numReserveDebit ]
|
768
|
+
assert_equal 1, counts[:vendorDebit ][:numVendorDebit ]
|
769
|
+
assert_equal 1, counts[:physicalCheckDebit ][:numPhysicalCheckDebit ]
|
770
|
+
assert_equal 106, counts[:submerchantDebit ][:submerchantDebitAmount ]
|
771
|
+
assert_equal 108, counts[:payFacDebit ][:payFacDebitAmount ]
|
772
|
+
assert_equal 109, counts[:reserveDebit ][:reserveDebitAmount ]
|
773
|
+
assert_equal 107, counts[:vendorDebit ][:vendorDebitAmount ]
|
774
|
+
assert_equal 110, counts[:physicalCheckDebit ][:physicalCheckDebitAmount ]
|
775
|
+
end
|
642
776
|
end
|
643
777
|
end
|