CnpOnline 11.4.0 → 12.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -164
- data/CHANGELOG~ +0 -0
- data/CONTRIBUTORS +0 -2
- data/DESCRIPTION +1 -1
- data/LICENSE +0 -0
- data/README.md +13 -15
- data/Rakefile +3 -2
- data/Rakefile~ +4 -3
- data/SETUP.md +13 -10
- data/bin/Setup.rb +26 -22
- data/bin/sample_batch_driver.rb +15 -15
- data/bin/sample_driver.rb +5 -5
- data/lib/{LitleBatchRequest.rb → CnpBatchRequest.rb} +68 -66
- data/lib/{LitleListeners.rb → CnpListeners.rb} +48 -40
- data/lib/{LitleOnline.rb → CnpOnline.rb} +8 -7
- data/lib/{LitleOnlineRequest.rb → CnpOnlineRequest.rb} +53 -53
- data/lib/{LitleRequest.rb → CnpRequest.rb} +186 -192
- data/lib/{LitleTransaction.rb → CnpTransaction.rb} +53 -52
- data/lib/{LitleXmlMapper.rb → CnpXmlMapper.rb} +7 -7
- data/lib/Communications.rb +8 -7
- data/lib/Configuration.rb +7 -6
- data/lib/EnvironmentVariables.rb +2 -2
- data/lib/XMLFields.rb +98 -108
- data/lib/cacert.pem +0 -0
- data/samples/Auth/CnpAuthReversalTransaction.rb +15 -0
- data/samples/Auth/{LitleAuthorizationTransaction.rb → CnpAuthorizationTransaction.rb} +4 -4
- data/samples/Auth/{LitlePaymentFullLifeCycle.rb → CnpPaymentFullLifeCycle.rb} +11 -11
- data/samples/Batch/AccountUpdate.rb +11 -11
- data/samples/Batch/SampleBatchDriver.rb +16 -16
- data/samples/Capture/{LitleCaptureGivenAuthTransaction.rb → CnpCaptureGivenAuthTransaction.rb} +4 -4
- data/samples/Capture/CnpCaptureTransaction.rb +14 -0
- data/samples/Capture/{LitleForceCaptureTransaction.rb → CnpForceCaptureTransaction.rb} +5 -5
- data/samples/Capture/CnpPartialCapture.rb +16 -0
- data/samples/Credit/CnpCreditTransaction.rb +16 -0
- data/samples/Credit/{LitleRefundTransaction.rb → CnpRefundTransaction.rb} +4 -4
- data/samples/Other/{LitleAvsTransaction.rb → CnpAvsTransaction.rb} +4 -4
- data/samples/Other/CnpVoidTransaction.rb +19 -0
- data/samples/Paypage/FullPaypageLifeCycle.rb +16 -16
- data/samples/Run_all.rb +12 -12
- data/samples/Sale/{LitleSaleTransaction.rb → CnpSaleTransaction.rb} +4 -4
- data/samples/Sale/SampleSaleTransaction.rb +5 -5
- data/test/certification/certTest1_base.rb +104 -103
- data/test/certification/certTest2_authenhanced.rb +90 -88
- data/test/certification/certTest3_authreversal.rb +29 -28
- data/test/certification/certTest4_echeck.rb +22 -20
- data/test/certification/certTest5_token.rb +51 -49
- data/test/certification/certTest_batchAll.rb +60 -60
- data/test/certification/ts_all.rb +1 -1
- data/test/functional/test_activate.rb +9 -8
- data/test/functional/test_activateReversal.rb +5 -5
- data/test/functional/test_auth.rb +31 -30
- data/test/functional/test_authReversal.rb +8 -8
- data/test/functional/test_balanceInquiry.rb +6 -6
- data/test/functional/test_batch.rb +32 -32
- data/test/functional/test_batchStream.rb +14 -14
- data/test/functional/test_cancelSubscription.rb +4 -4
- data/test/functional/test_capture.rb +14 -14
- data/test/functional/test_captureGivenAuth.rb +16 -16
- data/test/functional/test_configuration.rb +26 -26
- data/test/functional/test_createPlan.rb +5 -5
- data/test/functional/test_credit.rb +13 -33
- data/test/functional/test_deactivate.rb +6 -6
- data/test/functional/test_deactivateReversal.rb +5 -5
- data/test/functional/test_depositReversal.rb +5 -5
- data/test/functional/test_echeckCredit.rb +20 -20
- data/test/functional/test_echeckRedeposit.rb +16 -16
- data/test/functional/test_echeckSale.rb +35 -35
- data/test/functional/test_echeckVerification.rb +17 -17
- data/test/functional/test_echeckVoid.rb +4 -4
- data/test/functional/test_forceCapture.rb +21 -21
- data/test/functional/test_fraudCheck.rb +6 -5
- data/test/functional/test_giftCardAuthReversal.rb +5 -5
- data/test/functional/test_giftCardCapture.rb +5 -5
- data/test/functional/test_giftCardCredit.rb +5 -5
- data/test/functional/test_litle_requests.rb +101 -99
- data/test/functional/test_load.rb +6 -6
- data/test/functional/test_loadReversal.rb +5 -5
- data/test/functional/test_override.rb +9 -9
- data/test/functional/{test_pgp_litle_requests.rb → test_pgp_cnp_requests.rb} +61 -60
- data/test/functional/test_queryTransaction.rb +10 -10
- data/test/functional/test_refundReversal.rb +5 -5
- data/test/functional/test_sale.rb +36 -36
- data/test/functional/test_token.rb +10 -10
- data/test/functional/test_unload.rb +6 -6
- data/test/functional/test_unloadReversal.rb +5 -5
- data/test/functional/test_updateCardValidationNumOnToken.rb +4 -4
- data/test/functional/test_updatePlan.rb +4 -4
- data/test/functional/test_updateSubscription.rb +5 -5
- data/test/functional/test_wallet.rb +5 -5
- data/test/functional/test_xmlfields.rb +29 -69
- data/test/functional/ts_all.rb +2 -2
- data/test/unit/test_LitleAUBatch.rb +15 -15
- data/test/unit/test_LitleBatchRequest.rb +42 -76
- data/test/unit/test_LitleOnlineRequest.rb +38 -38
- data/test/unit/test_LitleRequest.rb +47 -47
- data/test/unit/test_LitleTransaction.rb +34 -34
- data/test/unit/test_LitleXmlMapper.rb +27 -27
- data/test/unit/test_activate.rb +8 -8
- data/test/unit/test_activateReversal.rb +5 -5
- data/test/unit/test_auth.rb +43 -43
- data/test/unit/test_authReversal.rb +14 -14
- data/test/unit/test_balanceInquiry.rb +4 -4
- data/test/unit/test_cancelSubscription.rb +4 -4
- data/test/unit/test_capture.rb +20 -20
- data/test/unit/test_captureGivenAuth.rb +22 -22
- data/test/unit/test_createPlan.rb +4 -4
- data/test/unit/test_credit.rb +43 -43
- data/test/unit/test_deactivate.rb +6 -6
- data/test/unit/test_deactivateReversal.rb +5 -5
- data/test/unit/test_depositReversal.rb +5 -5
- data/test/unit/test_echeckCredit.rb +16 -16
- data/test/unit/test_echeckRedeposit.rb +19 -19
- data/test/unit/test_echeckSale.rb +16 -16
- data/test/unit/test_echeckVerification.rb +11 -11
- data/test/unit/test_echeckVoid.rb +8 -8
- data/test/unit/test_forceCapture.rb +19 -19
- data/test/unit/test_fraudCheck.rb +4 -4
- data/test/unit/test_giftCardAuthReversal.rb +5 -5
- data/test/unit/test_giftCardCapture.rb +5 -5
- data/test/unit/test_giftCardCredit.rb +5 -5
- data/test/unit/test_load.rb +4 -4
- data/test/unit/test_loadReversal.rb +5 -5
- data/test/unit/{test_pgp_LitleRequest → test_pgp_CnpRequest.rb} +32 -32
- data/test/unit/test_queryTransaction.rb +8 -8
- data/test/unit/test_refundReversal.rb +5 -5
- data/test/unit/test_sale.rb +64 -64
- data/test/unit/test_token.rb +13 -13
- data/test/unit/test_unload.rb +4 -4
- data/test/unit/test_unloadReversal.rb +5 -5
- data/test/unit/test_updateCardValidationNumOnToken.rb +16 -16
- data/test/unit/test_updatePlan.rb +4 -4
- data/test/unit/test_updateSubscription.rb +11 -11
- data/test/unit/test_wallet.rb +13 -13
- data/test/unit/test_xmlfields.rb +119 -119
- data/test/unit/ts_unit.rb +6 -6
- metadata +35 -26
- data/samples/Auth/LitleAuthReversalTransaction.rb +0 -15
- data/samples/Capture/LitleCaptureTransaction.rb +0 -14
- data/samples/Capture/LitlePartialCapture.rb +0 -16
- data/samples/Credit/LitleCreditTransaction.rb +0 -16
- data/samples/Other/LitleVoidTransaction.rb +0 -19
@@ -22,11 +22,11 @@ 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/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test Load Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestLoad < Test::Unit::TestCase
|
31
31
|
|
32
32
|
def test_simple_happy
|
@@ -45,7 +45,7 @@ def test_simple_happy
|
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
48
|
-
response=
|
48
|
+
response= CnpOnlineRequest.new.load_request(hash)
|
49
49
|
assert_equal('Valid Format', response.message)
|
50
50
|
end
|
51
51
|
|
@@ -65,7 +65,7 @@ def test_simple_happy
|
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
68
|
-
response=
|
68
|
+
response= CnpOnlineRequest.new.load_request(hash)
|
69
69
|
assert_equal('Valid Format', response.message)
|
70
70
|
end
|
71
71
|
|
@@ -78,7 +78,7 @@ def test_simple_happy
|
|
78
78
|
}
|
79
79
|
|
80
80
|
#Get exceptions
|
81
|
-
exception = assert_raise(RuntimeError){
|
81
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.load_request(hash)}
|
82
82
|
#Test
|
83
83
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
84
84
|
end
|
@@ -100,7 +100,7 @@ def test_simple_happy
|
|
100
100
|
}
|
101
101
|
|
102
102
|
#Get exceptions
|
103
|
-
exception = assert_raise(RuntimeError){
|
103
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.load_request(hash)}
|
104
104
|
#Test
|
105
105
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
106
106
|
end
|
@@ -22,11 +22,11 @@ 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/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test loadReversal Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestLoadReversal < Test::Unit::TestCase
|
31
31
|
|
32
32
|
def test_simple
|
@@ -35,7 +35,7 @@ def test_simple
|
|
35
35
|
'version'=>'8.8',
|
36
36
|
'id'=>'test',
|
37
37
|
'reportGroup'=>'Planets',
|
38
|
-
'
|
38
|
+
'cnpTxnId' =>'5000',
|
39
39
|
'card'=>{
|
40
40
|
'type'=>'GC',
|
41
41
|
'number' =>'400000000000001',
|
@@ -50,7 +50,7 @@ def test_simple
|
|
50
50
|
'originalSequenceNumber' => '111111',
|
51
51
|
}
|
52
52
|
|
53
|
-
response=
|
53
|
+
response= CnpOnlineRequest.new.deposit_reversal(hash)
|
54
54
|
assert_equal('000', response.depositReversalResponse.response)
|
55
55
|
end
|
56
56
|
|
@@ -63,7 +63,7 @@ def test_simple
|
|
63
63
|
}
|
64
64
|
|
65
65
|
#Get exceptions
|
66
|
-
exception = assert_raise(RuntimeError){
|
66
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.load_reversal(hash)}
|
67
67
|
#Test
|
68
68
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
69
69
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path("../../../lib/
|
1
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
4
|
#test Activate Transaction
|
5
|
-
module
|
5
|
+
module CnpOnline
|
6
6
|
class TestOverride < Test::Unit::TestCase
|
7
7
|
def test_override_withoutLocalAndEnv
|
8
8
|
hash = {
|
@@ -18,7 +18,7 @@ module LitleOnline
|
|
18
18
|
'expDate' =>'1210'
|
19
19
|
}
|
20
20
|
}
|
21
|
-
response=
|
21
|
+
response= CnpOnlineRequest.new.activate(hash)
|
22
22
|
assert_equal('Default Report Group', response.activateResponse.reportGroup)
|
23
23
|
end
|
24
24
|
|
@@ -36,10 +36,10 @@ module LitleOnline
|
|
36
36
|
'expDate' =>'1210'
|
37
37
|
}
|
38
38
|
}
|
39
|
-
ENV['
|
40
|
-
response=
|
39
|
+
ENV['cnp_default_report_group']='380'
|
40
|
+
response= CnpOnlineRequest.new.activate(hash)
|
41
41
|
assert_equal('380', response.activateResponse.reportGroup)
|
42
|
-
ENV['
|
42
|
+
ENV['cnp_default_report_group']=nil
|
43
43
|
|
44
44
|
end
|
45
45
|
def test_override
|
@@ -57,10 +57,10 @@ module LitleOnline
|
|
57
57
|
'expDate' =>'1210'
|
58
58
|
}
|
59
59
|
}
|
60
|
-
ENV['
|
61
|
-
response=
|
60
|
+
ENV['cnp_default_report_group']='380'
|
61
|
+
response= CnpOnlineRequest.new.activate(hash)
|
62
62
|
assert_equal('Planets', response.activateResponse.reportGroup)
|
63
|
-
ENV['
|
63
|
+
ENV['cnp_default_report_group']=nil
|
64
64
|
|
65
65
|
end
|
66
66
|
|
@@ -1,39 +1,40 @@
|
|
1
|
-
require File.expand_path("../../../lib/
|
1
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
2
2
|
require 'test/unit'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
|
5
|
+
CNP_SDK_TEST_FOLDER = '/cnp-sdk-for-ruby-test'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
module CnpOnline
|
9
|
+
class TestPgpCnpRequest < Test::Unit::TestCase
|
9
10
|
|
10
11
|
def setup
|
11
|
-
dir = '/tmp
|
12
|
+
dir = '/tmp' + CNP_SDK_TEST_FOLDER
|
12
13
|
FileUtils.rm_rf dir
|
13
14
|
Dir.mkdir dir
|
14
15
|
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
ENV['
|
19
|
-
config_dir = ENV['
|
20
|
-
ENV['
|
18
|
+
def test_send_to_cnp
|
19
|
+
ENV['cnp_deleteBatchFiles'] = 'false'
|
20
|
+
config_dir = ENV['CNP_CONFIG_DIR']
|
21
|
+
ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
21
22
|
|
22
23
|
@config_hash = Configuration.new.config
|
23
24
|
|
24
25
|
dir = '/tmp'
|
25
26
|
|
26
|
-
request =
|
27
|
-
ENV['
|
28
|
-
request.
|
27
|
+
request = CnpRequest.new()
|
28
|
+
ENV['CNP_CONFIG_DIR'] = config_dir
|
29
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
29
30
|
request.finish_request
|
30
31
|
|
31
32
|
|
32
33
|
|
33
|
-
request.
|
34
|
+
request.send_to_cnp()
|
34
35
|
|
35
|
-
entries = Dir.entries(dir +
|
36
|
-
encrypted_entries = Dir.entries(dir +
|
36
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
37
|
+
encrypted_entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
37
38
|
entries.sort!
|
38
39
|
assert_equal 4, entries.size
|
39
40
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
@@ -65,9 +66,9 @@ module LitleOnline
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def test_full_flow
|
68
|
-
ENV['
|
69
|
-
config_dir = ENV['
|
70
|
-
ENV['
|
69
|
+
ENV['cnp_deleteBatchFiles'] = 'false'
|
70
|
+
config_dir = ENV['CNP_CONFIG_DIR']
|
71
|
+
ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
71
72
|
|
72
73
|
saleHash = {
|
73
74
|
'reportGroup'=>'Planets',
|
@@ -83,11 +84,11 @@ module LitleOnline
|
|
83
84
|
|
84
85
|
dir = '/tmp'
|
85
86
|
|
86
|
-
request =
|
87
|
-
ENV['
|
88
|
-
request.
|
87
|
+
request = CnpRequest.new()
|
88
|
+
ENV['CNP_CONFIG_DIR'] = config_dir
|
89
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
89
90
|
|
90
|
-
entries = Dir.entries(dir +
|
91
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
91
92
|
entries.sort!
|
92
93
|
|
93
94
|
assert_equal 4, entries.size
|
@@ -96,10 +97,10 @@ module LitleOnline
|
|
96
97
|
|
97
98
|
#create five batches, each with 10 sales
|
98
99
|
5.times{
|
99
|
-
batch =
|
100
|
-
batch.create_new_batch(dir +
|
100
|
+
batch = CnpBatchRequest.new
|
101
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
101
102
|
|
102
|
-
entries = Dir.entries(dir +
|
103
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
103
104
|
|
104
105
|
assert_equal 6, entries.length
|
105
106
|
entries.sort!
|
@@ -116,7 +117,7 @@ module LitleOnline
|
|
116
117
|
|
117
118
|
#close the batch, indicating we plan to add no more transactions
|
118
119
|
batch.close_batch()
|
119
|
-
entries = Dir.entries(dir +
|
120
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
120
121
|
|
121
122
|
assert_equal 5, entries.length
|
122
123
|
entries.sort!
|
@@ -124,26 +125,26 @@ module LitleOnline
|
|
124
125
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
125
126
|
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
126
127
|
|
127
|
-
#add the batch to the
|
128
|
+
#add the batch to the CnpRequest
|
128
129
|
request.commit_batch(batch)
|
129
|
-
entries = Dir.entries(dir +
|
130
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
130
131
|
assert_equal 4, entries.length
|
131
132
|
entries.sort!
|
132
133
|
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
133
134
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
134
135
|
}
|
135
|
-
#finish the
|
136
|
+
#finish the Cnp Request, indicating we plan to add no more batches
|
136
137
|
request.finish_request
|
137
|
-
entries = Dir.entries(dir +
|
138
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
138
139
|
assert_equal 3, entries.length
|
139
140
|
entries.sort!
|
140
141
|
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+.complete\z/
|
141
142
|
|
142
143
|
#send the batch files at the given directory over sFTP
|
143
144
|
|
144
|
-
request.
|
145
|
-
entries = Dir.entries(dir +
|
146
|
-
encrypted_entries = Dir.entries(dir +
|
145
|
+
request.send_to_cnp()
|
146
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
147
|
+
encrypted_entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
147
148
|
|
148
149
|
assert_equal entries.length, 4
|
149
150
|
entries.sort!
|
@@ -156,16 +157,16 @@ module LitleOnline
|
|
156
157
|
#grab the expected number of responses from the sFTP server and save them to the given path
|
157
158
|
request.get_responses_from_server()
|
158
159
|
#process the responses from the server with a listener which applies the given block
|
159
|
-
request.process_responses({:transaction_listener =>
|
160
|
+
request.process_responses({:transaction_listener => CnpOnline::DefaultCnpListener.new do |transaction| end})
|
160
161
|
|
161
|
-
entries = Dir.entries(dir +
|
162
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
162
163
|
|
163
164
|
assert_equal 5, entries.length
|
164
165
|
entries.sort!
|
165
166
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
166
|
-
File.delete(dir +
|
167
|
+
File.delete(dir + CNP_SDK_TEST_FOLDER + '/' + entries[3])
|
167
168
|
|
168
|
-
entries = Dir.entries(dir +
|
169
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + entries[4])
|
169
170
|
entries.sort!
|
170
171
|
assert_equal 4, entries.length
|
171
172
|
assert_not_nil entries[3] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}.processed\z/
|
@@ -173,9 +174,9 @@ module LitleOnline
|
|
173
174
|
|
174
175
|
|
175
176
|
def test_full_flow_with_deleteBatchFiles
|
176
|
-
ENV['
|
177
|
-
config_dir = ENV['
|
178
|
-
ENV['
|
177
|
+
ENV['cnp_deleteBatchFiles'] = 'true'
|
178
|
+
config_dir = ENV['CNP_CONFIG_DIR']
|
179
|
+
ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
|
179
180
|
|
180
181
|
saleHash = {
|
181
182
|
'reportGroup'=>'Planets',
|
@@ -191,12 +192,12 @@ module LitleOnline
|
|
191
192
|
|
192
193
|
dir = '/tmp'
|
193
194
|
|
194
|
-
request =
|
195
|
-
ENV['
|
196
|
-
ENV['
|
197
|
-
request.
|
195
|
+
request = CnpRequest.new()
|
196
|
+
ENV['CNP_CONFIG_DIR'] = config_dir
|
197
|
+
ENV['cnp_deleteBatchFiles'] = 'false'
|
198
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
198
199
|
|
199
|
-
entries = Dir.entries(dir +
|
200
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
200
201
|
entries.sort!
|
201
202
|
|
202
203
|
assert_equal 4, entries.size
|
@@ -205,10 +206,10 @@ module LitleOnline
|
|
205
206
|
|
206
207
|
#create five batches, each with 10 sales
|
207
208
|
5.times{
|
208
|
-
batch =
|
209
|
-
batch.create_new_batch(dir +
|
209
|
+
batch = CnpBatchRequest.new
|
210
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
210
211
|
|
211
|
-
entries = Dir.entries(dir +
|
212
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
212
213
|
|
213
214
|
assert_equal 6, entries.length
|
214
215
|
entries.sort!
|
@@ -225,7 +226,7 @@ module LitleOnline
|
|
225
226
|
|
226
227
|
#close the batch, indicating we plan to add no more transactions
|
227
228
|
batch.close_batch()
|
228
|
-
entries = Dir.entries(dir +
|
229
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
229
230
|
|
230
231
|
assert_equal 5, entries.length
|
231
232
|
entries.sort!
|
@@ -233,26 +234,26 @@ module LitleOnline
|
|
233
234
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
234
235
|
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
235
236
|
|
236
|
-
#add the batch to the
|
237
|
+
#add the batch to the CnpRequest
|
237
238
|
request.commit_batch(batch)
|
238
|
-
entries = Dir.entries(dir +
|
239
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
239
240
|
assert_equal 4, entries.length
|
240
241
|
entries.sort!
|
241
242
|
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
242
243
|
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
243
244
|
}
|
244
|
-
#finish the
|
245
|
+
#finish the Cnp Request, indicating we plan to add no more batches
|
245
246
|
request.finish_request
|
246
|
-
entries = Dir.entries(dir +
|
247
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
247
248
|
assert_equal 3, entries.length
|
248
249
|
entries.sort!
|
249
250
|
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+.complete\z/
|
250
251
|
|
251
252
|
#send the batch files at the given directory over sFTP
|
252
253
|
|
253
|
-
request.
|
254
|
-
entries = Dir.entries(dir +
|
255
|
-
encrypted_entries = Dir.entries(dir +
|
254
|
+
request.send_to_cnp()
|
255
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
256
|
+
encrypted_entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + ENCRYPTED_PATH_DIR)
|
256
257
|
|
257
258
|
assert_equal 3, entries.length
|
258
259
|
entries.sort!
|
@@ -264,17 +265,17 @@ module LitleOnline
|
|
264
265
|
#grab the expected number of responses from the sFTP server and save them to the given path
|
265
266
|
request.get_responses_from_server()
|
266
267
|
|
267
|
-
entries = Dir.entries(dir +
|
268
|
-
encrypted_entries = Dir.entries(dir +
|
268
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR)
|
269
|
+
encrypted_entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR + ENCRYPTED_PATH_DIR)
|
269
270
|
assert_equal 4, entries.length
|
270
271
|
entries.sort!
|
271
272
|
assert_not_nil entries[3] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}\z/
|
272
273
|
assert_equal 2, encrypted_entries.length
|
273
274
|
|
274
275
|
#process the responses from the server with a listener which applies the given block
|
275
|
-
request.process_responses({:transaction_listener =>
|
276
|
+
request.process_responses({:transaction_listener => CnpOnline::DefaultCnpListener.new do |transaction| end})
|
276
277
|
|
277
|
-
entries = Dir.entries(dir +
|
278
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR)
|
278
279
|
assert_equal 3, entries.length
|
279
280
|
entries.sort!
|
280
281
|
assert_not_nil entries[2] =~ /encrypted/
|
@@ -23,9 +23,9 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
25
|
|
26
|
-
require File.expand_path("../../../lib/
|
26
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
27
27
|
require 'test/unit'
|
28
|
-
module
|
28
|
+
module CnpOnline
|
29
29
|
class TestqueryTransaction < Test::Unit::TestCase
|
30
30
|
def test_queryTransaction
|
31
31
|
hash = {
|
@@ -40,8 +40,8 @@ module LitleOnline
|
|
40
40
|
'orderId'=>'65347567',
|
41
41
|
#'origAccountNumber' => '4000000000000001'
|
42
42
|
}
|
43
|
-
response=
|
44
|
-
assert_equal('
|
43
|
+
response= CnpOnlineRequest.new.query_Transaction(hash)
|
44
|
+
assert_equal('150', response.queryTransactionResponse.response)
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_queryTransaction_valid_enum
|
@@ -57,7 +57,7 @@ module LitleOnline
|
|
57
57
|
'orderId'=>'65347567',
|
58
58
|
#'origAccountNumber' => '4000000000000001'
|
59
59
|
}
|
60
|
-
response=
|
60
|
+
response= CnpOnlineRequest.new.query_Transaction(hash)
|
61
61
|
assert('000', response.queryTransactionResponse.response)
|
62
62
|
end
|
63
63
|
|
@@ -74,7 +74,7 @@ module LitleOnline
|
|
74
74
|
#'origAccountNumber' => '4000000000000001'
|
75
75
|
}
|
76
76
|
#Get exceptions
|
77
|
-
exception = assert_raise(RuntimeError){
|
77
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
78
78
|
#Test
|
79
79
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
80
80
|
end
|
@@ -92,7 +92,7 @@ module LitleOnline
|
|
92
92
|
#'origAccountNumber' => '4000000000000001'
|
93
93
|
}
|
94
94
|
#Get exceptions
|
95
|
-
exception = assert_raise(RuntimeError){
|
95
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
96
96
|
#Test
|
97
97
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
98
98
|
end
|
@@ -111,7 +111,7 @@ module LitleOnline
|
|
111
111
|
#'origAccountNumber' => '4000000000000001'
|
112
112
|
}
|
113
113
|
#Get exceptions
|
114
|
-
exception = assert_raise(RuntimeError){
|
114
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
115
115
|
#Test
|
116
116
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
117
117
|
end
|
@@ -127,7 +127,7 @@ module LitleOnline
|
|
127
127
|
#'origAccountNumber' => '4000000000000001'
|
128
128
|
}
|
129
129
|
#Get exceptions
|
130
|
-
exception = assert_raise(RuntimeError){
|
130
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
131
131
|
#Test
|
132
132
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
133
133
|
end
|
@@ -145,7 +145,7 @@ module LitleOnline
|
|
145
145
|
'orderId'=>'65347567',
|
146
146
|
#'origAccountNumber' => '4000000000000001'
|
147
147
|
}
|
148
|
-
response=
|
148
|
+
response= CnpOnlineRequest.new.query_Transaction(hash)
|
149
149
|
assert_equal('152', response.queryTransactionUnavailableResponse.response)
|
150
150
|
end
|
151
151
|
end
|