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
@@ -19,21 +19,21 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
19
19
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
20
20
|
OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
=end
|
22
|
-
require File.expand_path("../../../lib/
|
22
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
23
23
|
require 'test/unit'
|
24
24
|
require 'mocha/setup'
|
25
25
|
|
26
|
-
module
|
26
|
+
module CnpOnline
|
27
27
|
|
28
|
-
class
|
28
|
+
class TestCnpRequest < Test::Unit::TestCase
|
29
29
|
|
30
30
|
def test_create_with_file
|
31
|
-
request =
|
31
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
32
32
|
'user'=>'john',
|
33
33
|
'password'=>'tinkleberry'})
|
34
34
|
message = ""
|
35
35
|
File.expects(:file?).with('/durrrrrr').returns(true).once
|
36
|
-
request.
|
36
|
+
request.create_new_cnp_request('/durrrrrr')
|
37
37
|
|
38
38
|
rescue RuntimeError=> e
|
39
39
|
message = e.message
|
@@ -42,16 +42,16 @@ module LitleOnline
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_create_with_no_sep
|
45
|
-
request =
|
45
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
46
46
|
'user'=>'john',
|
47
47
|
'password'=>'tinkleberry'})
|
48
48
|
File.expects(:open).twice
|
49
|
-
request.
|
49
|
+
request.create_new_cnp_request('/usr/local')
|
50
50
|
assert request.get_path_to_batches.include?('/usr/local/')
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_create_name_collision
|
54
|
-
request =
|
54
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
55
55
|
'user'=>'john',
|
56
56
|
'password'=>'tinkleberry'})
|
57
57
|
|
@@ -62,11 +62,11 @@ module LitleOnline
|
|
62
62
|
File.expects(:file?).returns(false).twice.in_sequence(create_new) #or's don't quit
|
63
63
|
File.expects(:open).twice.in_sequence(create_new)
|
64
64
|
|
65
|
-
request.
|
65
|
+
request.create_new_cnp_request('/usr/local')
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_create_normal
|
69
|
-
request =
|
69
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
70
70
|
'user'=>'john',
|
71
71
|
'password'=>'tinkleberry'})
|
72
72
|
|
@@ -76,10 +76,10 @@ module LitleOnline
|
|
76
76
|
File.expects(:open).once.in_sequence(create_new)
|
77
77
|
File.expects(:open).once.in_sequence(create_new)
|
78
78
|
|
79
|
-
request.
|
79
|
+
request.create_new_cnp_request('/usr/local')
|
80
80
|
end
|
81
81
|
|
82
|
-
def
|
82
|
+
def test_add_rfr_request_cnp_session
|
83
83
|
add_rfr = sequence('add_rfr')
|
84
84
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(1).in_sequence(add_rfr)
|
85
85
|
|
@@ -88,27 +88,27 @@ module LitleOnline
|
|
88
88
|
File.expects(:open).with(regexp_matches(/request_\d+\z/), 'a+').in_sequence(add_rfr)
|
89
89
|
File.expects(:rename).with(regexp_matches(/request_\d+\z/), regexp_matches(/request_\d+.complete\z/)).in_sequence(add_rfr)
|
90
90
|
|
91
|
-
request =
|
91
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
92
92
|
'user'=>'john',
|
93
93
|
'password'=>'tinkleberry'})
|
94
94
|
|
95
|
-
request.add_rfr_request({'
|
95
|
+
request.add_rfr_request({'cnpSessionId' => '137813712'}, '/usr/srv')
|
96
96
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_commit_batch_with_batch
|
100
100
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(2)
|
101
101
|
|
102
|
-
request =
|
102
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
103
103
|
'user'=>'john',
|
104
104
|
'password'=>'tinkleberry'})
|
105
105
|
File.expects(:file?).returns(false).once
|
106
106
|
File.expects(:file?).returns(false).twice #or's don't quit
|
107
107
|
File.expects(:open).twice
|
108
108
|
File.expects(:directory?).returns(true).once
|
109
|
-
request.
|
109
|
+
request.create_new_cnp_request("/usr/srv/batches")
|
110
110
|
|
111
|
-
batch =
|
111
|
+
batch = CnpBatchRequest.new
|
112
112
|
File.expects(:open).twice
|
113
113
|
File.expects(:file?).returns(false).twice
|
114
114
|
File.expects(:directory?).returns(true).once
|
@@ -126,14 +126,14 @@ module LitleOnline
|
|
126
126
|
def test_commit_batch_with_path
|
127
127
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(1)
|
128
128
|
|
129
|
-
request =
|
129
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
130
130
|
'user'=>'john',
|
131
131
|
'password'=>'tinkleberry'})
|
132
132
|
File.expects(:file?).returns(false).once
|
133
133
|
File.expects(:file?).returns(false).twice #or's don't quit
|
134
134
|
File.expects(:open).twice
|
135
135
|
File.expects(:directory?).returns(true).once
|
136
|
-
request.
|
136
|
+
request.create_new_cnp_request("/usr/srv/batches")
|
137
137
|
|
138
138
|
File.expects(:open).with(regexp_matches(/.*_batches.*/), 'a+')
|
139
139
|
File.expects(:delete).with(regexp_matches(/.*\.closed.*/))
|
@@ -142,12 +142,12 @@ module LitleOnline
|
|
142
142
|
|
143
143
|
def test_add_bad_object
|
144
144
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
145
|
-
request =
|
145
|
+
request = CnpRequest.new({})
|
146
146
|
request.commit_batch({:apple => "pear"})
|
147
147
|
test = ""
|
148
148
|
rescue RuntimeError => e
|
149
149
|
test = e.message
|
150
|
-
assert_equal "You entered neither a path nor a batch." ,test
|
150
|
+
assert_equal "You entered neither a path nor a batch. Game over :(" ,test
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_add_open_batch
|
@@ -155,9 +155,9 @@ module LitleOnline
|
|
155
155
|
File.expects(:open).with(regexp_matches(/\/usr\/srv\/.*/), 'a+').times(2)
|
156
156
|
|
157
157
|
Dir.expects(:mkdir).with('/usr/srv/batches/').once
|
158
|
-
batch =
|
158
|
+
batch = CnpBatchRequest.new
|
159
159
|
batch.create_new_batch('/usr/srv/batches')
|
160
|
-
request =
|
160
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
161
161
|
'user'=>'john',
|
162
162
|
'password'=>'tinkleberry'})
|
163
163
|
|
@@ -174,14 +174,14 @@ module LitleOnline
|
|
174
174
|
def test_batch_too_big
|
175
175
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(1)
|
176
176
|
|
177
|
-
request =
|
177
|
+
request = CnpRequest.new({'sessionId'=>'8675309',
|
178
178
|
'user'=>'john',
|
179
179
|
'password'=>'tinkleberry'})
|
180
180
|
File.expects(:file?).returns(false).once
|
181
181
|
File.expects(:file?).returns(false).twice #or's don't quit
|
182
182
|
File.expects(:open).twice
|
183
183
|
File.expects(:directory?).returns(true).once
|
184
|
-
request.
|
184
|
+
request.create_new_cnp_request("/usr/srv/batches")
|
185
185
|
create_new = sequence('create_new')
|
186
186
|
|
187
187
|
File.expects(:open).with(regexp_matches(/.*_batches.*/), 'a+').times(5)
|
@@ -193,7 +193,7 @@ module LitleOnline
|
|
193
193
|
|
194
194
|
request.expects(:finish_request).once
|
195
195
|
request.expects(:initialize).once
|
196
|
-
request.expects(:
|
196
|
+
request.expects(:create_new_cnp_request).once
|
197
197
|
request.commit_batch("/usr/srv/batches/batch_123123131231.closed-100000")
|
198
198
|
end
|
199
199
|
|
@@ -204,12 +204,12 @@ module LitleOnline
|
|
204
204
|
reader.expects(:read).once.in_sequence(xml)
|
205
205
|
reader.expects(:get_attribute).with('response').returns("0").in_sequence(xml)
|
206
206
|
reader.expects(:read).once.in_sequence(xml)
|
207
|
-
reader.expects(:node).returns(node = LibXML::XML::Node.new("
|
207
|
+
reader.expects(:node).returns(node = LibXML::XML::Node.new("cnpResponse")).twice.in_sequence(xml)
|
208
208
|
|
209
|
-
request =
|
209
|
+
request = CnpRequest.new({})
|
210
210
|
request.process_response(Dir.pwd + '/responses/good_xml.xml' ,
|
211
|
-
|
212
|
-
|
211
|
+
DefaultCnpListener.new{|txn| puts txn["type"]} ,
|
212
|
+
DefaultCnpListener.new{|batch| } )
|
213
213
|
end
|
214
214
|
|
215
215
|
def test_process_response_xml_error
|
@@ -218,63 +218,63 @@ module LitleOnline
|
|
218
218
|
reader.expects(:get_attribute).with('response').twice.returns(4)
|
219
219
|
reader.expects(:get_attribute).with("message").returns("Error validating xml data against the schema")
|
220
220
|
|
221
|
-
request =
|
221
|
+
request = CnpRequest.new({})
|
222
222
|
response = ''
|
223
223
|
begin
|
224
224
|
request.process_response(Dir.pwd + '/responses/bad_xml.xml' ,
|
225
|
-
|
226
|
-
|
225
|
+
DefaultCnpListener.new{|txn| puts txn["type"]} ,
|
226
|
+
DefaultCnpListener.new{|batch| } )
|
227
227
|
rescue Exception => e
|
228
228
|
response = e.message
|
229
229
|
end
|
230
|
-
assert_equal "Error parsing
|
230
|
+
assert_equal "Error parsing Cnp Request: Error validating xml data against the schema", response.to_s
|
231
231
|
end
|
232
232
|
|
233
233
|
def test_process_responses
|
234
|
-
request =
|
235
|
-
listener =
|
234
|
+
request = CnpRequest.new({})
|
235
|
+
listener = DefaultCnpListener.new
|
236
236
|
args = {:transaction_listener=>listener,:path_to_responses=>"fake/path/"}
|
237
237
|
args.expects(:[]).with(:transaction_listener)
|
238
238
|
args.expects(:[]).with(:batch_listener).returns(nil)
|
239
239
|
args.expects(:[]).with(:path_to_responses).returns("fake/path/")
|
240
240
|
args.expects(:[]).twice.with(:deleteBatchFiles)
|
241
241
|
args.expects(:[]).with("deleteBatchFiles")
|
242
|
-
Dir.expects(:foreach).with("fake/path/")
|
242
|
+
Dir.expects(:foreach).with("fake/path/")
|
243
243
|
|
244
244
|
request.process_responses(args)
|
245
245
|
end
|
246
246
|
|
247
247
|
def test_get_responses_from_server
|
248
|
-
request =
|
248
|
+
request = CnpRequest.new({})
|
249
249
|
resp_seq = sequence("resp_seq")
|
250
250
|
args = {:responses_expected=>4, :response_path=>"new/path", :sftp_username=>"periwinkle",:sftp_password=>"password", :sftp_url=>"reddit.com"}
|
251
251
|
|
252
252
|
File.expects(:directory?).with("new/path/").returns(false).once.in_sequence(resp_seq)
|
253
253
|
Dir.expects(:mkdir).with("new/path/").once.in_sequence(resp_seq)
|
254
|
-
Net::SFTP.expects(:start).with("reddit.com", "periwinkle", :password=>"password")
|
254
|
+
Net::SFTP.expects(:start).once.with("reddit.com", "periwinkle", :password=>"password")
|
255
255
|
|
256
256
|
request.get_responses_from_server(args)
|
257
257
|
end
|
258
258
|
|
259
259
|
def test_send_over_stream
|
260
|
-
request =
|
260
|
+
request = CnpRequest.new({})
|
261
261
|
req_seq = sequence('request')
|
262
262
|
|
263
263
|
File.expects(:directory?).with(regexp_matches(/responses\//)).once.returns(false).in_sequence(req_seq)
|
264
264
|
Dir.expects(:mkdir).with(regexp_matches(/responses\//)).once.in_sequence(req_seq)
|
265
265
|
Dir.expects(:foreach).once.in_sequence(req_seq)
|
266
266
|
|
267
|
-
request.
|
267
|
+
request.send_to_cnp_stream({:fast_url=>"www.redit.com", :fast_port=>"2313"})
|
268
268
|
end
|
269
269
|
|
270
270
|
def test_send_over_stream_bad_crds
|
271
|
-
request =
|
271
|
+
request = CnpRequest.new({})
|
272
272
|
|
273
273
|
assert_raise ArgumentError do
|
274
|
-
request.
|
274
|
+
request.send_to_cnp_stream({:fast_url=>"", :fast_port=>""})
|
275
275
|
end
|
276
276
|
end
|
277
|
-
#Outputs an example
|
277
|
+
#Outputs an example CnpRequest doc in the current directory
|
278
278
|
# def test_finish_request_xml! #that's why the name has a bang
|
279
279
|
# # see the bang up there ^^^ that means we ACTUALLY edit the file system
|
280
280
|
# # make sure to clear this; otherwise, you're gonna have a bad time.
|
@@ -292,14 +292,14 @@ module LitleOnline
|
|
292
292
|
# 'expDate' =>'1210'
|
293
293
|
# }}
|
294
294
|
#
|
295
|
-
# request =
|
295
|
+
# request = CnpRequest.new({'sessionId'=>'8675309',
|
296
296
|
# 'user'=>'john',
|
297
297
|
# 'password'=>'tinkleberry'})
|
298
|
-
# request.
|
298
|
+
# request.create_new_cnp_request(path)
|
299
299
|
#
|
300
300
|
#
|
301
301
|
# #5.times{
|
302
|
-
# batch =
|
302
|
+
# batch = CnpBatchRequest.new
|
303
303
|
# batch.create_new_batch(path)
|
304
304
|
# puts "Batch is at: " + batch.get_batch_name
|
305
305
|
#
|
@@ -22,18 +22,18 @@ 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
|
|
27
27
|
require 'test/unit'
|
28
28
|
require 'mocha/setup'
|
29
29
|
|
30
|
-
module
|
30
|
+
module CnpOnline
|
31
31
|
|
32
|
-
class
|
32
|
+
class TestCnpTransaction < Test::Unit::TestCase
|
33
33
|
|
34
34
|
|
35
35
|
def test_authorization
|
36
|
-
ltlTxn =
|
36
|
+
ltlTxn = CnpTransaction.new
|
37
37
|
authHash = {
|
38
38
|
'reportGroup'=>'Planets',
|
39
39
|
'id'=>'12345',
|
@@ -60,7 +60,7 @@ module LitleOnline
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_sale
|
63
|
-
ltlTxn =
|
63
|
+
ltlTxn = CnpTransaction.new
|
64
64
|
saleHash = {
|
65
65
|
'reportGroup'=>'Planets',
|
66
66
|
'id'=>'12345',
|
@@ -87,7 +87,7 @@ module LitleOnline
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def test_credit
|
90
|
-
ltlTxn =
|
90
|
+
ltlTxn = CnpTransaction.new
|
91
91
|
creditHash = {
|
92
92
|
'merchantId' => '101',
|
93
93
|
'version'=>'8.8',
|
@@ -116,14 +116,14 @@ module LitleOnline
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def test_auth_reversal
|
119
|
-
ltlTxn =
|
119
|
+
ltlTxn = CnpTransaction.new
|
120
120
|
authReversalHash = {
|
121
121
|
'merchantId' => '101',
|
122
122
|
'version'=>'8.8',
|
123
123
|
'reportGroup'=>'Planets',
|
124
124
|
'id'=>'12345',
|
125
125
|
'customerId'=>'0987',
|
126
|
-
'
|
126
|
+
'cnpTxnId'=>'12345678000',
|
127
127
|
'amount'=>'106',
|
128
128
|
'payPalNotes'=>'Notes'
|
129
129
|
}
|
@@ -132,13 +132,13 @@ module LitleOnline
|
|
132
132
|
assert_equal 'Planets', result.reportGroup
|
133
133
|
assert_equal '12345', result.transactionId
|
134
134
|
assert_equal '0987', result.customerId
|
135
|
-
assert_equal '12345678000', result.
|
135
|
+
assert_equal '12345678000', result.cnpTxnId
|
136
136
|
assert_equal '106', result.amount
|
137
137
|
assert_equal 'Notes', result.payPalNotes
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_register_token_request
|
141
|
-
ltlTxn =
|
141
|
+
ltlTxn = CnpTransaction.new
|
142
142
|
registerTokenHash = {
|
143
143
|
'merchantId' => '101',
|
144
144
|
'version'=>'8.8',
|
@@ -158,7 +158,7 @@ module LitleOnline
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def test_update_card_validation_num_on_token
|
161
|
-
ltlTxn =
|
161
|
+
ltlTxn = CnpTransaction.new
|
162
162
|
updateCardHash = {
|
163
163
|
'merchantId' => '101',
|
164
164
|
'version'=>'8.8',
|
@@ -166,7 +166,7 @@ module LitleOnline
|
|
166
166
|
'id'=>'12345',
|
167
167
|
'customerId'=>'0987',
|
168
168
|
'orderId'=>'12344',
|
169
|
-
'
|
169
|
+
'cnpToken'=>'1233456789103801',
|
170
170
|
'cardValidationNum'=>'123'
|
171
171
|
}
|
172
172
|
|
@@ -175,12 +175,12 @@ module LitleOnline
|
|
175
175
|
assert_equal '12345', result.transactionId
|
176
176
|
assert_equal '0987', result.customerId
|
177
177
|
assert_equal '12344', result.orderId
|
178
|
-
assert_equal '1233456789103801', result.
|
178
|
+
assert_equal '1233456789103801', result.cnpToken
|
179
179
|
assert_equal '123', result.cardValidationNum
|
180
180
|
end
|
181
181
|
|
182
182
|
def test_force_capture
|
183
|
-
ltlTxn =
|
183
|
+
ltlTxn = CnpTransaction.new
|
184
184
|
forceCaptHash = {
|
185
185
|
'merchantId' => '101',
|
186
186
|
'version'=>'8.8',
|
@@ -209,14 +209,14 @@ module LitleOnline
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def test_capture
|
212
|
-
ltlTxn =
|
212
|
+
ltlTxn = CnpTransaction.new
|
213
213
|
captHash = {
|
214
214
|
'merchantId' => '101',
|
215
215
|
'version'=>'8.8',
|
216
216
|
'reportGroup'=>'Planets',
|
217
217
|
'id'=>'12345',
|
218
218
|
'customerId'=>'0987',
|
219
|
-
'
|
219
|
+
'cnpTxnId'=>'123456000',
|
220
220
|
'amount'=>'106',
|
221
221
|
}
|
222
222
|
|
@@ -224,12 +224,12 @@ module LitleOnline
|
|
224
224
|
assert_equal 'Planets', result.reportGroup
|
225
225
|
assert_equal '12345', result.transactionId
|
226
226
|
assert_equal '0987', result.customerId
|
227
|
-
assert_equal '123456000', result.
|
227
|
+
assert_equal '123456000', result.cnpTxnId
|
228
228
|
assert_equal '106', result.amount
|
229
229
|
end
|
230
230
|
|
231
231
|
def test_capture_given_auth
|
232
|
-
ltlTxn =
|
232
|
+
ltlTxn = CnpTransaction.new
|
233
233
|
captGivenAuthHash = {
|
234
234
|
'merchantId' => '101',
|
235
235
|
'version'=>'8.8',
|
@@ -266,7 +266,7 @@ module LitleOnline
|
|
266
266
|
end
|
267
267
|
|
268
268
|
def test_echeck_verification
|
269
|
-
ltlTxn =
|
269
|
+
ltlTxn = CnpTransaction.new
|
270
270
|
echeckVerificationHash = {
|
271
271
|
'merchantId' => '101',
|
272
272
|
'version'=>'8.8',
|
@@ -283,7 +283,7 @@ module LitleOnline
|
|
283
283
|
'billToAddress'=>{'name'=>'Bob',
|
284
284
|
'city'=>'lowell',
|
285
285
|
'state'=>'MA',
|
286
|
-
'email'=>'
|
286
|
+
'email'=>'cnp.com'}
|
287
287
|
}
|
288
288
|
|
289
289
|
result = ltlTxn.echeck_verification(echeckVerificationHash)
|
@@ -300,18 +300,18 @@ module LitleOnline
|
|
300
300
|
assert_equal 'Bob', result.billToAddress.name
|
301
301
|
assert_equal 'lowell', result.billToAddress.city
|
302
302
|
assert_equal 'MA', result.billToAddress.state
|
303
|
-
assert_equal '
|
303
|
+
assert_equal 'cnp.com', result.billToAddress.email
|
304
304
|
end
|
305
305
|
|
306
306
|
def test_echeck_credit
|
307
|
-
ltlTxn =
|
307
|
+
ltlTxn = CnpTransaction.new
|
308
308
|
echeckCreditHash = {
|
309
309
|
'merchantId' => '101',
|
310
310
|
'version'=>'8.8',
|
311
311
|
'reportGroup'=>'Planets',
|
312
312
|
'id'=>'12345',
|
313
313
|
'customerId'=>'0987',
|
314
|
-
'
|
314
|
+
'cnpTxnId'=>'123456789101112',
|
315
315
|
'amount'=>'12'
|
316
316
|
}
|
317
317
|
|
@@ -319,30 +319,30 @@ module LitleOnline
|
|
319
319
|
assert_equal 'Planets', result.reportGroup
|
320
320
|
assert_equal '12345', result.transactionId
|
321
321
|
assert_equal '0987', result.customerId
|
322
|
-
assert_equal '123456789101112', result.
|
322
|
+
assert_equal '123456789101112', result.cnpTxnId
|
323
323
|
assert_equal '12', result.amount
|
324
324
|
end
|
325
325
|
|
326
326
|
def test_echeck_redeposit
|
327
|
-
ltlTxn =
|
327
|
+
ltlTxn = CnpTransaction.new
|
328
328
|
echeckRedeopsitHash = {
|
329
329
|
'merchantId' => '101',
|
330
330
|
'version'=>'8.8',
|
331
331
|
'reportGroup'=>'Planets',
|
332
332
|
'id'=>'12345',
|
333
333
|
'customerId'=>'0987',
|
334
|
-
'
|
334
|
+
'cnpTxnId'=>'123456'
|
335
335
|
}
|
336
336
|
|
337
337
|
result = ltlTxn.echeck_redeposit(echeckRedeopsitHash)
|
338
338
|
assert_equal 'Planets', result.reportGroup
|
339
339
|
assert_equal '12345', result.transactionId
|
340
340
|
assert_equal '0987', result.customerId
|
341
|
-
assert_equal '123456', result.
|
341
|
+
assert_equal '123456', result.cnpTxnId
|
342
342
|
end
|
343
343
|
|
344
344
|
def test_echeck_sale
|
345
|
-
ltlTxn =
|
345
|
+
ltlTxn = CnpTransaction.new
|
346
346
|
echeckSaleHash = {
|
347
347
|
'merchantId' => '101',
|
348
348
|
'version'=>'8.8',
|
@@ -354,7 +354,7 @@ module LitleOnline
|
|
354
354
|
'orderId'=>'12345',
|
355
355
|
'orderSource'=>'ecommerce',
|
356
356
|
'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
|
357
|
-
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'
|
357
|
+
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'cnp.com'}
|
358
358
|
}
|
359
359
|
|
360
360
|
result = ltlTxn.echeck_sale(echeckSaleHash)
|
@@ -372,11 +372,11 @@ module LitleOnline
|
|
372
372
|
assert_equal 'Bob', result.billToAddress.name
|
373
373
|
assert_equal 'lowell', result.billToAddress.city
|
374
374
|
assert_equal 'MA', result.billToAddress.state
|
375
|
-
assert_equal '
|
375
|
+
assert_equal 'cnp.com', result.billToAddress.email
|
376
376
|
end
|
377
377
|
|
378
378
|
def test_account_update
|
379
|
-
ltlTxn =
|
379
|
+
ltlTxn = CnpTransaction.new
|
380
380
|
accountUpdateHash = {
|
381
381
|
'reportGroup'=>'Planets',
|
382
382
|
'id'=>'12345',
|
@@ -398,7 +398,7 @@ module LitleOnline
|
|
398
398
|
|
399
399
|
|
400
400
|
def test_queryTransaction
|
401
|
-
ltlTxn =
|
401
|
+
ltlTxn = CnpTransaction.new
|
402
402
|
queryTransactionHash = {
|
403
403
|
'merchantId' => '101',
|
404
404
|
'version'=>'8.8',
|
@@ -407,7 +407,7 @@ module LitleOnline
|
|
407
407
|
'customerId'=>'0987',
|
408
408
|
'origId'=>'834262',
|
409
409
|
'origActionType'=>'A',
|
410
|
-
'
|
410
|
+
'origCnpTxnId'=>'123456',
|
411
411
|
'origOrderId' => '65347567',
|
412
412
|
'origAccountNumber'=>'4000000000000001'
|
413
413
|
}
|
@@ -418,7 +418,7 @@ module LitleOnline
|
|
418
418
|
assert_equal '0987', result.customerId
|
419
419
|
assert_equal '834262', result.origId
|
420
420
|
assert_equal 'A', result.origActionType
|
421
|
-
assert_equal '123456', result.
|
421
|
+
assert_equal '123456', result.origCnpTxnId
|
422
422
|
#assert_equal '65347567', result.origOrderId
|
423
423
|
#assert_equal '4000000000000001', result.origAccountNumber
|
424
424
|
end
|