CnpOnline 12.1.1 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/Rakefile +2 -2
- data/lib/CnpBatchRequest.rb +13 -2
- data/lib/CnpOnlineRequest.rb +10 -4
- data/lib/CnpRequest.rb +2 -2
- data/lib/CnpTransaction.rb +22 -2
- data/lib/XMLFields.rb +169 -42
- data/test/certification/certTest1_base.rb +5 -4
- data/test/certification/certTest2_authenhanced.rb +51 -50
- data/test/certification/certTest3_authreversal.rb +6 -3
- data/test/certification/certTest4_echeck.rb +7 -6
- data/test/certification/certTest5_token.rb +15 -13
- data/test/functional/test_auth.rb +31 -1
- data/test/functional/test_capture.rb +25 -0
- data/test/functional/test_captureGivenAuth.rb +35 -1
- data/test/functional/test_credit.rb +31 -1
- data/test/functional/test_fastAccessFunding.rb +156 -0
- data/test/functional/test_forceCapture.rb +32 -0
- data/test/functional/test_fraudCheck.rb +1 -1
- data/test/functional/test_queryTransaction.rb +53 -52
- data/test/functional/test_sale.rb +54 -2
- data/test/functional/test_translateToken.rb +203 -0
- data/test/unit/test_LitleOnlineRequest.rb +1 -1
- metadata +5 -5
- data/CHANGELOG~ +0 -5
- data/Rakefile~ +0 -90
@@ -186,7 +186,37 @@ module CnpOnline
|
|
186
186
|
response= CnpOnlineRequest.new.credit(hash)
|
187
187
|
assert_equal('Valid Format', response.message)
|
188
188
|
assert_equal('000', response.creditResponse.response)
|
189
|
-
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_simple_credit_with_lodging_info
|
192
|
+
hash = {
|
193
|
+
'merchantId' => '101',
|
194
|
+
'id' => 'test',
|
195
|
+
'version'=>'8.8',
|
196
|
+
'reportGroup'=>'Planets',
|
197
|
+
'orderId'=>'12344',
|
198
|
+
'amount'=>'106',
|
199
|
+
'orderSource'=>'ecommerce',
|
200
|
+
'card'=>{
|
201
|
+
'type'=>'VI',
|
202
|
+
'number' =>'4100000000000001',
|
203
|
+
'expDate' =>'1210'
|
204
|
+
},
|
205
|
+
'lodgingInfo' => {
|
206
|
+
'hotelFolioNumber ' => 'testFolio',
|
207
|
+
'duration' => '111',
|
208
|
+
'customerServicePhone' => 'testPhone1',
|
209
|
+
'programCode' => 'LODGING',
|
210
|
+
'roomRate' => '112233445566',
|
211
|
+
'numAdults' => '11',
|
212
|
+
'propertyLocalPhone' => 'testPhone2',
|
213
|
+
'fireSafetyIndicator' => 'true',
|
214
|
+
'lodgingCharge' => {'name' => 'RESTAURANT'}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
response= CnpOnlineRequest.new.credit(hash)
|
218
|
+
assert_equal('Valid Format', response.message)
|
219
|
+
end
|
190
220
|
|
191
221
|
end
|
192
222
|
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2017 Vantiv eCommerce
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
|
+
require 'test/unit'
|
27
|
+
|
28
|
+
module CnpOnline
|
29
|
+
class TestFastAccessFunding < Test::Unit::TestCase
|
30
|
+
def test_faf
|
31
|
+
hash = {
|
32
|
+
'merchantId' => '101',
|
33
|
+
'id' => 'test',
|
34
|
+
'version'=>'8.8',
|
35
|
+
'reportGroup'=>'Planets',
|
36
|
+
'amount'=>'106',
|
37
|
+
'fundingSubmerchantId'=>'this is a merchant id',
|
38
|
+
'submerchantName'=>'this is a very long string',
|
39
|
+
'fundsTransferId'=>'0123456789abcdef',
|
40
|
+
'card'=>{
|
41
|
+
'type'=>'VI',
|
42
|
+
'number' =>'4100000000000001',
|
43
|
+
'expDate' =>'1210'
|
44
|
+
}}
|
45
|
+
response= CnpOnlineRequest.new.fast_access_funding(hash)
|
46
|
+
|
47
|
+
assert_equal('0', response.response)
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_faf_fields_out_of_order
|
52
|
+
hash = {
|
53
|
+
'merchantId' => '101',
|
54
|
+
'id' => 'test',
|
55
|
+
'version'=>'8.8',
|
56
|
+
'amount'=>'106',
|
57
|
+
'fundingSubmerchantId'=>'this is a merchant id',
|
58
|
+
'submerchantName'=>'this is a very long string',
|
59
|
+
'fundsTransferId'=>'0123456789abcdef',
|
60
|
+
'reportGroup'=>'Planets',
|
61
|
+
'card'=>{
|
62
|
+
'type'=>'VI',
|
63
|
+
'number' =>'4100000000000001',
|
64
|
+
'expDate' =>'1210'
|
65
|
+
}}
|
66
|
+
response= CnpOnlineRequest.new.fast_access_funding(hash)
|
67
|
+
|
68
|
+
assert_equal('0', response.response)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_faf_invalid_field
|
73
|
+
hash = {
|
74
|
+
'merchantId' => '101',
|
75
|
+
'id' => 'test',
|
76
|
+
'version'=>'8.8',
|
77
|
+
'reportGroup'=>'Planets',
|
78
|
+
'amount'=>'106',
|
79
|
+
'fundingSubmerchantId'=>'this is a merchant id',
|
80
|
+
'submerchantName'=>'this is a very long string',
|
81
|
+
'fundsTransferId'=>'0123456789abcdef',
|
82
|
+
'card'=>{
|
83
|
+
'NOexistantField' => 'ShouldNotCauseError',
|
84
|
+
'type'=>'VI',
|
85
|
+
'number' =>'4100000000000001',
|
86
|
+
'expDate' =>'1210'
|
87
|
+
}}
|
88
|
+
response= CnpOnlineRequest.new.fast_access_funding(hash)
|
89
|
+
|
90
|
+
assert_equal('0', response.response)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_faf_no_fundingSubmerchantId
|
95
|
+
hash = {
|
96
|
+
'merchantId' => '101',
|
97
|
+
'id' => 'test',
|
98
|
+
'version'=>'8.8',
|
99
|
+
'reportGroup'=>'Planets',
|
100
|
+
'amount'=>'106',
|
101
|
+
'submerchantName'=>'this is a very long string',
|
102
|
+
'fundsTransferId'=>'0123456789abcdef',
|
103
|
+
'card'=>{
|
104
|
+
'type'=>'VI',
|
105
|
+
'number' =>'4100000000000001',
|
106
|
+
'expDate' =>'1210'
|
107
|
+
}}
|
108
|
+
#Get exceptions
|
109
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.fast_access_funding(hash)}
|
110
|
+
#Test
|
111
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_faf_no_submerchantName
|
115
|
+
hash = {
|
116
|
+
'merchantId' => '101',
|
117
|
+
'id' => 'test',
|
118
|
+
'version'=>'8.8',
|
119
|
+
'reportGroup'=>'Planets',
|
120
|
+
'amount'=>'106',
|
121
|
+
'fundingSubmerchantId'=>'this is a merchant id',
|
122
|
+
'fundsTransferId'=>'0123456789abcdef',
|
123
|
+
'card'=>{
|
124
|
+
'type'=>'VI',
|
125
|
+
'number' =>'4100000000000001',
|
126
|
+
'expDate' =>'1210'
|
127
|
+
}}
|
128
|
+
#Get exceptions
|
129
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.fast_access_funding(hash)}
|
130
|
+
#Test
|
131
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_faf_no_fundsTransferId
|
135
|
+
hash = {
|
136
|
+
'merchantId' => '101',
|
137
|
+
'id' => 'test',
|
138
|
+
'version'=>'8.8',
|
139
|
+
'reportGroup'=>'Planets',
|
140
|
+
'amount'=>'106',
|
141
|
+
'fundingSubmerchantId'=>'this is a merchant id',
|
142
|
+
'submerchantName'=>'this is a very long string',
|
143
|
+
'card'=>{
|
144
|
+
'type'=>'VI',
|
145
|
+
'number' =>'4100000000000001',
|
146
|
+
'expDate' =>'1210'
|
147
|
+
}}
|
148
|
+
#Get exceptions
|
149
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.fast_access_funding(hash)}
|
150
|
+
#Test
|
151
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -213,6 +213,38 @@ module CnpOnline
|
|
213
213
|
assert_equal('0', response.response)
|
214
214
|
|
215
215
|
end
|
216
|
+
|
217
|
+
def test_simple_force_capture_with_lodgingInfo
|
218
|
+
hash = {
|
219
|
+
'merchantId' => '101',
|
220
|
+
'id' => 'test',
|
221
|
+
'version'=>'8.8',
|
222
|
+
'reportGroup'=>'Planets',
|
223
|
+
'orderId'=>'12344',
|
224
|
+
'amount'=>'106',
|
225
|
+
'orderSource'=>'ecommerce',
|
226
|
+
'card'=>{
|
227
|
+
'type'=>'VI',
|
228
|
+
'number' =>'4100000000000001',
|
229
|
+
'expDate' =>'1210'
|
230
|
+
},
|
231
|
+
'lodgingInfo' => {
|
232
|
+
'hotelFolioNumber ' => 'testFolio',
|
233
|
+
'duration' => '111',
|
234
|
+
'customerServicePhone' => 'testPhone1',
|
235
|
+
'programCode' => 'LODGING',
|
236
|
+
'roomRate' => '112233445566',
|
237
|
+
'numAdults' => '11',
|
238
|
+
'propertyLocalPhone' => 'testPhone2',
|
239
|
+
'fireSafetyIndicator' => 'true',
|
240
|
+
'lodgingCharge' => {'name' => 'RESTAURANT'}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
response= CnpOnlineRequest.new.force_capture(hash)
|
244
|
+
|
245
|
+
assert_equal('0', response.response)
|
246
|
+
|
247
|
+
end
|
216
248
|
|
217
249
|
end
|
218
250
|
|
@@ -44,7 +44,7 @@ module CnpOnline
|
|
44
44
|
assert_equal('0', response.response)
|
45
45
|
assert_equal('pass', response.fraudCheckResponse.advancedFraudResults.deviceReviewStatus)
|
46
46
|
#sandbox is being updated to handle this correctly
|
47
|
-
|
47
|
+
assert_equal('55', response.fraudCheckResponse.advancedFraudResults.deviceReputationScore)
|
48
48
|
assert_equal('triggered_rule_1', response.fraudCheckResponse.advancedFraudResults.triggeredRule[0])
|
49
49
|
assert_equal(5, response.fraudCheckResponse.advancedFraudResults.triggeredRule.size())
|
50
50
|
end
|
@@ -43,6 +43,59 @@ module CnpOnline
|
|
43
43
|
response= CnpOnlineRequest.new.query_Transaction(hash)
|
44
44
|
assert_equal('150', response.queryTransactionResponse.response)
|
45
45
|
end
|
46
|
+
|
47
|
+
def test_queryTransaction_noOrigId_noOrigActionType
|
48
|
+
hash = {
|
49
|
+
'merchantId' => '101',
|
50
|
+
'id' => 'test',
|
51
|
+
'version'=>'10.0',
|
52
|
+
'reportGroup'=>'Some RG',
|
53
|
+
'customerId' => '038945',
|
54
|
+
'transactionId'=>'123456',
|
55
|
+
'orderId'=>'65347567',
|
56
|
+
#'origAccountNumber' => '4000000000000001'
|
57
|
+
}
|
58
|
+
response= CnpOnlineRequest.new.query_Transaction(hash)
|
59
|
+
assert_equal('150', response.queryTransactionResponse.response)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_queryTransaction_withShowStatusOnly
|
63
|
+
hash = {
|
64
|
+
'merchantId' => '101',
|
65
|
+
'id' => 'test',
|
66
|
+
'version'=>'10.0',
|
67
|
+
'reportGroup'=>'Some RG',
|
68
|
+
'customerId' => '038945',
|
69
|
+
'origId' => '834262',
|
70
|
+
'origActionType' => 'A',
|
71
|
+
'transactionId'=>'123456',
|
72
|
+
'orderId'=>'65347567',
|
73
|
+
'showStatusOnly' => 'Y'
|
74
|
+
#'origAccountNumber' => '4000000000000001'
|
75
|
+
}
|
76
|
+
response= CnpOnlineRequest.new.query_Transaction(hash)
|
77
|
+
assert_equal('150', response.queryTransactionResponse.response)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_queryTransaction_invalidShowStatusOnly
|
81
|
+
hash = {
|
82
|
+
'merchantId' => '101',
|
83
|
+
'id' => 'test',
|
84
|
+
'version'=>'10.0',
|
85
|
+
'reportGroup'=>'Some RG',
|
86
|
+
'customerId' => '038945',
|
87
|
+
'origId' => '834262',
|
88
|
+
'origActionType' => 'A',
|
89
|
+
'transactionId'=>'123456',
|
90
|
+
'orderId'=>'65347567',
|
91
|
+
'showStatusOnly' => 'A'
|
92
|
+
#'origAccountNumber' => '4000000000000001'
|
93
|
+
}
|
94
|
+
#Get exceptions
|
95
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
96
|
+
#Test
|
97
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
98
|
+
end
|
46
99
|
|
47
100
|
def test_queryTransaction_valid_enum
|
48
101
|
hash = {
|
@@ -59,42 +112,6 @@ module CnpOnline
|
|
59
112
|
}
|
60
113
|
response= CnpOnlineRequest.new.query_Transaction(hash)
|
61
114
|
assert('000', response.queryTransactionResponse.response)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_queryTransaction_no_origid
|
65
|
-
hash = {
|
66
|
-
'merchantId' => '101',
|
67
|
-
'id' => 'test',
|
68
|
-
'version'=>'10.0',
|
69
|
-
'reportGroup'=>'Some RG',
|
70
|
-
'customerId' => '038945',
|
71
|
-
'origActionType' => 'A',
|
72
|
-
'transactionId'=>'123456',
|
73
|
-
'orderId'=>'65347567',
|
74
|
-
#'origAccountNumber' => '4000000000000001'
|
75
|
-
}
|
76
|
-
#Get exceptions
|
77
|
-
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
78
|
-
#Test
|
79
|
-
assert(exception.message =~ /Error validating xml data against the schema/)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_queryTransaction_no_accttype
|
83
|
-
hash = {
|
84
|
-
'merchantId' => '101',
|
85
|
-
'id' => 'test',
|
86
|
-
'version'=>'10.0',
|
87
|
-
'reportGroup'=>'Some RG',
|
88
|
-
'customerId' => '038945',
|
89
|
-
'origId' => '834262',
|
90
|
-
'transactionId'=>'123456',
|
91
|
-
'orderId'=>'65347567',
|
92
|
-
#'origAccountNumber' => '4000000000000001'
|
93
|
-
}
|
94
|
-
#Get exceptions
|
95
|
-
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
96
|
-
#Test
|
97
|
-
assert(exception.message =~ /Error validating xml data against the schema/)
|
98
115
|
end
|
99
116
|
|
100
117
|
def test_queryTransaction_invalid_values
|
@@ -114,22 +131,6 @@ module CnpOnline
|
|
114
131
|
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
115
132
|
#Test
|
116
133
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_queryTransaction_missing_attributes
|
120
|
-
hash = {
|
121
|
-
'merchantId' => '101',
|
122
|
-
'id' => 'test',
|
123
|
-
'version'=>'10.0',
|
124
|
-
'customerId' => '038945',
|
125
|
-
'origActionType' => 'A',
|
126
|
-
'transactionId'=>'123456',
|
127
|
-
#'origAccountNumber' => '4000000000000001'
|
128
|
-
}
|
129
|
-
#Get exceptions
|
130
|
-
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
|
131
|
-
#Test
|
132
|
-
assert(exception.message =~ /Error validating xml data against the schema/)
|
133
134
|
end
|
134
135
|
|
135
136
|
def test_queryTransaction_unavailable_response
|
@@ -400,8 +400,60 @@ module CnpOnline
|
|
400
400
|
assert_equal('jj2d1d372osmmt7tb8epm0a99q', response.saleResponse.sepaDirectDebitResponse.redirectToken)
|
401
401
|
assert_equal('1BADA58', response.saleResponse.sepaDirectDebitResponse.mandateReference)
|
402
402
|
end
|
403
|
-
|
404
|
-
|
403
|
+
|
404
|
+
def test_simple_sale_with_lodgingInfo
|
405
|
+
hash = {
|
406
|
+
'merchantId' => '101',
|
407
|
+
'id' => 'test',
|
408
|
+
'version'=>'8.8',
|
409
|
+
'reportGroup'=>'Planets',
|
410
|
+
'cnpTxnId'=>'123456',
|
411
|
+
'orderId'=>'12344',
|
412
|
+
'amount'=>'106',
|
413
|
+
'orderSource'=>'ecommerce',
|
414
|
+
'card'=>{
|
415
|
+
'type'=>'VI',
|
416
|
+
'number' =>'4100000000000002',
|
417
|
+
'expDate' =>'1210'
|
418
|
+
},
|
419
|
+
'lodgingInfo' => {
|
420
|
+
'hotelFolioNumber ' => 'testFolio',
|
421
|
+
'duration' => '111',
|
422
|
+
'customerServicePhone' => 'testPhone1',
|
423
|
+
'programCode' => 'LODGING',
|
424
|
+
'roomRate' => '112233445566',
|
425
|
+
'numAdults' => '11',
|
426
|
+
'propertyLocalPhone' => 'testPhone2',
|
427
|
+
'fireSafetyIndicator' => 'true',
|
428
|
+
'lodgingCharge' => {'name' => 'RESTAURANT'}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
|
432
|
+
response= CnpOnlineRequest.new.sale(hash)
|
433
|
+
assert_equal('000', response.saleResponse.response)
|
434
|
+
end
|
435
|
+
|
436
|
+
def test_simple_sale_with_pinlessDebitRequestType
|
437
|
+
hash = {
|
438
|
+
'merchantId' => '101',
|
439
|
+
'id' => 'test',
|
440
|
+
'version'=>'8.8',
|
441
|
+
'reportGroup'=>'Planets',
|
442
|
+
'cnpTxnId'=>'123456',
|
443
|
+
'orderId'=>'12344',
|
444
|
+
'amount'=>'106',
|
445
|
+
'orderSource'=>'ecommerce',
|
446
|
+
'card'=>{
|
447
|
+
'type'=>'VI',
|
448
|
+
'number' =>'4100000000000002',
|
449
|
+
'expDate' =>'1210'
|
450
|
+
}, 'pinlessDebitRequest' => {'routingPreference' => 'regular',
|
451
|
+
'preferredDebitNetworks' => {'debitNetworkName' => 'fast'}}
|
452
|
+
}
|
453
|
+
|
454
|
+
response= CnpOnlineRequest.new.sale(hash)
|
455
|
+
assert_equal('000', response.saleResponse.response)
|
456
|
+
end
|
405
457
|
|
406
458
|
end
|
407
459
|
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2018 Vantiv eCommerce
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
5
|
+
obtaining a copy of this software and associated documentation
|
6
|
+
files (the "Software"), to deal in the Software without
|
7
|
+
restriction, including without limitation the rights to use,
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the
|
10
|
+
Software is furnished to do so, subject to the following
|
11
|
+
conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
|
+
require 'test/unit'
|
27
|
+
|
28
|
+
module CnpOnline
|
29
|
+
class TestTranslateToken < Test::Unit::TestCase
|
30
|
+
def test_token_happy
|
31
|
+
hash = {
|
32
|
+
'merchantId' => '101',
|
33
|
+
'id' => 'test',
|
34
|
+
'version'=>'8.8',
|
35
|
+
'reportGroup'=>'Planets',
|
36
|
+
|
37
|
+
'orderId'=>'5656',
|
38
|
+
'token'=>'444'
|
39
|
+
}
|
40
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
41
|
+
|
42
|
+
assert_equal('803', response.translateToLowValueTokenResponse.response)
|
43
|
+
|
44
|
+
end
|
45
|
+
def test_ttlvt
|
46
|
+
hash = {
|
47
|
+
'merchantId' => '101',
|
48
|
+
'version'=>'12.3',
|
49
|
+
'id' => 'testId',
|
50
|
+
'reportGroup'=>'Planets',
|
51
|
+
'orderId' => 'test',
|
52
|
+
'token' => '1111222233334444'
|
53
|
+
}
|
54
|
+
|
55
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
56
|
+
|
57
|
+
assert_equal('0', response.response)
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_ttlvt_fields_out_of_order
|
62
|
+
hash = {
|
63
|
+
'merchantId' => '101',
|
64
|
+
'version'=>'12.3',
|
65
|
+
'id' => 'testId',
|
66
|
+
'orderId' => 'test',
|
67
|
+
'token' => '1111222233334444',
|
68
|
+
'reportGroup' =>'Planets'
|
69
|
+
}
|
70
|
+
|
71
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
72
|
+
|
73
|
+
assert_equal('0', response.response)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_ttlvt_invalid_field
|
78
|
+
hash = {
|
79
|
+
'merchantId' => '101',
|
80
|
+
'version'=>'12.3',
|
81
|
+
'id' => 'testId',
|
82
|
+
'reportGroup'=>'Planets',
|
83
|
+
'orderId' => 'test',
|
84
|
+
'token' => '1111222233334444',
|
85
|
+
'testField' => 'ShouldNotCauseError'
|
86
|
+
}
|
87
|
+
|
88
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
89
|
+
|
90
|
+
assert_equal('0', response.response)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_ttlvt_no_orderId
|
95
|
+
hash = {
|
96
|
+
'merchantId' => '101',
|
97
|
+
'version'=>'12.3',
|
98
|
+
'id' => 'testId',
|
99
|
+
'reportGroup'=>'Planets',
|
100
|
+
'token' => '1111222233334444'
|
101
|
+
}
|
102
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
103
|
+
|
104
|
+
assert_equal('0', response.response)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_ttlvt_response_orderId
|
108
|
+
hash = {
|
109
|
+
'merchantId' => '101',
|
110
|
+
'version'=>'12.3',
|
111
|
+
'id' => 'testId',
|
112
|
+
'reportGroup'=>'Planets',
|
113
|
+
'orderId' => 'test',
|
114
|
+
'token' => '1111222233334444'
|
115
|
+
}
|
116
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
117
|
+
|
118
|
+
assert_equal('test', response.translateToLowValueTokenResponse.orderId)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_ttlvt_no_token
|
122
|
+
hash = {
|
123
|
+
'merchantId' => '101',
|
124
|
+
'version'=>'12.3',
|
125
|
+
'id' => 'testId',
|
126
|
+
'reportGroup'=>'Planets',
|
127
|
+
'orderId' => 'test',
|
128
|
+
}
|
129
|
+
#Get exceptions
|
130
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.translate_to_low_value_token_request(hash)}
|
131
|
+
#Test
|
132
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_ttlvt_too_long_orderId
|
136
|
+
hash = {
|
137
|
+
'merchantId' => '101',
|
138
|
+
'version'=>'12.3',
|
139
|
+
'id' => 'testId',
|
140
|
+
'reportGroup'=>'Planets',
|
141
|
+
'orderId' => 'this string contains more than twenty five characters',
|
142
|
+
'token' => '1111222233334444'
|
143
|
+
}
|
144
|
+
#Get exceptions
|
145
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.translate_to_low_value_token_request(hash)}
|
146
|
+
#Test
|
147
|
+
assert(exception.message =~ /Error validating xml data against the schema/)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_ttlvt_response_valid
|
151
|
+
hash = {
|
152
|
+
'merchantId' => '101',
|
153
|
+
'version'=>'12.3',
|
154
|
+
'id' => 'testId',
|
155
|
+
'reportGroup'=>'Planets',
|
156
|
+
'orderId' => 'test',
|
157
|
+
'token' => '1111222233334444'
|
158
|
+
}
|
159
|
+
|
160
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
161
|
+
|
162
|
+
assert_equal('803', response.translateToLowValueTokenResponse.response)
|
163
|
+
assert_equal('Valid Token', response.translateToLowValueTokenResponse.message)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_ttlvt_response_not_authorized
|
167
|
+
hash = {
|
168
|
+
'merchantId' => '101',
|
169
|
+
'version'=>'12.3',
|
170
|
+
'id' => 'testId',
|
171
|
+
'reportGroup'=>'Planets',
|
172
|
+
'orderId' => 'test',
|
173
|
+
'token' => '1111222233334444821'
|
174
|
+
}
|
175
|
+
|
176
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
177
|
+
|
178
|
+
assert_equal('821', response.translateToLowValueTokenResponse.response)
|
179
|
+
assert_equal('Merchant is not authorized for tokens', response.translateToLowValueTokenResponse.message)
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_ttlvt_response_not_found
|
184
|
+
hash = {
|
185
|
+
'merchantId' => '101',
|
186
|
+
'version'=>'12.3',
|
187
|
+
'id' => 'testId',
|
188
|
+
'reportGroup'=>'Planets',
|
189
|
+
'orderId' => 'test',
|
190
|
+
'token' => '1111222233334444822'
|
191
|
+
}
|
192
|
+
|
193
|
+
response= CnpOnlineRequest.new.translate_to_low_value_token_request(hash)
|
194
|
+
|
195
|
+
assert_equal('822', response.translateToLowValueTokenResponse.response)
|
196
|
+
assert_equal('Token was not found', response.translateToLowValueTokenResponse.message)
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
end
|