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,20 +22,20 @@ 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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
|
31
|
-
class
|
31
|
+
class TestCnpAUBatch < Test::Unit::TestCase
|
32
32
|
def test_create_new_batch
|
33
33
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
34
34
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').twice
|
35
35
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
36
36
|
File.expects(:directory?).returns(false).once
|
37
37
|
|
38
|
-
batch =
|
38
|
+
batch = CnpAUBatch.new
|
39
39
|
batch.create_new_batch('/usr/local/Batches/')
|
40
40
|
end
|
41
41
|
|
@@ -56,7 +56,7 @@ module LitleOnline
|
|
56
56
|
'expDate' =>'1210'
|
57
57
|
}}
|
58
58
|
|
59
|
-
batch =
|
59
|
+
batch = CnpAUBatch.new
|
60
60
|
batch.create_new_batch('D:\Batches\\')
|
61
61
|
batch.account_update(accountUpdateHash)
|
62
62
|
|
@@ -74,7 +74,7 @@ module LitleOnline
|
|
74
74
|
File.expects(:delete).once
|
75
75
|
File.expects(:directory?).returns(true).once
|
76
76
|
|
77
|
-
batch =
|
77
|
+
batch = CnpAUBatch.new
|
78
78
|
batch.create_new_batch('D:\Batches\\')
|
79
79
|
|
80
80
|
batch.close_batch()
|
@@ -97,8 +97,8 @@ module LitleOnline
|
|
97
97
|
File.expects(:rename).once.in_sequence(open)
|
98
98
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once.in_sequence(open)
|
99
99
|
File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once.in_sequence(open)
|
100
|
-
batch1 =
|
101
|
-
batch2 =
|
100
|
+
batch1 = CnpAUBatch.new
|
101
|
+
batch2 = CnpAUBatch.new
|
102
102
|
batch1.create_new_batch('/usr/local/Batches/')
|
103
103
|
|
104
104
|
batch2.open_existing_batch(batch1.get_batch_name)
|
@@ -114,7 +114,7 @@ module LitleOnline
|
|
114
114
|
File.expects(:delete).once
|
115
115
|
File.expects(:directory?).returns(true).once
|
116
116
|
|
117
|
-
batch =
|
117
|
+
batch = CnpAUBatch.new
|
118
118
|
batch.get_counts_and_amounts.expects(:[]).returns(hash = Hash.new).at_least(5)
|
119
119
|
|
120
120
|
batch.create_new_batch('/usr/local/batches')
|
@@ -126,7 +126,7 @@ module LitleOnline
|
|
126
126
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
127
127
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').once
|
128
128
|
|
129
|
-
batch =
|
129
|
+
batch = CnpAUBatch.new
|
130
130
|
batch.create_new_batch('/usr/local')
|
131
131
|
|
132
132
|
assert batch.get_batch_name.include?('/usr/local/')
|
@@ -144,14 +144,14 @@ module LitleOnline
|
|
144
144
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(fileExists)
|
145
145
|
|
146
146
|
|
147
|
-
batch =
|
147
|
+
batch = CnpAUBatch.new
|
148
148
|
batch.create_new_batch('/usr/local/')
|
149
149
|
end
|
150
150
|
|
151
151
|
def test_create_new_batch_when_full
|
152
152
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
153
153
|
|
154
|
-
batch =
|
154
|
+
batch = CnpAUBatch.new
|
155
155
|
addTxn = sequence('addTxn')
|
156
156
|
|
157
157
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(addTxn)
|
@@ -190,7 +190,7 @@ module LitleOnline
|
|
190
190
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
191
191
|
File.expects(:directory?).returns(false).once
|
192
192
|
|
193
|
-
batch =
|
193
|
+
batch = CnpAUBatch.new
|
194
194
|
batch.create_new_batch('/usr/local/Batches/')
|
195
195
|
|
196
196
|
accountUpdateHash = {
|
@@ -223,14 +223,14 @@ module LitleOnline
|
|
223
223
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
224
224
|
File.expects(:directory?).returns(false).once
|
225
225
|
|
226
|
-
batch =
|
226
|
+
batch = CnpAUBatch.new
|
227
227
|
batch.create_new_batch('/usr/local/Batches/')
|
228
228
|
|
229
229
|
accountUpdateHash = {
|
230
230
|
'reportGroup'=>'Planets',
|
231
231
|
'id'=>'12345',
|
232
232
|
'customerId'=>'0987',
|
233
|
-
'token'=>{'
|
233
|
+
'token'=>{'cnpToken'=>'1234567890123'
|
234
234
|
}}
|
235
235
|
|
236
236
|
5.times(){ batch.account_update(accountUpdateHash ) }
|
@@ -22,19 +22,19 @@ 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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
30
|
-
class
|
29
|
+
module CnpOnline
|
30
|
+
class TestCnpBatchRequest < Test::Unit::TestCase
|
31
31
|
def test_create_new_batch
|
32
32
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
33
33
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').twice
|
34
34
|
Dir.expects(:mkdir).with('/usr/local/Batches/').once
|
35
35
|
File.expects(:directory?).returns(false).once
|
36
36
|
|
37
|
-
batch =
|
37
|
+
batch = CnpBatchRequest.new
|
38
38
|
batch.create_new_batch('/usr/local/Batches/')
|
39
39
|
end
|
40
40
|
|
@@ -56,7 +56,7 @@ module LitleOnline
|
|
56
56
|
'expDate' =>'1210'
|
57
57
|
}}
|
58
58
|
|
59
|
-
batch =
|
59
|
+
batch = CnpBatchRequest.new
|
60
60
|
batch.create_new_batch('/usr/local/Batches/')
|
61
61
|
|
62
62
|
2.times(){ batch.authorization(authHash) }
|
@@ -85,7 +85,7 @@ module LitleOnline
|
|
85
85
|
'expDate' =>'1210'
|
86
86
|
}}
|
87
87
|
|
88
|
-
batch =
|
88
|
+
batch = CnpBatchRequest.new
|
89
89
|
batch.create_new_batch('D:\Batches\\')
|
90
90
|
batch.sale(saleHash)
|
91
91
|
|
@@ -114,7 +114,7 @@ module LitleOnline
|
|
114
114
|
'expDate' =>'1210'
|
115
115
|
}}
|
116
116
|
|
117
|
-
batch =
|
117
|
+
batch = CnpBatchRequest.new
|
118
118
|
batch.create_new_batch('D:\Batches\\')
|
119
119
|
batch.credit(creditHash)
|
120
120
|
|
@@ -134,12 +134,12 @@ module LitleOnline
|
|
134
134
|
'merchantId' => '101',
|
135
135
|
'version'=>'8.8',
|
136
136
|
'reportGroup'=>'Planets',
|
137
|
-
'
|
137
|
+
'cnpTxnId'=>'12345678000',
|
138
138
|
'amount'=>'106',
|
139
139
|
'payPalNotes'=>'Notes'
|
140
140
|
}
|
141
141
|
|
142
|
-
batch =
|
142
|
+
batch = CnpBatchRequest.new
|
143
143
|
batch.create_new_batch('D:\Batches\\')
|
144
144
|
batch.auth_reversal(authReversalHash)
|
145
145
|
|
@@ -163,7 +163,7 @@ module LitleOnline
|
|
163
163
|
'accountNumber'=>'1233456789103801'
|
164
164
|
}
|
165
165
|
|
166
|
-
batch =
|
166
|
+
batch = CnpBatchRequest.new
|
167
167
|
batch.create_new_batch('D:\Batches\\')
|
168
168
|
batch.register_token_request(registerTokenHash)
|
169
169
|
|
@@ -185,7 +185,7 @@ module LitleOnline
|
|
185
185
|
'subscriptionId'=>'100'
|
186
186
|
}
|
187
187
|
|
188
|
-
batch =
|
188
|
+
batch = CnpBatchRequest.new
|
189
189
|
batch.create_new_batch('D:\Batches\\')
|
190
190
|
batch.cancel_subscription(hash)
|
191
191
|
|
@@ -206,10 +206,10 @@ module LitleOnline
|
|
206
206
|
'reportGroup'=>'Planets',
|
207
207
|
'subscriptionId'=>'100',
|
208
208
|
'planCode'=>'planCodeString',
|
209
|
-
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'
|
209
|
+
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'cnp.com'}
|
210
210
|
}
|
211
211
|
|
212
|
-
batch =
|
212
|
+
batch = CnpBatchRequest.new
|
213
213
|
batch.create_new_batch('D:\Batches\\')
|
214
214
|
batch.update_subscription(hash)
|
215
215
|
|
@@ -229,11 +229,11 @@ module LitleOnline
|
|
229
229
|
'version'=>'8.8',
|
230
230
|
'reportGroup'=>'Planets',
|
231
231
|
'orderId'=>'12344',
|
232
|
-
'
|
232
|
+
'cnpToken'=>'1233456789103801',
|
233
233
|
'cardValidationNum'=>'123'
|
234
234
|
}
|
235
235
|
|
236
|
-
batch =
|
236
|
+
batch = CnpBatchRequest.new
|
237
237
|
batch.create_new_batch('D:\Batches\\')
|
238
238
|
batch.update_card_validation_num_on_token(updateCardHash)
|
239
239
|
|
@@ -252,7 +252,7 @@ module LitleOnline
|
|
252
252
|
'merchantId' => '101',
|
253
253
|
'version'=>'8.8',
|
254
254
|
'reportGroup'=>'Planets',
|
255
|
-
'
|
255
|
+
'cnpTxnId'=>'123456',
|
256
256
|
'orderId'=>'12344',
|
257
257
|
'amount'=>'106',
|
258
258
|
'orderSource'=>'ecommerce',
|
@@ -262,7 +262,7 @@ module LitleOnline
|
|
262
262
|
'expDate' =>'1210'
|
263
263
|
}}
|
264
264
|
|
265
|
-
batch =
|
265
|
+
batch = CnpBatchRequest.new
|
266
266
|
batch.create_new_batch('D:\Batches\\')
|
267
267
|
batch.force_capture(forceCaptHash)
|
268
268
|
|
@@ -282,11 +282,11 @@ module LitleOnline
|
|
282
282
|
'merchantId' => '101',
|
283
283
|
'version'=>'8.8',
|
284
284
|
'reportGroup'=>'Planets',
|
285
|
-
'
|
285
|
+
'cnpTxnId'=>'123456000',
|
286
286
|
'amount'=>'106',
|
287
287
|
}
|
288
288
|
|
289
|
-
batch =
|
289
|
+
batch = CnpBatchRequest.new
|
290
290
|
batch.create_new_batch('D:\Batches\\')
|
291
291
|
batch.capture(captHash)
|
292
292
|
|
@@ -319,7 +319,7 @@ module LitleOnline
|
|
319
319
|
'expDate' =>'1210'
|
320
320
|
}}
|
321
321
|
|
322
|
-
batch =
|
322
|
+
batch = CnpBatchRequest.new
|
323
323
|
batch.create_new_batch('D:\Batches\\')
|
324
324
|
batch.capture_given_auth(captGivenAuthHash)
|
325
325
|
|
@@ -343,10 +343,10 @@ module LitleOnline
|
|
343
343
|
'orderId'=>'12345',
|
344
344
|
'orderSource'=>'ecommerce',
|
345
345
|
'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
|
346
|
-
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'
|
346
|
+
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'cnp.com'}
|
347
347
|
}
|
348
348
|
|
349
|
-
batch =
|
349
|
+
batch = CnpBatchRequest.new
|
350
350
|
batch.create_new_batch('D:\Batches\\')
|
351
351
|
batch.echeck_verification(echeckVerificationHash)
|
352
352
|
|
@@ -366,11 +366,11 @@ module LitleOnline
|
|
366
366
|
'merchantId' => '101',
|
367
367
|
'version'=>'8.8',
|
368
368
|
'reportGroup'=>'Planets',
|
369
|
-
'
|
369
|
+
'cnpTxnId'=>'123456789101112',
|
370
370
|
'amount'=>'12'
|
371
371
|
}
|
372
372
|
|
373
|
-
batch =
|
373
|
+
batch = CnpBatchRequest.new
|
374
374
|
batch.create_new_batch('D:\Batches\\')
|
375
375
|
batch.echeck_credit(echeckCreditHash)
|
376
376
|
|
@@ -390,10 +390,10 @@ module LitleOnline
|
|
390
390
|
'merchantId' => '101',
|
391
391
|
'version'=>'8.8',
|
392
392
|
'reportGroup'=>'Planets',
|
393
|
-
'
|
393
|
+
'cnpTxnId'=>'123456'
|
394
394
|
}
|
395
395
|
|
396
|
-
batch =
|
396
|
+
batch = CnpBatchRequest.new
|
397
397
|
batch.create_new_batch('D:\Batches\\')
|
398
398
|
batch.echeck_redeposit(echeckRedeopsitHash)
|
399
399
|
|
@@ -417,10 +417,10 @@ module LitleOnline
|
|
417
417
|
'orderId'=>'12345',
|
418
418
|
'orderSource'=>'ecommerce',
|
419
419
|
'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
|
420
|
-
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'
|
420
|
+
'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'cnp.com'}
|
421
421
|
}
|
422
422
|
|
423
|
-
batch =
|
423
|
+
batch = CnpBatchRequest.new
|
424
424
|
batch.create_new_batch('D:\Batches\\')
|
425
425
|
batch.echeck_sale(echeckSaleHash)
|
426
426
|
|
@@ -429,36 +429,6 @@ module LitleOnline
|
|
429
429
|
assert_equal 123456, counts[:echeckSale][:echeckSalesAmount]
|
430
430
|
end
|
431
431
|
|
432
|
-
def test_add_fast_access_funding
|
433
|
-
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
434
|
-
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
435
|
-
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
|
436
|
-
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
|
437
|
-
File.expects(:directory?).returns(true).once
|
438
|
-
|
439
|
-
fastAccessFundingHash = {
|
440
|
-
'reportGroup'=>'Planets',
|
441
|
-
'orderId'=>'12344',
|
442
|
-
'fundingSubmerchantId'=>'123456',
|
443
|
-
'submerhcantName'=>'submerchant',
|
444
|
-
'fundsTransferId'=>'1234567',
|
445
|
-
'amount'=>'123',
|
446
|
-
'card'=>{
|
447
|
-
'type'=>'VI',
|
448
|
-
'number' =>'4100000000000001',
|
449
|
-
'expDate' =>'1210'
|
450
|
-
}
|
451
|
-
}
|
452
|
-
|
453
|
-
batch = LitleBatchRequest.new
|
454
|
-
batch.create_new_batch('D:\Batches\\')
|
455
|
-
batch.fast_access_funding(fastAccessFundingHash)
|
456
|
-
|
457
|
-
counts = batch.get_counts_and_amounts
|
458
|
-
assert_equal 1, counts[:fastAccessFunding][:numFastAccessFunding]
|
459
|
-
assert_equal 123, counts[:fastAccessFunding][:fastAccessFundingAmount]
|
460
|
-
end
|
461
|
-
|
462
432
|
def test_close_batch
|
463
433
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
464
434
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
@@ -481,7 +451,7 @@ module LitleOnline
|
|
481
451
|
'expDate' =>'1210'
|
482
452
|
}}
|
483
453
|
|
484
|
-
batch =
|
454
|
+
batch = CnpBatchRequest.new
|
485
455
|
batch.create_new_batch('D:\Batches\\')
|
486
456
|
|
487
457
|
batch.sale(saleHash)
|
@@ -516,8 +486,8 @@ module LitleOnline
|
|
516
486
|
File.expects(:rename).once.in_sequence(open)
|
517
487
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once.in_sequence(open)
|
518
488
|
File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once.in_sequence(open)
|
519
|
-
batch1 =
|
520
|
-
batch2 =
|
489
|
+
batch1 = CnpBatchRequest.new
|
490
|
+
batch2 = CnpBatchRequest.new
|
521
491
|
batch2.expects(:build_batch_header).returns("foo")
|
522
492
|
batch1.create_new_batch('/usr/local/Batches/')
|
523
493
|
batch2.open_existing_batch(batch1.get_batch_name)
|
@@ -533,7 +503,7 @@ module LitleOnline
|
|
533
503
|
File.expects(:delete).once
|
534
504
|
File.expects(:directory?).returns(true).once
|
535
505
|
|
536
|
-
batch =
|
506
|
+
batch = CnpBatchRequest.new
|
537
507
|
batch.get_counts_and_amounts.expects(:[]).returns(hash = Hash.new).at_least(25)
|
538
508
|
hash.expects(:[]).returns('a').at_least(20)
|
539
509
|
|
@@ -546,7 +516,7 @@ module LitleOnline
|
|
546
516
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
|
547
517
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').once
|
548
518
|
|
549
|
-
batch =
|
519
|
+
batch = CnpBatchRequest.new
|
550
520
|
batch.create_new_batch('/usr/local')
|
551
521
|
|
552
522
|
assert batch.get_batch_name.include?('/usr/local/')
|
@@ -563,14 +533,14 @@ module LitleOnline
|
|
563
533
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(fileExists)
|
564
534
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(fileExists)
|
565
535
|
|
566
|
-
batch =
|
536
|
+
batch = CnpBatchRequest.new
|
567
537
|
batch.create_new_batch('/usr/local/')
|
568
538
|
end
|
569
539
|
|
570
540
|
def test_create_new_batch_when_full
|
571
541
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
|
572
542
|
|
573
|
-
batch =
|
543
|
+
batch = CnpBatchRequest.new
|
574
544
|
addTxn = sequence('addTxn')
|
575
545
|
|
576
546
|
File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(addTxn)
|
@@ -644,11 +614,11 @@ module LitleOnline
|
|
644
614
|
'id'=>'12345',
|
645
615
|
'customerId'=>'0987',
|
646
616
|
'orderId'=>'12344',
|
647
|
-
'
|
617
|
+
'cnpToken'=>'1233456789103801',
|
648
618
|
'cardValidationNum'=>'123'
|
649
619
|
}
|
650
620
|
|
651
|
-
batch =
|
621
|
+
batch = CnpBatchRequest.new
|
652
622
|
batch.create_new_batch('/usr/local/Batches/')
|
653
623
|
|
654
624
|
5.times(){ batch.authorization(authHash) }
|
@@ -767,16 +737,12 @@ module LitleOnline
|
|
767
737
|
'reportGroup'=>'Planets',
|
768
738
|
'orderId'=>'12344',
|
769
739
|
'fundingSubmerchantId'=>'123456',
|
770
|
-
'
|
740
|
+
'submerchantName' => 'Colin',
|
771
741
|
'fundsTransferId'=>'1234567',
|
772
742
|
'amount'=>'111',
|
773
|
-
'card'=>{
|
774
|
-
'type'=>'VI',
|
775
|
-
'number' =>'4100000000000001',
|
776
|
-
'expDate' =>'1210'
|
777
|
-
}
|
778
743
|
}
|
779
|
-
|
744
|
+
|
745
|
+
batch = CnpBatchRequest.new
|
780
746
|
batch.create_new_batch('/usr/local/Batches/')
|
781
747
|
|
782
748
|
batch.submerchant_credit(submerchantCreditHash)
|
@@ -818,8 +784,8 @@ module LitleOnline
|
|
818
784
|
assert_equal 107, counts[:vendorDebit ][:vendorDebitAmount ]
|
819
785
|
assert_equal 110, counts[:physicalCheckDebit ][:physicalCheckDebitAmount ]
|
820
786
|
|
821
|
-
|
822
|
-
|
787
|
+
assert_equal 111, counts[:fastAccessFunding ][:fastAccessFundingAmount ]
|
788
|
+
assert_equal 1, counts[:fastAccessFunding ][:numFastAccessFunding ]
|
823
789
|
end
|
824
790
|
end
|
825
791
|
end
|
@@ -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
|
require 'test/unit'
|
27
27
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
|
31
|
-
class
|
31
|
+
class TestCnpOnlineRequest < Test::Unit::TestCase
|
32
32
|
def test_set_merchant_id
|
33
33
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}})
|
34
|
-
|
35
|
-
assert_equal '2',
|
36
|
-
assert_equal '1',
|
34
|
+
cnp = CnpOnlineRequest.new
|
35
|
+
assert_equal '2', cnp.send(:get_merchant_id, {'merchantId'=>'2'})
|
36
|
+
assert_equal '1', cnp.send(:get_merchant_id, {'NotMerchantId'=>'2'})
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_simple
|
@@ -49,8 +49,8 @@ module LitleOnline
|
|
49
49
|
'expDate' =>'1210'
|
50
50
|
}}
|
51
51
|
|
52
|
-
|
53
|
-
response =
|
52
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/<cnpOnlineRequest .*/m), is_a(Hash))
|
53
|
+
response = CnpOnlineRequest.new.authorization(hash)
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_authorization_attributes
|
@@ -67,8 +67,8 @@ module LitleOnline
|
|
67
67
|
'expDate' =>'1210'
|
68
68
|
}}
|
69
69
|
|
70
|
-
|
71
|
-
response =
|
70
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<authorization ((reportGroup="Planets" id="003")|(id="003" reportGroup="Planets")).*/m), is_a(Hash))
|
71
|
+
response = CnpOnlineRequest.new.authorization(hash)
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_authorization_elements
|
@@ -85,8 +85,8 @@ module LitleOnline
|
|
85
85
|
'expDate' =>'1210'
|
86
86
|
}}
|
87
87
|
|
88
|
-
|
89
|
-
response =
|
88
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<authorization.*<orderId>12344.*<amount>106.*<orderSource>ecommerce.*/m), is_a(Hash))
|
89
|
+
response = CnpOnlineRequest.new.authorization(hash)
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_authorization_card_field
|
@@ -103,8 +103,8 @@ module LitleOnline
|
|
103
103
|
'expDate' =>'1210'
|
104
104
|
}}
|
105
105
|
|
106
|
-
|
107
|
-
response =
|
106
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<authorization.*<card>.*<number>4100000000000001.*<expDate>1210.*/m), is_a(Hash))
|
107
|
+
response = CnpOnlineRequest.new.authorization(hash)
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_sale_card_field
|
@@ -121,8 +121,8 @@ module LitleOnline
|
|
121
121
|
'expDate' =>'1210'
|
122
122
|
}}
|
123
123
|
|
124
|
-
|
125
|
-
response =
|
124
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/<cnpOnlineRequest.*<sale.*<card>.*<number>4100000000000001.*<expDate>1210.*/m), is_a(Hash))
|
125
|
+
response = CnpOnlineRequest.new.sale(hash)
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_capture_amount_unset_should_not_be_in_xml
|
@@ -130,11 +130,11 @@ module LitleOnline
|
|
130
130
|
hash={
|
131
131
|
'id' => '006',
|
132
132
|
'reportGroup'=>'Planets',
|
133
|
-
'
|
133
|
+
'cnpTxnId'=>'123456789012345678'
|
134
134
|
}
|
135
135
|
|
136
|
-
|
137
|
-
response =
|
136
|
+
CnpXmlMapper.expects(:request).with(Not(regexp_matches(/.*amount.*/m)), is_a(Hash))
|
137
|
+
response = CnpOnlineRequest.new.capture(hash)
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_force_capture_amount_unset_should_not_be_in_xml
|
@@ -144,11 +144,11 @@ module LitleOnline
|
|
144
144
|
'orderId'=>'12344',
|
145
145
|
'reportGroup'=>'Planets',
|
146
146
|
'orderSource'=>'ecommerce',
|
147
|
-
'
|
147
|
+
'cnpTxnId'=>'123456789012345678'
|
148
148
|
}
|
149
149
|
|
150
|
-
|
151
|
-
response =
|
150
|
+
CnpXmlMapper.expects(:request).with(Not(regexp_matches(/.*amount.*/m)), is_a(Hash))
|
151
|
+
response = CnpOnlineRequest.new.force_capture(hash)
|
152
152
|
end
|
153
153
|
|
154
154
|
def test_amount_is_not_required_in_echeck_credit
|
@@ -158,12 +158,12 @@ module LitleOnline
|
|
158
158
|
'orderId'=>'12344',
|
159
159
|
'reportGroup'=>'Planets',
|
160
160
|
'orderSource'=>'ecommerce',
|
161
|
-
'
|
161
|
+
'cnpTxnId'=>'123456789012345678',
|
162
162
|
}
|
163
163
|
|
164
|
-
|
164
|
+
CnpXmlMapper.expects(:request).with(Not(regexp_matches(/.*amount.*/m)), is_a(Hash))
|
165
165
|
|
166
|
-
response =
|
166
|
+
response = CnpOnlineRequest.new.echeck_credit(hash)
|
167
167
|
end
|
168
168
|
|
169
169
|
def test_amount_is_not_required_in_echeck_sale
|
@@ -173,11 +173,11 @@ module LitleOnline
|
|
173
173
|
'orderId'=>'12344',
|
174
174
|
'reportGroup'=>'Planets',
|
175
175
|
'orderSource'=>'ecommerce',
|
176
|
-
'
|
176
|
+
'cnpTxnId'=>'123456789012345678',
|
177
177
|
}
|
178
178
|
|
179
|
-
|
180
|
-
response =
|
179
|
+
CnpXmlMapper.expects(:request).with(Not(regexp_matches(/.*amount.*/m)), is_a(Hash))
|
180
|
+
response = CnpOnlineRequest.new.echeck_sale(hash)
|
181
181
|
end
|
182
182
|
|
183
183
|
def test_choice_between_card_token
|
@@ -196,8 +196,8 @@ module LitleOnline
|
|
196
196
|
}
|
197
197
|
}
|
198
198
|
|
199
|
-
|
200
|
-
|
199
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*card.*/m), is_a(Hash))
|
200
|
+
CnpOnlineRequest.new.authorization(start_hash.merge(card_only))
|
201
201
|
end
|
202
202
|
|
203
203
|
def test_choice_between_card_token2
|
@@ -211,12 +211,12 @@ module LitleOnline
|
|
211
211
|
|
212
212
|
token_only = {
|
213
213
|
'token'=> {
|
214
|
-
'
|
214
|
+
'cnpToken' => '1111222233334444'
|
215
215
|
}
|
216
216
|
}
|
217
217
|
|
218
|
-
|
219
|
-
|
218
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*token.*/m), is_a(Hash))
|
219
|
+
CnpOnlineRequest.new.authorization(start_hash.merge(token_only))
|
220
220
|
end
|
221
221
|
|
222
222
|
|
@@ -236,17 +236,17 @@ module LitleOnline
|
|
236
236
|
'expDate' =>'1210'
|
237
237
|
}}
|
238
238
|
|
239
|
-
|
240
|
-
response =
|
239
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/<cnpOnlineRequest.*<sale.*<payPalOrderComplete>true<\/payPalOrderComplete>.*/m), is_a(Hash))
|
240
|
+
response = CnpOnlineRequest.new.sale(hash)
|
241
241
|
end
|
242
242
|
|
243
243
|
def test_version_matches_sdk_major_and_minor_version_ignoring_config
|
244
244
|
Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
|
245
245
|
hash={
|
246
|
-
'
|
246
|
+
'cnpTxnId' => '006'
|
247
247
|
}
|
248
|
-
|
249
|
-
response =
|
248
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/<cnpOnlineRequest.*version="12\.1".*/m), is_a(Hash))
|
249
|
+
response = CnpOnlineRequest.new.void(hash)
|
250
250
|
end
|
251
251
|
|
252
252
|
end
|