CnpOnline 12.3.0 → 12.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -0
- data/Rakefile +1 -1
- data/lib/CnpBatchRequest.rb +17 -8
- data/lib/CnpOnline.rb +2 -0
- data/lib/CnpOnlineRequest.rb +30 -2
- data/lib/CnpRequest.rb +24 -4
- data/lib/CnpTransaction.rb +70 -7
- data/lib/CommManager.rb +185 -0
- data/lib/Communications.rb +7 -3
- data/lib/EnvironmentVariables.rb +8 -0
- data/lib/RequestTarget.rb +10 -0
- data/lib/XMLFields.rb +148 -11
- data/out/production/cnp-sdk-for-ruby/CnpBatchRequest.rb +787 -0
- data/out/production/cnp-sdk-for-ruby/CnpListeners.rb +265 -0
- data/out/production/cnp-sdk-for-ruby/CnpOnline.rb +65 -0
- data/out/production/cnp-sdk-for-ruby/CnpOnlineRequest.rb +370 -0
- data/out/production/cnp-sdk-for-ruby/CnpRequest.rb +670 -0
- data/out/production/cnp-sdk-for-ruby/CnpTransaction.rb +831 -0
- data/out/production/cnp-sdk-for-ruby/CnpXmlMapper.rb +71 -0
- data/out/production/cnp-sdk-for-ruby/CommManager.rb +185 -0
- data/out/production/cnp-sdk-for-ruby/Communications.rb +90 -0
- data/out/production/cnp-sdk-for-ruby/Configuration.rb +75 -0
- data/out/production/cnp-sdk-for-ruby/EnvironmentVariables.rb +33 -0
- data/out/production/cnp-sdk-for-ruby/RequestTarget.rb +10 -0
- data/out/production/cnp-sdk-for-ruby/Setup.rb +147 -0
- data/out/production/cnp-sdk-for-ruby/XMLFields.rb +2638 -0
- data/out/production/cnp-sdk-for-ruby/cacert.pem +3331 -0
- data/out/production/cnp-sdk-for-ruby/sample_batch_driver.rb +123 -0
- data/out/production/cnp-sdk-for-ruby/sample_driver.rb +49 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest1_base.rb +948 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest2_authenhanced.rb +577 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest3_authreversal.rb +190 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest4_echeck.rb +288 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest5_token.rb +209 -0
- data/out/test/cnp-sdk-for-ruby/certification/certTest_batchAll.rb +610 -0
- data/out/test/cnp-sdk-for-ruby/certification/ts_all.rb +33 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_activate.rb +133 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_activateReversal.rb +73 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_auth.rb +478 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_authReversal.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_balanceInquiry.rb +107 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_batch.rb +264 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_batchStream.rb +154 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_cancelSubscription.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_capture.rb +147 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_captureGivenAuth.rb +352 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_commManager.rb +302 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_configuration.rb +89 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_createPlan.rb +87 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_credit.rb +222 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_ctx.rb +124 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_deactivate.rb +105 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_deactivateReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_depositReversal.rb +70 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckCredit.rb +179 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckRedeposit.rb +117 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckSale.rb +255 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckVerification.rb +160 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_echeckVoid.rb +42 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_fastAccessFunding.rb +177 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_forceCapture.rb +272 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_fraudCheck.rb +76 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardAuthReversal.rb +72 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCapture.rb +72 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCredit.rb +69 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_litle_requests.rb +355 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_load.rb +108 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_loadReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_override.rb +68 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_pgp_cnp_requests.rb +295 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_queryTransaction.rb +154 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_refundReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_sale.rb +459 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_token.rb +137 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_translateToken.rb +203 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_unload.rb +108 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_unloadReversal.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updateCardValidationNumOnToken.rb +44 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updatePlan.rb +61 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_updateSubscription.rb +80 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_wallet.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/functional/test_xmlfields.rb +429 -0
- data/out/test/cnp-sdk-for-ruby/functional/ts_all.rb +69 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleAUBatch.rb +244 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleBatchRequest.rb +791 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleOnlineRequest.rb +253 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleRequest.rb +317 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleTransaction.rb +426 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_LitleXmlMapper.rb +139 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_activate.rb +92 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_activateReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_auth.rb +463 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_authReversal.rb +82 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_balanceInquiry.rb +52 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_cancelSubscription.rb +43 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_capture.rb +99 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_captureGivenAuth.rb +234 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_createPlan.rb +52 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_credit.rb +355 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_deactivate.rb +71 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_deactivateReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_depositReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckCredit.rb +103 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckRedeposit.rb +109 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckSale.rb +107 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckVerification.rb +74 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_echeckVoid.rb +54 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_forceCapture.rb +163 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_fraudCheck.rb +45 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardAuthReversal.rb +58 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCapture.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCredit.rb +57 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_load.rb +53 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_loadReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_pgp_CnpRequest.rb +139 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_queryTransaction.rb +106 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_refundReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_sale.rb +551 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_token.rb +159 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_unload.rb +53 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_unloadReversal.rb +56 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updateCardValidationNumOnToken.rb +80 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updatePlan.rb +45 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_updateSubscription.rb +172 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_wallet.rb +262 -0
- data/out/test/cnp-sdk-for-ruby/unit/test_xmlfields.rb +2930 -0
- data/out/test/cnp-sdk-for-ruby/unit/ts_unit.rb +67 -0
- data/test/certification/certTest2_authenhanced.rb +28 -27
- data/test/functional/test_batch.rb +106 -1
- data/test/functional/test_batchStream.rb +3 -2
- data/test/functional/test_captureGivenAuth.rb +24 -0
- data/test/functional/test_commManager.rb +302 -0
- data/test/functional/test_ctx.rb +124 -0
- data/test/functional/test_fastAccessFunding.rb +21 -0
- data/test/functional/test_forceCapture.rb +21 -0
- data/test/functional/test_xmlfields.rb +20 -1
- metadata +122 -4
@@ -0,0 +1,52 @@
|
|
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
|
+
require 'mocha/setup'
|
28
|
+
module CnpOnline
|
29
|
+
class TestCreatePlan < Test::Unit::TestCase
|
30
|
+
|
31
|
+
def test_simple
|
32
|
+
hash ={
|
33
|
+
'merchantId' => '101',
|
34
|
+
'version'=>'8.8',
|
35
|
+
'reportGroup'=>'Planets',
|
36
|
+
'planCode'=>'planCodeString',
|
37
|
+
'name'=>'nameString',
|
38
|
+
'description'=>'descriptionString',
|
39
|
+
'intervalType'=>'ANNUAL',
|
40
|
+
'amount'=>'500',
|
41
|
+
'numberOfPayments'=>'2',
|
42
|
+
'trialNumberOfIntervals'=>'1',
|
43
|
+
'trialIntervalType'=>'MONTH',
|
44
|
+
'active'=>'true'
|
45
|
+
}
|
46
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<createPlan><planCode>planCodeString<\/planCode><name>nameString<\/name><description>descriptionString<\/description><intervalType>ANNUAL<\/intervalType><amount>500<\/amount><numberOfPayments>2<\/numberOfPayments><trialNumberOfIntervals>1<\/trialNumberOfIntervals><trialIntervalType>MONTH<\/trialIntervalType><active>true<\/active><\/createPlan>.*/m), is_a(Hash))
|
47
|
+
CnpOnlineRequest.new.create_plan(hash)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,355 @@
|
|
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
|
+
require 'mocha/setup'
|
28
|
+
|
29
|
+
module CnpOnline
|
30
|
+
class TestCredit < Test::Unit::TestCase
|
31
|
+
def test_both_choices_card_and_paypal
|
32
|
+
hash = {
|
33
|
+
'merchantId' => '101',
|
34
|
+
'version'=>'8.8',
|
35
|
+
'reportGroup'=>'Planets',
|
36
|
+
'orderId'=>'12344',
|
37
|
+
'amount'=>'106',
|
38
|
+
'orderSource'=>'ecommerce',
|
39
|
+
'card'=>{
|
40
|
+
'type'=>'VI',
|
41
|
+
'number' =>'4100000000000001',
|
42
|
+
'expDate' =>'1210'
|
43
|
+
},
|
44
|
+
'paypal'=>{
|
45
|
+
'payerEmail'=>'a@b.com',
|
46
|
+
'payerId'=>'1234',
|
47
|
+
'token'=>'1234',
|
48
|
+
'transactionId'=>'123456'
|
49
|
+
}}
|
50
|
+
|
51
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
52
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_three_choices_card_and_paypage_and_paypal
|
56
|
+
hash = {
|
57
|
+
'merchantId' => '101',
|
58
|
+
'version'=>'8.8',
|
59
|
+
'reportGroup'=>'Planets',
|
60
|
+
'orderId'=>'12344',
|
61
|
+
'amount'=>'106',
|
62
|
+
'orderSource'=>'ecommerce',
|
63
|
+
'card'=>{
|
64
|
+
'type'=>'VI',
|
65
|
+
'number' =>'4100000000000001',
|
66
|
+
'expDate' =>'1210'
|
67
|
+
},
|
68
|
+
'paypage'=> {
|
69
|
+
'paypageRegistrationId'=>'1234',
|
70
|
+
'expDate'=>'1210',
|
71
|
+
'cardValidationNum'=>'555',
|
72
|
+
'type'=>'VI'},
|
73
|
+
'paypal'=>{
|
74
|
+
'payerEmail'=>'a@b.com',
|
75
|
+
'payerId'=>'1234',
|
76
|
+
'token'=>'1234',
|
77
|
+
'transactionId'=>'123456'
|
78
|
+
}}
|
79
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
80
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_all_choices_card_and_paypage_and_paypal_and_token
|
84
|
+
hash = {
|
85
|
+
'merchantId' => '101',
|
86
|
+
'version'=>'8.8',
|
87
|
+
'reportGroup'=>'Planets',
|
88
|
+
'orderId'=>'12344',
|
89
|
+
'amount'=>'106',
|
90
|
+
'orderSource'=>'ecommerce',
|
91
|
+
'fraudCheck'=>{'authenticationTransactionId'=>'123'},
|
92
|
+
'bypassVelocityCheckcardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
|
93
|
+
'card'=>{
|
94
|
+
'type'=>'VI',
|
95
|
+
'number' =>'4100000000000001',
|
96
|
+
'expDate' =>'1210'
|
97
|
+
},
|
98
|
+
'paypage'=> {
|
99
|
+
'paypageRegistrationId'=>'1234',
|
100
|
+
'expDate'=>'1210',
|
101
|
+
'cardValidationNum'=>'555',
|
102
|
+
'type'=>'VI'
|
103
|
+
},
|
104
|
+
'paypal'=>{
|
105
|
+
'payerId'=>'1234',
|
106
|
+
'payerEmail'=>'a@b.com',
|
107
|
+
'token'=>'1234',
|
108
|
+
'transactionId'=>'123456'
|
109
|
+
},
|
110
|
+
'token'=> {
|
111
|
+
'cnpToken'=>'1234567890123',
|
112
|
+
'expDate'=>'1210',
|
113
|
+
'cardValidationNum'=>'555',
|
114
|
+
'type'=>'VI'
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
119
|
+
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_action_reason_on_orphaned_refund
|
123
|
+
hash = {
|
124
|
+
'merchantId' => '101',
|
125
|
+
'version'=>'8.12',
|
126
|
+
'orderId'=>'1',
|
127
|
+
'amount'=>'2',
|
128
|
+
'orderSource'=>'ecommerce',
|
129
|
+
'reportGroup'=>'Planets',
|
130
|
+
'actionReason'=> 'SUSPECT_FRAUD'
|
131
|
+
}
|
132
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<actionReason>SUSPECT_FRAUD<\/actionReason>.*/m), is_a(Hash))
|
133
|
+
CnpOnlineRequest.new.credit(hash)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_simple_enhanced_data_incorrect_enum_for_country_code
|
137
|
+
hash = {
|
138
|
+
'merchantId' => '101',
|
139
|
+
'version'=>'8.8',
|
140
|
+
'reportGroup'=>'Planets',
|
141
|
+
'orderId'=>'12344',
|
142
|
+
'amount'=>'106',
|
143
|
+
'card'=>{
|
144
|
+
'type'=>'VI',
|
145
|
+
'number' =>'4100000000000001',
|
146
|
+
'expDate' =>'1210'},
|
147
|
+
'orderSource'=>'ecommerce',
|
148
|
+
'enhancedData'=>{
|
149
|
+
'destinationCountryCode'=>'001',
|
150
|
+
'customerReference'=>'Cnp',
|
151
|
+
'salesTax'=>'50',
|
152
|
+
'deliveryType'=>'TBD',
|
153
|
+
'shipFromPostalCode'=>'01741',
|
154
|
+
'destinationPostalCode'=>'01742'}
|
155
|
+
}
|
156
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
157
|
+
assert_match /If enhancedData destinationCountryCode is specified, it must be/, exception.message
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_token_with_incorrect_token_Length
|
161
|
+
hash = {
|
162
|
+
'merchantId' => '101',
|
163
|
+
'version'=>'8.8',
|
164
|
+
'reportGroup'=>'Planets',
|
165
|
+
'orderId'=>'12344',
|
166
|
+
'amount'=>'106',
|
167
|
+
'orderSource'=>'ecommerce',
|
168
|
+
'token'=> {
|
169
|
+
'cnpToken'=>'123456789012',
|
170
|
+
'expDate'=>'1210',
|
171
|
+
'cardValidationNum'=>'555',
|
172
|
+
'type'=>'VI'
|
173
|
+
}}
|
174
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
175
|
+
assert_match /If token cnpToken is specified, it must be between/, exception.message
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_token_missing_token
|
179
|
+
hash = {
|
180
|
+
'merchantId' => '101',
|
181
|
+
'version'=>'8.8',
|
182
|
+
'reportGroup'=>'Planets',
|
183
|
+
'orderId'=>'12344',
|
184
|
+
'amount'=>'106',
|
185
|
+
'orderSource'=>'ecommerce',
|
186
|
+
'token'=> {
|
187
|
+
'expDate'=>'1210',
|
188
|
+
'cardValidationNum'=>'555',
|
189
|
+
'type'=>'VI'
|
190
|
+
}}
|
191
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
192
|
+
assert_match /If token is specified, it must have a cnpToken/, exception.message
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_pos_with_invalid_entry_mode
|
196
|
+
hash = {
|
197
|
+
'merchantId' => '101',
|
198
|
+
'version'=>'8.8',
|
199
|
+
'reportGroup'=>'Planets',
|
200
|
+
'orderId'=>'12344',
|
201
|
+
'amount'=>'106',
|
202
|
+
'orderSource'=>'ecommerce',
|
203
|
+
'pos'=>{'entryMode'=>'none','cardholderId'=>'pin','capability'=>'notused'},
|
204
|
+
'card'=>{
|
205
|
+
'type'=>'VI',
|
206
|
+
'number' =>'4100000000000001',
|
207
|
+
'expDate' =>'1210'
|
208
|
+
}}
|
209
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
210
|
+
assert_match /If pos entryMode is specified, it must be in/, exception.message
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_paypage_missing_id
|
214
|
+
hash = {
|
215
|
+
'merchantId' => '101',
|
216
|
+
'version'=>'8.8',
|
217
|
+
'reportGroup'=>'Planets',
|
218
|
+
'orderId'=>'12344',
|
219
|
+
'amount'=>'106',
|
220
|
+
'orderSource'=>'ecommerce',
|
221
|
+
'paypage'=> {
|
222
|
+
'expDate'=>'1210',
|
223
|
+
'cardValidationNum'=>'555',
|
224
|
+
'type'=>'VI'
|
225
|
+
}}
|
226
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
227
|
+
assert_match /If paypage is specified, it must have a paypageRegistrationId/, exception.message
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_logged_in_user
|
231
|
+
hash = {
|
232
|
+
'loggedInUser' => 'gdake',
|
233
|
+
'merchantSdk' => 'Ruby;8.14.0',
|
234
|
+
'merchantId' => '101',
|
235
|
+
'version'=>'8.12',
|
236
|
+
'orderId'=>'1',
|
237
|
+
'amount'=>'2',
|
238
|
+
'orderSource'=>'ecommerce',
|
239
|
+
'reportGroup'=>'Planets'
|
240
|
+
}
|
241
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
242
|
+
CnpOnlineRequest.new.credit(hash)
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_secondary_amount_tied
|
246
|
+
hash = {
|
247
|
+
'amount' => '2',
|
248
|
+
'secondaryAmount' => '1',
|
249
|
+
'cnpTxnId' => '3',
|
250
|
+
'processingInstructions' => {},
|
251
|
+
'reportGroup' => 'Planets'
|
252
|
+
}
|
253
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><process.*/m), is_a(Hash))
|
254
|
+
CnpOnlineRequest.new.credit(hash)
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_surcharge_amount_tied
|
258
|
+
hash = {
|
259
|
+
'amount' => '2',
|
260
|
+
'surchargeAmount' => '1',
|
261
|
+
'cnpTxnId' => '3',
|
262
|
+
'processingInstructions' => {},
|
263
|
+
'reportGroup' => 'Planets'
|
264
|
+
}
|
265
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><process.*/m), is_a(Hash))
|
266
|
+
CnpOnlineRequest.new.credit(hash)
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_surcharge_amount_tied_optional
|
270
|
+
hash = {
|
271
|
+
'amount' => '2',
|
272
|
+
'cnpTxnId' => '3',
|
273
|
+
'processingInstructions' => {},
|
274
|
+
'reportGroup' => 'Planets'
|
275
|
+
}
|
276
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><process.*/m), is_a(Hash))
|
277
|
+
CnpOnlineRequest.new.credit(hash)
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_secondary_amount_orphan
|
281
|
+
hash = {
|
282
|
+
'amount' => '2',
|
283
|
+
'secondaryAmount' => '1',
|
284
|
+
'orderSource' => 'ecommerce',
|
285
|
+
'reportGroup' => 'Planets'
|
286
|
+
}
|
287
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
288
|
+
CnpOnlineRequest.new.credit(hash)
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_surcharge_amount_orphan
|
292
|
+
hash = {
|
293
|
+
'amount' => '2',
|
294
|
+
'surchargeAmount' => '1',
|
295
|
+
'orderSource' => 'ecommerce',
|
296
|
+
'reportGroup' => 'Planets'
|
297
|
+
}
|
298
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
299
|
+
CnpOnlineRequest.new.credit(hash)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_surcharge_amount_orphan_optional
|
303
|
+
hash = {
|
304
|
+
'amount' => '2',
|
305
|
+
'orderSource' => 'ecommerce',
|
306
|
+
'reportGroup' => 'Planets'
|
307
|
+
}
|
308
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
309
|
+
CnpOnlineRequest.new.credit(hash)
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_pos_tied
|
313
|
+
hash = {
|
314
|
+
'amount' => '2',
|
315
|
+
'pos' => {
|
316
|
+
'terminalId' => 'abc123',
|
317
|
+
'capability' => 'magstripe',
|
318
|
+
'entryMode' => 'keyed',
|
319
|
+
'cardholderId' => 'nopin',
|
320
|
+
'catLevel' => 'self service'
|
321
|
+
},
|
322
|
+
'cnpTxnId' => '3',
|
323
|
+
'reportGroup' => 'Planets',
|
324
|
+
'orderSource' => 'ecommerce',
|
325
|
+
'payPalNotes' => 'notes'
|
326
|
+
}
|
327
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><pos><capability>magstripe<\/capability><entryMode>keyed<\/entryMode><cardholderId>nopin<\/cardholderId><terminalId>abc123<\/terminalId><catLevel>self service<\/catLevel><\/pos><payPalNotes>.*/m), is_a(Hash))
|
328
|
+
CnpOnlineRequest.new.credit(hash)
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_post_tied_optional
|
332
|
+
hash = {
|
333
|
+
'amount' => '2',
|
334
|
+
'cnpTxnId' => '3',
|
335
|
+
}
|
336
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><\/credit>.*/m), is_a(Hash))
|
337
|
+
CnpOnlineRequest.new.credit(hash)
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_pin
|
341
|
+
hash = {
|
342
|
+
'merchantId' => '101',
|
343
|
+
'version'=>'8.8',
|
344
|
+
'reportGroup'=>'Planets',
|
345
|
+
'amount'=>'106',
|
346
|
+
'secondaryAmount'=>'20',
|
347
|
+
'cnpTxnId'=>'1234',
|
348
|
+
'pin'=>'3333'
|
349
|
+
}
|
350
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<pin>3333<\/pin>.*/m), is_a(Hash))
|
351
|
+
CnpOnlineRequest.new.credit(hash)
|
352
|
+
end
|
353
|
+
|
354
|
+
end
|
355
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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
|
+
require 'mocha/setup'
|
28
|
+
module CnpOnline
|
29
|
+
class TestDeactivate < Test::Unit::TestCase
|
30
|
+
|
31
|
+
def test_simple
|
32
|
+
hash = {
|
33
|
+
'merchantId' => '101',
|
34
|
+
'version'=>'8.8',
|
35
|
+
'reportGroup'=>'Planets',
|
36
|
+
'orderId' => '11',
|
37
|
+
'orderSource'=>'ecommerce',
|
38
|
+
'card'=>
|
39
|
+
{
|
40
|
+
'type'=>'GC',
|
41
|
+
'number' =>'4100000000000001',
|
42
|
+
'expDate' =>'1210'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<deactivate reportGroup="Planets"><orderId>11<\/orderId><orderSource>ecommerce<\/orderSource><card><type>GC<\/type><number>4100000000000001<\/number><expDate>1210<\/expDate><\/card><\/deactivate>.*/m), is_a(Hash))
|
47
|
+
CnpOnlineRequest.new.deactivate(hash)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_simple
|
51
|
+
hash = {
|
52
|
+
'merchantId' => '101',
|
53
|
+
'version'=>'8.8',
|
54
|
+
'reportGroup'=>'Planets',
|
55
|
+
'orderId' => '11',
|
56
|
+
'orderSource'=>'ecommerce',
|
57
|
+
'card'=>
|
58
|
+
{
|
59
|
+
'type'=>'VI',
|
60
|
+
'number' =>'4100000000000001',
|
61
|
+
'expDate' =>'1210'
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<deactivate reportGroup="Planets"><orderId>11<\/orderId><orderSource>ecommerce<\/orderSource><card><type>VI<\/type><number>4100000000000001<\/number><expDate>1210<\/expDate><\/card><\/deactivate>.*/m), is_a(Hash))
|
66
|
+
CnpOnlineRequest.new.deactivate(hash)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|