CnpOnline 9.14.0 → 11.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/CHANGELOG +23 -17
- data/CONTRIBUTORS +0 -0
- data/DESCRIPTION +1 -1
- data/LICENSE +1 -1
- data/README.md +5 -3
- data/Rakefile +5 -5
- data/Rakefile~ +5 -5
- data/SETUP.md +3 -3
- data/bin/Setup.rb +59 -41
- data/lib/Communications.rb +3 -3
- data/lib/Configuration.rb +52 -45
- data/lib/EnvironmentVariables.rb +5 -1
- data/lib/LitleBatchRequest.rb +72 -7
- data/lib/LitleListeners.rb +17 -1
- data/lib/LitleOnline.rb +3 -4
- data/lib/LitleOnlineRequest.rb +37 -7
- data/lib/LitleRequest.rb +315 -186
- data/lib/LitleTransaction.rb +212 -85
- data/lib/LitleXmlMapper.rb +4 -2
- data/lib/XMLFields.rb +384 -171
- data/lib/cacert.pem +0 -0
- data/samples/Auth/LitleAuthReversalTransaction.rb +2 -2
- data/samples/Auth/LitleAuthorizationTransaction.rb +1 -0
- data/samples/Auth/LitlePaymentFullLifeCycle.rb +12 -6
- data/samples/Batch/AccountUpdate.rb +1 -0
- data/samples/Batch/SampleBatchDriver.rb +2 -1
- data/samples/Capture/LitleCaptureGivenAuthTransaction.rb +2 -1
- data/samples/Capture/LitleCaptureTransaction.rb +2 -2
- data/samples/Capture/LitleForceCaptureTransaction.rb +2 -1
- data/samples/Capture/LitlePartialCapture.rb +3 -3
- data/samples/Credit/LitleCreditTransaction.rb +2 -2
- data/samples/Credit/LitleRefundTransaction.rb +2 -1
- data/samples/Other/LitleAvsTransaction.rb +2 -1
- data/samples/Other/LitleVoidTransaction.rb +2 -1
- data/samples/Paypage/FullPaypageLifeCycle.rb +7 -2
- data/samples/Run_all.rb +0 -0
- data/samples/Sale/LitleSaleTransaction.rb +2 -1
- data/samples/Sale/SampleSaleTransaction.rb +2 -1
- data/test/certification/certTest1_base.rb +52 -53
- data/test/certification/certTest2_authenhanced.rb +24 -25
- data/test/certification/certTest3_authreversal.rb +23 -26
- data/test/certification/certTest4_echeck.rb +18 -32
- data/test/certification/certTest5_token.rb +105 -106
- data/test/certification/certTest_batchAll.rb +47 -15
- data/test/functional/test_activate.rb +32 -4
- data/test/functional/test_activateReversal.rb +18 -5
- data/test/functional/test_auth.rb +94 -48
- data/test/functional/test_authReversal.rb +4 -1
- data/test/functional/test_balanceInquiry.rb +28 -3
- data/test/functional/test_batchStream.rb +2 -4
- data/test/functional/test_cancelSubscription.rb +2 -2
- data/test/functional/test_capture.rb +21 -14
- data/test/functional/test_captureGivenAuth.rb +15 -6
- data/test/functional/test_createPlan.rb +1 -1
- data/test/functional/test_credit.rb +14 -5
- data/test/functional/test_deactivate.rb +26 -3
- data/test/functional/test_deactivateReversal.rb +18 -5
- data/test/functional/test_depositReversal.rb +31 -19
- data/test/functional/test_echeckCredit.rb +34 -6
- data/test/functional/test_echeckRedeposit.rb +29 -2
- data/test/functional/test_echeckSale.rb +68 -11
- data/test/functional/test_echeckVerification.rb +32 -7
- data/test/functional/test_echeckVoid.rb +2 -1
- data/test/functional/test_forceCapture.rb +20 -6
- data/test/functional/test_fraudCheck.rb +3 -5
- data/test/functional/test_giftCardAuthReversal.rb +72 -0
- data/test/functional/test_giftCardCapture.rb +72 -0
- data/test/functional/test_giftCardCredit.rb +69 -0
- data/test/functional/test_litle_requests.rb +3 -6
- data/test/functional/test_load.rb +27 -3
- data/test/functional/test_loadReversal.rb +18 -5
- data/test/functional/test_override.rb +7 -3
- data/test/functional/test_pgp_litle_requests.rb +294 -0
- data/test/functional/test_queryTransaction.rb +152 -0
- data/test/functional/test_refundReversal.rb +18 -5
- data/test/functional/test_sale.rb +122 -159
- data/test/functional/test_token.rb +17 -11
- data/test/functional/test_unload.rb +27 -3
- data/test/functional/test_unloadReversal.rb +18 -5
- data/test/functional/test_updateCardValidationNumOnToken.rb +1 -0
- data/test/functional/test_updatePlan.rb +2 -1
- data/test/functional/test_updateSubscription.rb +3 -1
- data/test/functional/test_wallet.rb +74 -0
- data/test/functional/test_xmlfields.rb +22 -3
- data/test/functional/ts_all.rb +2 -0
- data/test/unit/test_LitleBatchRequest.rb +53 -5
- data/test/unit/test_LitleOnlineRequest.rb +5 -30
- data/test/unit/test_LitleRequest.rb +7 -6
- data/test/unit/test_LitleTransaction.rb +34 -5
- data/test/unit/test_LitleXmlMapper.rb +3 -0
- data/test/unit/test_activate.rb +22 -2
- data/test/unit/test_activateReversal.rb +15 -3
- data/test/unit/test_auth.rb +11 -9
- data/test/unit/test_balanceInquiry.rb +2 -2
- data/test/unit/test_capture.rb +2 -2
- data/test/unit/test_captureGivenAuth.rb +21 -1
- data/test/unit/test_credit.rb +1 -1
- data/test/unit/test_deactivate.rb +19 -0
- data/test/unit/test_deactivateReversal.rb +15 -3
- data/test/unit/test_depositReversal.rb +17 -5
- data/test/unit/test_echeckCredit.rb +19 -0
- data/test/unit/test_echeckRedeposit.rb +15 -0
- data/test/unit/test_echeckSale.rb +20 -1
- data/test/unit/test_echeckVerification.rb +6 -3
- data/test/unit/test_forceCapture.rb +1 -1
- data/test/unit/test_giftCardAuthReversal.rb +58 -0
- data/test/{functional/test_utf8.rb → unit/test_giftCardCapture.rb} +25 -12
- data/test/unit/test_giftCardCredit.rb +57 -0
- data/test/unit/test_load.rb +2 -2
- data/test/unit/test_loadReversal.rb +15 -3
- data/test/unit/test_pgp_LitleRequest +139 -0
- data/test/unit/test_queryTransaction.rb +105 -0
- data/test/unit/test_refundReversal.rb +15 -3
- data/test/unit/test_sale.rb +23 -3
- data/test/unit/test_token.rb +24 -20
- data/test/unit/test_unload.rb +2 -2
- data/test/unit/test_unloadReversal.rb +15 -3
- data/test/unit/test_wallet.rb +262 -0
- data/test/unit/ts_unit.rb +2 -1
- metadata +81 -100
@@ -1,6 +1,5 @@
|
|
1
1
|
=begin
|
2
2
|
Copyright (c) 2017 Vantiv eCommerce
|
3
|
-
|
4
3
|
Permission is hereby granted, free of charge, to any person
|
5
4
|
obtaining a copy of this software and associated documentation
|
6
5
|
files (the "Software"), to deal in the Software without
|
@@ -9,10 +8,8 @@ copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
8
|
copies of the Software, and to permit persons to whom the
|
10
9
|
Software is furnished to do so, subject to the following
|
11
10
|
conditions:
|
12
|
-
|
13
11
|
The above copyright notice and this permission notice shall be
|
14
12
|
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
13
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
14
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
15
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -198,8 +195,8 @@ module LitleOnline
|
|
198
195
|
|
199
196
|
entries = Dir.entries(dir + '/litle-sdk-for-ruby-test')
|
200
197
|
entries.sort!
|
201
|
-
|
202
198
|
assert_equal 3, entries.size
|
199
|
+
puts entries[2]
|
203
200
|
assert_not_nil entries[2] =~ /request_\d+.complete.sent\z/
|
204
201
|
|
205
202
|
uploaded_file = entries[2]
|
@@ -247,6 +244,7 @@ module LitleOnline
|
|
247
244
|
|
248
245
|
assert_equal 3, entries.size
|
249
246
|
assert_not_nil entries[2] =~ /response_\d+.complete.asc.received\z/
|
247
|
+
|
250
248
|
end
|
251
249
|
|
252
250
|
def test_full_flow
|
@@ -340,7 +338,6 @@ module LitleOnline
|
|
340
338
|
entries.sort!
|
341
339
|
assert_equal 3, entries.length
|
342
340
|
assert_not_nil entries[2] =~ /response_\d+.complete.asc.received.processed\z/
|
343
|
-
|
344
341
|
end
|
345
342
|
|
346
343
|
def get_config(field, options)
|
@@ -353,4 +350,4 @@ module LitleOnline
|
|
353
350
|
end
|
354
351
|
end
|
355
352
|
end
|
356
|
-
end
|
353
|
+
end
|
@@ -33,12 +33,13 @@ def test_simple_happy
|
|
33
33
|
hash = {
|
34
34
|
'merchantId' => '101',
|
35
35
|
'version'=>'8.8',
|
36
|
+
'id'=>'test',
|
36
37
|
'reportGroup'=>'Planets',
|
37
38
|
'orderId' =>'1001',
|
38
39
|
'amount' =>'500',
|
39
40
|
'orderSource' =>'ecommerce',
|
40
41
|
'card'=>{
|
41
|
-
'type'=>'
|
42
|
+
'type'=>'GC',
|
42
43
|
'number' =>'4100000000000001',
|
43
44
|
'expDate' =>'1210'
|
44
45
|
}
|
@@ -52,12 +53,13 @@ def test_simple_happy
|
|
52
53
|
hash = {
|
53
54
|
'merchantId' => '101',
|
54
55
|
'version'=>'8.8',
|
56
|
+
'id'=>'test',
|
55
57
|
'reportGroup'=>'Planets',
|
56
58
|
'amount' =>'500',
|
57
59
|
'orderId' =>'1001',
|
58
60
|
'orderSource' =>'ecommerce',
|
59
61
|
'card'=>{
|
60
|
-
'type'=>'
|
62
|
+
'type'=>'GC',
|
61
63
|
'number' =>'4100000000000001',
|
62
64
|
'expDate' =>'1210'
|
63
65
|
}
|
@@ -78,7 +80,29 @@ def test_simple_happy
|
|
78
80
|
#Get exceptions
|
79
81
|
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.load_request(hash)}
|
80
82
|
#Test
|
81
|
-
assert(exception.message =~ /Error validating xml data against the schema/)
|
83
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_GiftCardCardType_NotPresent
|
87
|
+
hash = {
|
88
|
+
'merchantId' => '101',
|
89
|
+
'version'=>'8.8',
|
90
|
+
'id' =>'test',
|
91
|
+
'reportGroup'=>'Planets',
|
92
|
+
'amount' =>'500',
|
93
|
+
'orderId' =>'1001',
|
94
|
+
'orderSource' =>'ecommerce',
|
95
|
+
'card'=>{
|
96
|
+
'type'=>'VI',
|
97
|
+
'number' =>'4100000000000001',
|
98
|
+
'expDate' =>'1210'
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
#Get exceptions
|
103
|
+
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.load_request(hash)}
|
104
|
+
#Test
|
105
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
82
106
|
end
|
83
107
|
end
|
84
108
|
end
|
@@ -33,12 +33,25 @@ def test_simple
|
|
33
33
|
hash = {
|
34
34
|
'merchantId' => '101',
|
35
35
|
'version'=>'8.8',
|
36
|
+
'id'=>'test',
|
36
37
|
'reportGroup'=>'Planets',
|
37
|
-
'litleTxnId' =>'5000'
|
38
|
-
|
38
|
+
'litleTxnId' =>'5000',
|
39
|
+
'card'=>{
|
40
|
+
'type'=>'GC',
|
41
|
+
'number' =>'400000000000001',
|
42
|
+
'expDate' =>'0150',
|
43
|
+
'pin' => '1234',
|
44
|
+
'cardValidationNum' => '411'
|
45
|
+
},
|
46
|
+
'originalRefCode' => '101',
|
47
|
+
'originalAmount' => '34561',
|
48
|
+
'originalTxnTime' => '2017-01-24T09:00:00',
|
49
|
+
'originalSystemTraceId' => '33',
|
50
|
+
'originalSequenceNumber' => '111111',
|
51
|
+
}
|
39
52
|
|
40
|
-
response= LitleOnlineRequest.new.
|
41
|
-
assert_equal('
|
53
|
+
response= LitleOnlineRequest.new.deposit_reversal(hash)
|
54
|
+
assert_equal('000', response.depositReversalResponse.response)
|
42
55
|
end
|
43
56
|
|
44
57
|
|
@@ -52,7 +65,7 @@ def test_simple
|
|
52
65
|
#Get exceptions
|
53
66
|
exception = assert_raise(RuntimeError){LitleOnlineRequest.new.load_reversal(hash)}
|
54
67
|
#Test
|
55
|
-
assert(exception.message =~ /Error validating xml data against the schema/)
|
68
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
56
69
|
end
|
57
70
|
end
|
58
71
|
end
|
@@ -7,12 +7,13 @@ module LitleOnline
|
|
7
7
|
def test_override_withoutLocalAndEnv
|
8
8
|
hash = {
|
9
9
|
'merchantId' => '101',
|
10
|
+
'id' => 'test',
|
10
11
|
'version'=>'8.8',
|
11
12
|
'orderId' =>'1001',
|
12
13
|
'amount' =>'500',
|
13
14
|
'orderSource' =>'ecommerce',
|
14
15
|
'card'=>{
|
15
|
-
'type'=>'
|
16
|
+
'type'=>'GC',
|
16
17
|
'number' =>'4100000000000001',
|
17
18
|
'expDate' =>'1210'
|
18
19
|
}
|
@@ -20,15 +21,17 @@ module LitleOnline
|
|
20
21
|
response= LitleOnlineRequest.new.activate(hash)
|
21
22
|
assert_equal('Default Report Group', response.activateResponse.reportGroup)
|
22
23
|
end
|
24
|
+
|
23
25
|
def test_override_withoutLocal
|
24
26
|
hash = {
|
25
27
|
'merchantId' => '101',
|
28
|
+
'id' => 'test',
|
26
29
|
'version'=>'8.8',
|
27
30
|
'orderId' =>'1001',
|
28
31
|
'amount' =>'500',
|
29
32
|
'orderSource' =>'ecommerce',
|
30
33
|
'card'=>{
|
31
|
-
'type'=>'
|
34
|
+
'type'=>'GC',
|
32
35
|
'number' =>'4100000000000001',
|
33
36
|
'expDate' =>'1210'
|
34
37
|
}
|
@@ -42,13 +45,14 @@ module LitleOnline
|
|
42
45
|
def test_override
|
43
46
|
hash = {
|
44
47
|
'merchantId' => '101',
|
48
|
+
'id' => 'test',
|
45
49
|
'version'=>'8.8',
|
46
50
|
'reportGroup'=>'Planets',
|
47
51
|
'orderId' =>'1001',
|
48
52
|
'amount' =>'500',
|
49
53
|
'orderSource' =>'ecommerce',
|
50
54
|
'card'=>{
|
51
|
-
'type'=>'
|
55
|
+
'type'=>'GC',
|
52
56
|
'number' =>'4100000000000001',
|
53
57
|
'expDate' =>'1210'
|
54
58
|
}
|
@@ -0,0 +1,294 @@
|
|
1
|
+
require File.expand_path("../../../lib/LitleOnline",__FILE__)
|
2
|
+
require 'test/unit'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
LITLE_SDK_TEST_FOLDER = '/litle-sdk-for-ruby-test'
|
6
|
+
|
7
|
+
module LitleOnline
|
8
|
+
class TestPgpLitleRequest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
dir = '/tmp/litle-sdk-for-ruby-test'
|
12
|
+
FileUtils.rm_rf dir
|
13
|
+
Dir.mkdir dir
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_send_to_litle
|
18
|
+
ENV['litle_deleteBatchFiles'] = 'false'
|
19
|
+
config_dir = ENV['LITLE_CONFIG_DIR']
|
20
|
+
ENV['LITLE_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
21
|
+
|
22
|
+
@config_hash = Configuration.new.config
|
23
|
+
|
24
|
+
dir = '/tmp'
|
25
|
+
|
26
|
+
request = LitleRequest.new()
|
27
|
+
ENV['LITLE_CONFIG_DIR'] = config_dir
|
28
|
+
request.create_new_litle_request(dir + LITLE_SDK_TEST_FOLDER)
|
29
|
+
request.finish_request
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
request.send_to_litle()
|
34
|
+
|
35
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
36
|
+
encrypted_entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
37
|
+
entries.sort!
|
38
|
+
assert_equal 4, entries.size
|
39
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
40
|
+
encrypted_entries.sort!
|
41
|
+
assert_equal 3, encrypted_entries.size
|
42
|
+
assert_not_nil encrypted_entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{ENCRYPTED_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
43
|
+
|
44
|
+
uploaded_file = encrypted_entries[2]
|
45
|
+
|
46
|
+
options = {}
|
47
|
+
username = get_config(:sftp_username, options)
|
48
|
+
password = get_config(:sftp_password, options)
|
49
|
+
url = get_config(:sftp_url, options)
|
50
|
+
|
51
|
+
Net::SFTP.start(url, username, :password => password) do |sftp|
|
52
|
+
# clear out the sFTP outbound dir prior to checking for new files, avoids leaving files on the server
|
53
|
+
# if files are left behind we are not counting then towards the expected total
|
54
|
+
ents = []
|
55
|
+
handle = sftp.opendir!('/inbound/')
|
56
|
+
files_on_srv = sftp.readdir!(handle)
|
57
|
+
files_on_srv.each {|file|
|
58
|
+
ents.push(file.name)
|
59
|
+
}
|
60
|
+
assert_equal 3,ents.size
|
61
|
+
ents.sort!
|
62
|
+
assert_equal ents[2], uploaded_file.gsub(SENT_FILE_SUFFIX, '.asc')
|
63
|
+
sftp.remove('/inbound/' + ents[2])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_full_flow
|
68
|
+
ENV['litle_deleteBatchFiles'] = 'false'
|
69
|
+
config_dir = ENV['LITLE_CONFIG_DIR']
|
70
|
+
ENV['LITLE_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
71
|
+
|
72
|
+
saleHash = {
|
73
|
+
'reportGroup'=>'Planets',
|
74
|
+
'id' => '006',
|
75
|
+
'orderId'=>'12344',
|
76
|
+
'amount'=>'6000',
|
77
|
+
'orderSource'=>'ecommerce',
|
78
|
+
'card'=>{
|
79
|
+
'type'=>'VI',
|
80
|
+
'number' =>'4100000000000001',
|
81
|
+
'expDate' =>'1210'
|
82
|
+
}}
|
83
|
+
|
84
|
+
dir = '/tmp'
|
85
|
+
|
86
|
+
request = LitleRequest.new()
|
87
|
+
ENV['LITLE_CONFIG_DIR'] = config_dir
|
88
|
+
request.create_new_litle_request(dir + LITLE_SDK_TEST_FOLDER)
|
89
|
+
|
90
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
91
|
+
entries.sort!
|
92
|
+
|
93
|
+
assert_equal 4, entries.size
|
94
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
95
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
96
|
+
|
97
|
+
#create five batches, each with 10 sales
|
98
|
+
5.times{
|
99
|
+
batch = LitleBatchRequest.new
|
100
|
+
batch.create_new_batch(dir + LITLE_SDK_TEST_FOLDER)
|
101
|
+
|
102
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
103
|
+
|
104
|
+
assert_equal 6, entries.length
|
105
|
+
entries.sort!
|
106
|
+
assert_not_nil entries[2] =~ /batch_\d+\z/
|
107
|
+
assert_not_nil entries[3] =~ /batch_\d+_txns\z/
|
108
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
109
|
+
assert_not_nil entries[5] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
110
|
+
#add the same sale ten times
|
111
|
+
10.times{
|
112
|
+
#batch.account_update(accountUpdateHash)
|
113
|
+
saleHash['card']['number']= (saleHash['card']['number'].to_i + 1).to_s
|
114
|
+
batch.sale(saleHash)
|
115
|
+
}
|
116
|
+
|
117
|
+
#close the batch, indicating we plan to add no more transactions
|
118
|
+
batch.close_batch()
|
119
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
120
|
+
|
121
|
+
assert_equal 5, entries.length
|
122
|
+
entries.sort!
|
123
|
+
assert_not_nil entries[2] =~ /batch_\d+.closed-\d+\z/
|
124
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
125
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
126
|
+
|
127
|
+
#add the batch to the LitleRequest
|
128
|
+
request.commit_batch(batch)
|
129
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
130
|
+
assert_equal 4, entries.length
|
131
|
+
entries.sort!
|
132
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
133
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
134
|
+
}
|
135
|
+
#finish the Litle Request, indicating we plan to add no more batches
|
136
|
+
request.finish_request
|
137
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
138
|
+
assert_equal 3, entries.length
|
139
|
+
entries.sort!
|
140
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+.complete\z/
|
141
|
+
|
142
|
+
#send the batch files at the given directory over sFTP
|
143
|
+
|
144
|
+
request.send_to_litle()
|
145
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
146
|
+
encrypted_entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
147
|
+
|
148
|
+
assert_equal entries.length, 4
|
149
|
+
entries.sort!
|
150
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
151
|
+
encrypted_entries.sort!
|
152
|
+
assert_not_nil encrypted_entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{ENCRYPTED_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
#grab the expected number of responses from the sFTP server and save them to the given path
|
157
|
+
request.get_responses_from_server()
|
158
|
+
#process the responses from the server with a listener which applies the given block
|
159
|
+
request.process_responses({:transaction_listener => LitleOnline::DefaultLitleListener.new do |transaction| end})
|
160
|
+
|
161
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
162
|
+
|
163
|
+
assert_equal 5, entries.length
|
164
|
+
entries.sort!
|
165
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
166
|
+
File.delete(dir + LITLE_SDK_TEST_FOLDER + '/' + entries[3])
|
167
|
+
|
168
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + entries[4])
|
169
|
+
entries.sort!
|
170
|
+
assert_equal 4, entries.length
|
171
|
+
assert_not_nil entries[3] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}.processed\z/
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
def test_full_flow_with_deleteBatchFiles
|
176
|
+
ENV['litle_deleteBatchFiles'] = 'true'
|
177
|
+
config_dir = ENV['LITLE_CONFIG_DIR']
|
178
|
+
ENV['LITLE_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
179
|
+
|
180
|
+
saleHash = {
|
181
|
+
'reportGroup'=>'Planets',
|
182
|
+
'id' => '006',
|
183
|
+
'orderId'=>'12344',
|
184
|
+
'amount'=>'6000',
|
185
|
+
'orderSource'=>'ecommerce',
|
186
|
+
'card'=>{
|
187
|
+
'type'=>'VI',
|
188
|
+
'number' =>'4100000000000001',
|
189
|
+
'expDate' =>'1210'
|
190
|
+
}}
|
191
|
+
|
192
|
+
dir = '/tmp'
|
193
|
+
|
194
|
+
request = LitleRequest.new()
|
195
|
+
ENV['LITLE_CONFIG_DIR'] = config_dir
|
196
|
+
ENV['litle_deleteBatchFiles'] = 'false'
|
197
|
+
request.create_new_litle_request(dir + LITLE_SDK_TEST_FOLDER)
|
198
|
+
|
199
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
200
|
+
entries.sort!
|
201
|
+
|
202
|
+
assert_equal 4, entries.size
|
203
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
204
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
205
|
+
|
206
|
+
#create five batches, each with 10 sales
|
207
|
+
5.times{
|
208
|
+
batch = LitleBatchRequest.new
|
209
|
+
batch.create_new_batch(dir + LITLE_SDK_TEST_FOLDER)
|
210
|
+
|
211
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
212
|
+
|
213
|
+
assert_equal 6, entries.length
|
214
|
+
entries.sort!
|
215
|
+
assert_not_nil entries[2] =~ /batch_\d+\z/
|
216
|
+
assert_not_nil entries[3] =~ /batch_\d+_txns\z/
|
217
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
218
|
+
assert_not_nil entries[5] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
219
|
+
#add the same sale ten times
|
220
|
+
10.times{
|
221
|
+
#batch.account_update(accountUpdateHash)
|
222
|
+
saleHash['card']['number']= (saleHash['card']['number'].to_i + 1).to_s
|
223
|
+
batch.sale(saleHash)
|
224
|
+
}
|
225
|
+
|
226
|
+
#close the batch, indicating we plan to add no more transactions
|
227
|
+
batch.close_batch()
|
228
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
229
|
+
|
230
|
+
assert_equal 5, entries.length
|
231
|
+
entries.sort!
|
232
|
+
assert_not_nil entries[2] =~ /batch_\d+.closed-\d+\z/
|
233
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
234
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
235
|
+
|
236
|
+
#add the batch to the LitleRequest
|
237
|
+
request.commit_batch(batch)
|
238
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
239
|
+
assert_equal 4, entries.length
|
240
|
+
entries.sort!
|
241
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
242
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
243
|
+
}
|
244
|
+
#finish the Litle Request, indicating we plan to add no more batches
|
245
|
+
request.finish_request
|
246
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
247
|
+
assert_equal 3, entries.length
|
248
|
+
entries.sort!
|
249
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+.complete\z/
|
250
|
+
|
251
|
+
#send the batch files at the given directory over sFTP
|
252
|
+
|
253
|
+
request.send_to_litle()
|
254
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER)
|
255
|
+
encrypted_entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
256
|
+
|
257
|
+
assert_equal 3, entries.length
|
258
|
+
entries.sort!
|
259
|
+
puts entries[2]
|
260
|
+
assert_not_nil entries[2] =~ /encrypted/
|
261
|
+
assert_equal 2, encrypted_entries.length
|
262
|
+
|
263
|
+
|
264
|
+
#grab the expected number of responses from the sFTP server and save them to the given path
|
265
|
+
request.get_responses_from_server()
|
266
|
+
|
267
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR)
|
268
|
+
encrypted_entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR + ENCRYPTED_PATH_DIR)
|
269
|
+
assert_equal 4, entries.length
|
270
|
+
entries.sort!
|
271
|
+
assert_not_nil entries[3] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}\z/
|
272
|
+
assert_equal 2, encrypted_entries.length
|
273
|
+
|
274
|
+
#process the responses from the server with a listener which applies the given block
|
275
|
+
request.process_responses({:transaction_listener => LitleOnline::DefaultLitleListener.new do |transaction| end})
|
276
|
+
|
277
|
+
entries = Dir.entries(dir + LITLE_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR)
|
278
|
+
assert_equal 3, entries.length
|
279
|
+
entries.sort!
|
280
|
+
assert_not_nil entries[2] =~ /encrypted/
|
281
|
+
end
|
282
|
+
|
283
|
+
def get_config(field, options)
|
284
|
+
if options[field.to_s] == nil and options[field] == nil then
|
285
|
+
return @config_hash[field.to_s]
|
286
|
+
elsif options[field.to_s] != nil then
|
287
|
+
return options[field.to_s]
|
288
|
+
else
|
289
|
+
return options[field]
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
294
|
+
end
|