CnpOnline 12.3.0 → 12.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +12 -0
  3. data/Rakefile +1 -1
  4. data/lib/CnpBatchRequest.rb +17 -8
  5. data/lib/CnpOnline.rb +2 -0
  6. data/lib/CnpOnlineRequest.rb +30 -2
  7. data/lib/CnpRequest.rb +24 -4
  8. data/lib/CnpTransaction.rb +70 -7
  9. data/lib/CommManager.rb +185 -0
  10. data/lib/Communications.rb +7 -3
  11. data/lib/EnvironmentVariables.rb +8 -0
  12. data/lib/RequestTarget.rb +10 -0
  13. data/lib/XMLFields.rb +148 -11
  14. data/out/production/cnp-sdk-for-ruby/CnpBatchRequest.rb +787 -0
  15. data/out/production/cnp-sdk-for-ruby/CnpListeners.rb +265 -0
  16. data/out/production/cnp-sdk-for-ruby/CnpOnline.rb +65 -0
  17. data/out/production/cnp-sdk-for-ruby/CnpOnlineRequest.rb +370 -0
  18. data/out/production/cnp-sdk-for-ruby/CnpRequest.rb +670 -0
  19. data/out/production/cnp-sdk-for-ruby/CnpTransaction.rb +831 -0
  20. data/out/production/cnp-sdk-for-ruby/CnpXmlMapper.rb +71 -0
  21. data/out/production/cnp-sdk-for-ruby/CommManager.rb +185 -0
  22. data/out/production/cnp-sdk-for-ruby/Communications.rb +90 -0
  23. data/out/production/cnp-sdk-for-ruby/Configuration.rb +75 -0
  24. data/out/production/cnp-sdk-for-ruby/EnvironmentVariables.rb +33 -0
  25. data/out/production/cnp-sdk-for-ruby/RequestTarget.rb +10 -0
  26. data/out/production/cnp-sdk-for-ruby/Setup.rb +147 -0
  27. data/out/production/cnp-sdk-for-ruby/XMLFields.rb +2638 -0
  28. data/out/production/cnp-sdk-for-ruby/cacert.pem +3331 -0
  29. data/out/production/cnp-sdk-for-ruby/sample_batch_driver.rb +123 -0
  30. data/out/production/cnp-sdk-for-ruby/sample_driver.rb +49 -0
  31. data/out/test/cnp-sdk-for-ruby/certification/certTest1_base.rb +948 -0
  32. data/out/test/cnp-sdk-for-ruby/certification/certTest2_authenhanced.rb +577 -0
  33. data/out/test/cnp-sdk-for-ruby/certification/certTest3_authreversal.rb +190 -0
  34. data/out/test/cnp-sdk-for-ruby/certification/certTest4_echeck.rb +288 -0
  35. data/out/test/cnp-sdk-for-ruby/certification/certTest5_token.rb +209 -0
  36. data/out/test/cnp-sdk-for-ruby/certification/certTest_batchAll.rb +610 -0
  37. data/out/test/cnp-sdk-for-ruby/certification/ts_all.rb +33 -0
  38. data/out/test/cnp-sdk-for-ruby/functional/test_activate.rb +133 -0
  39. data/out/test/cnp-sdk-for-ruby/functional/test_activateReversal.rb +73 -0
  40. data/out/test/cnp-sdk-for-ruby/functional/test_auth.rb +478 -0
  41. data/out/test/cnp-sdk-for-ruby/functional/test_authReversal.rb +74 -0
  42. data/out/test/cnp-sdk-for-ruby/functional/test_balanceInquiry.rb +107 -0
  43. data/out/test/cnp-sdk-for-ruby/functional/test_batch.rb +264 -0
  44. data/out/test/cnp-sdk-for-ruby/functional/test_batchStream.rb +154 -0
  45. data/out/test/cnp-sdk-for-ruby/functional/test_cancelSubscription.rb +57 -0
  46. data/out/test/cnp-sdk-for-ruby/functional/test_capture.rb +147 -0
  47. data/out/test/cnp-sdk-for-ruby/functional/test_captureGivenAuth.rb +352 -0
  48. data/out/test/cnp-sdk-for-ruby/functional/test_commManager.rb +302 -0
  49. data/out/test/cnp-sdk-for-ruby/functional/test_configuration.rb +89 -0
  50. data/out/test/cnp-sdk-for-ruby/functional/test_createPlan.rb +87 -0
  51. data/out/test/cnp-sdk-for-ruby/functional/test_credit.rb +222 -0
  52. data/out/test/cnp-sdk-for-ruby/functional/test_ctx.rb +124 -0
  53. data/out/test/cnp-sdk-for-ruby/functional/test_deactivate.rb +105 -0
  54. data/out/test/cnp-sdk-for-ruby/functional/test_deactivateReversal.rb +71 -0
  55. data/out/test/cnp-sdk-for-ruby/functional/test_depositReversal.rb +70 -0
  56. data/out/test/cnp-sdk-for-ruby/functional/test_echeckCredit.rb +179 -0
  57. data/out/test/cnp-sdk-for-ruby/functional/test_echeckRedeposit.rb +117 -0
  58. data/out/test/cnp-sdk-for-ruby/functional/test_echeckSale.rb +255 -0
  59. data/out/test/cnp-sdk-for-ruby/functional/test_echeckVerification.rb +160 -0
  60. data/out/test/cnp-sdk-for-ruby/functional/test_echeckVoid.rb +42 -0
  61. data/out/test/cnp-sdk-for-ruby/functional/test_fastAccessFunding.rb +177 -0
  62. data/out/test/cnp-sdk-for-ruby/functional/test_forceCapture.rb +272 -0
  63. data/out/test/cnp-sdk-for-ruby/functional/test_fraudCheck.rb +76 -0
  64. data/out/test/cnp-sdk-for-ruby/functional/test_giftCardAuthReversal.rb +72 -0
  65. data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCapture.rb +72 -0
  66. data/out/test/cnp-sdk-for-ruby/functional/test_giftCardCredit.rb +69 -0
  67. data/out/test/cnp-sdk-for-ruby/functional/test_litle_requests.rb +355 -0
  68. data/out/test/cnp-sdk-for-ruby/functional/test_load.rb +108 -0
  69. data/out/test/cnp-sdk-for-ruby/functional/test_loadReversal.rb +71 -0
  70. data/out/test/cnp-sdk-for-ruby/functional/test_override.rb +68 -0
  71. data/out/test/cnp-sdk-for-ruby/functional/test_pgp_cnp_requests.rb +295 -0
  72. data/out/test/cnp-sdk-for-ruby/functional/test_queryTransaction.rb +154 -0
  73. data/out/test/cnp-sdk-for-ruby/functional/test_refundReversal.rb +71 -0
  74. data/out/test/cnp-sdk-for-ruby/functional/test_sale.rb +459 -0
  75. data/out/test/cnp-sdk-for-ruby/functional/test_token.rb +137 -0
  76. data/out/test/cnp-sdk-for-ruby/functional/test_translateToken.rb +203 -0
  77. data/out/test/cnp-sdk-for-ruby/functional/test_unload.rb +108 -0
  78. data/out/test/cnp-sdk-for-ruby/functional/test_unloadReversal.rb +71 -0
  79. data/out/test/cnp-sdk-for-ruby/functional/test_updateCardValidationNumOnToken.rb +44 -0
  80. data/out/test/cnp-sdk-for-ruby/functional/test_updatePlan.rb +61 -0
  81. data/out/test/cnp-sdk-for-ruby/functional/test_updateSubscription.rb +80 -0
  82. data/out/test/cnp-sdk-for-ruby/functional/test_wallet.rb +74 -0
  83. data/out/test/cnp-sdk-for-ruby/functional/test_xmlfields.rb +429 -0
  84. data/out/test/cnp-sdk-for-ruby/functional/ts_all.rb +69 -0
  85. data/out/test/cnp-sdk-for-ruby/unit/test_LitleAUBatch.rb +244 -0
  86. data/out/test/cnp-sdk-for-ruby/unit/test_LitleBatchRequest.rb +791 -0
  87. data/out/test/cnp-sdk-for-ruby/unit/test_LitleOnlineRequest.rb +253 -0
  88. data/out/test/cnp-sdk-for-ruby/unit/test_LitleRequest.rb +317 -0
  89. data/out/test/cnp-sdk-for-ruby/unit/test_LitleTransaction.rb +426 -0
  90. data/out/test/cnp-sdk-for-ruby/unit/test_LitleXmlMapper.rb +139 -0
  91. data/out/test/cnp-sdk-for-ruby/unit/test_activate.rb +92 -0
  92. data/out/test/cnp-sdk-for-ruby/unit/test_activateReversal.rb +56 -0
  93. data/out/test/cnp-sdk-for-ruby/unit/test_auth.rb +463 -0
  94. data/out/test/cnp-sdk-for-ruby/unit/test_authReversal.rb +82 -0
  95. data/out/test/cnp-sdk-for-ruby/unit/test_balanceInquiry.rb +52 -0
  96. data/out/test/cnp-sdk-for-ruby/unit/test_cancelSubscription.rb +43 -0
  97. data/out/test/cnp-sdk-for-ruby/unit/test_capture.rb +99 -0
  98. data/out/test/cnp-sdk-for-ruby/unit/test_captureGivenAuth.rb +234 -0
  99. data/out/test/cnp-sdk-for-ruby/unit/test_createPlan.rb +52 -0
  100. data/out/test/cnp-sdk-for-ruby/unit/test_credit.rb +355 -0
  101. data/out/test/cnp-sdk-for-ruby/unit/test_deactivate.rb +71 -0
  102. data/out/test/cnp-sdk-for-ruby/unit/test_deactivateReversal.rb +56 -0
  103. data/out/test/cnp-sdk-for-ruby/unit/test_depositReversal.rb +56 -0
  104. data/out/test/cnp-sdk-for-ruby/unit/test_echeckCredit.rb +103 -0
  105. data/out/test/cnp-sdk-for-ruby/unit/test_echeckRedeposit.rb +109 -0
  106. data/out/test/cnp-sdk-for-ruby/unit/test_echeckSale.rb +107 -0
  107. data/out/test/cnp-sdk-for-ruby/unit/test_echeckVerification.rb +74 -0
  108. data/out/test/cnp-sdk-for-ruby/unit/test_echeckVoid.rb +54 -0
  109. data/out/test/cnp-sdk-for-ruby/unit/test_forceCapture.rb +163 -0
  110. data/out/test/cnp-sdk-for-ruby/unit/test_fraudCheck.rb +45 -0
  111. data/out/test/cnp-sdk-for-ruby/unit/test_giftCardAuthReversal.rb +58 -0
  112. data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCapture.rb +57 -0
  113. data/out/test/cnp-sdk-for-ruby/unit/test_giftCardCredit.rb +57 -0
  114. data/out/test/cnp-sdk-for-ruby/unit/test_load.rb +53 -0
  115. data/out/test/cnp-sdk-for-ruby/unit/test_loadReversal.rb +56 -0
  116. data/out/test/cnp-sdk-for-ruby/unit/test_pgp_CnpRequest.rb +139 -0
  117. data/out/test/cnp-sdk-for-ruby/unit/test_queryTransaction.rb +106 -0
  118. data/out/test/cnp-sdk-for-ruby/unit/test_refundReversal.rb +56 -0
  119. data/out/test/cnp-sdk-for-ruby/unit/test_sale.rb +551 -0
  120. data/out/test/cnp-sdk-for-ruby/unit/test_token.rb +159 -0
  121. data/out/test/cnp-sdk-for-ruby/unit/test_unload.rb +53 -0
  122. data/out/test/cnp-sdk-for-ruby/unit/test_unloadReversal.rb +56 -0
  123. data/out/test/cnp-sdk-for-ruby/unit/test_updateCardValidationNumOnToken.rb +80 -0
  124. data/out/test/cnp-sdk-for-ruby/unit/test_updatePlan.rb +45 -0
  125. data/out/test/cnp-sdk-for-ruby/unit/test_updateSubscription.rb +172 -0
  126. data/out/test/cnp-sdk-for-ruby/unit/test_wallet.rb +262 -0
  127. data/out/test/cnp-sdk-for-ruby/unit/test_xmlfields.rb +2930 -0
  128. data/out/test/cnp-sdk-for-ruby/unit/ts_unit.rb +67 -0
  129. data/test/certification/certTest2_authenhanced.rb +28 -27
  130. data/test/functional/test_batch.rb +106 -1
  131. data/test/functional/test_batchStream.rb +3 -2
  132. data/test/functional/test_captureGivenAuth.rb +24 -0
  133. data/test/functional/test_commManager.rb +302 -0
  134. data/test/functional/test_ctx.rb +124 -0
  135. data/test/functional/test_fastAccessFunding.rb +21 -0
  136. data/test/functional/test_forceCapture.rb +21 -0
  137. data/test/functional/test_xmlfields.rb +20 -1
  138. metadata +122 -4
@@ -0,0 +1,426 @@
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
+
27
+ require 'test/unit'
28
+ require 'mocha/setup'
29
+
30
+ module CnpOnline
31
+
32
+ class TestCnpTransaction < Test::Unit::TestCase
33
+
34
+
35
+ def test_authorization
36
+ ltlTxn = CnpTransaction.new
37
+ authHash = {
38
+ 'reportGroup'=>'Planets',
39
+ 'id'=>'12345',
40
+ 'customerId'=>'0987',
41
+ 'orderId'=>'12344',
42
+ 'amount'=>'106',
43
+ 'orderSource'=>'ecommerce',
44
+ 'card'=>{
45
+ 'type'=>'VI',
46
+ 'number' =>'4100000000000001',
47
+ 'expDate' =>'1210'
48
+ }}
49
+
50
+ result = ltlTxn.authorization(authHash)
51
+ assert_equal 'Planets', result.reportGroup
52
+ assert_equal '12345', result.transactionId
53
+ assert_equal '0987', result.customerId
54
+ assert_equal "12344", result.orderId
55
+ assert_equal "106", result.amount
56
+ assert_equal "ecommerce", result.orderSource
57
+ assert_equal "4100000000000001", result.card.number
58
+ assert_equal "VI", result.card.mop
59
+ assert_equal "1210", result.card.expDate
60
+ end
61
+
62
+ def test_sale
63
+ ltlTxn = CnpTransaction.new
64
+ saleHash = {
65
+ 'reportGroup'=>'Planets',
66
+ 'id'=>'12345',
67
+ 'customerId'=>'0987',
68
+ 'orderId'=>'12344',
69
+ 'amount'=>'6000',
70
+ 'orderSource'=>'ecommerce',
71
+ 'card'=>{
72
+ 'type'=>'VI',
73
+ 'number' =>'4100000000000001',
74
+ 'expDate' =>'1210'
75
+ }}
76
+
77
+ result = ltlTxn.sale(saleHash)
78
+ assert_equal 'Planets', result.reportGroup
79
+ assert_equal '12345', result.transactionId
80
+ assert_equal '0987', result.customerId
81
+ assert_equal "12344", result.orderId
82
+ assert_equal "6000", result.amount
83
+ assert_equal "ecommerce", result.orderSource
84
+ assert_equal "4100000000000001", result.card.number
85
+ assert_equal "VI", result.card.mop
86
+ assert_equal "1210", result.card.expDate
87
+ end
88
+
89
+ def test_credit
90
+ ltlTxn = CnpTransaction.new
91
+ creditHash = {
92
+ 'merchantId' => '101',
93
+ 'version'=>'8.8',
94
+ 'reportGroup'=>'Planets',
95
+ 'id'=>'12345',
96
+ 'customerId'=>'0987',
97
+ 'orderId'=>'12344',
98
+ 'amount'=>'106',
99
+ 'orderSource'=>'ecommerce',
100
+ 'card'=>{
101
+ 'type'=>'VI',
102
+ 'number' =>'4100000000000001',
103
+ 'expDate' =>'1210'
104
+ }}
105
+
106
+ result = ltlTxn.credit(creditHash)
107
+ assert_equal 'Planets', result.reportGroup
108
+ assert_equal '12345', result.transactionId
109
+ assert_equal '0987', result.customerId
110
+ assert_equal '12344', result.orderId
111
+ assert_equal '106', result.amount
112
+ assert_equal 'ecommerce', result.orderSource
113
+ assert_equal '4100000000000001', result.card.number
114
+ assert_equal 'VI', result.card.mop
115
+ assert_equal '1210', result.card.expDate
116
+ end
117
+
118
+ def test_auth_reversal
119
+ ltlTxn = CnpTransaction.new
120
+ authReversalHash = {
121
+ 'merchantId' => '101',
122
+ 'version'=>'8.8',
123
+ 'reportGroup'=>'Planets',
124
+ 'id'=>'12345',
125
+ 'customerId'=>'0987',
126
+ 'cnpTxnId'=>'12345678000',
127
+ 'amount'=>'106',
128
+ 'payPalNotes'=>'Notes'
129
+ }
130
+
131
+ result = ltlTxn.auth_reversal(authReversalHash)
132
+ assert_equal 'Planets', result.reportGroup
133
+ assert_equal '12345', result.transactionId
134
+ assert_equal '0987', result.customerId
135
+ assert_equal '12345678000', result.cnpTxnId
136
+ assert_equal '106', result.amount
137
+ assert_equal 'Notes', result.payPalNotes
138
+ end
139
+
140
+ def test_register_token_request
141
+ ltlTxn = CnpTransaction.new
142
+ registerTokenHash = {
143
+ 'merchantId' => '101',
144
+ 'version'=>'8.8',
145
+ 'reportGroup'=>'Planets',
146
+ 'id'=>'12345',
147
+ 'customerId'=>'0987',
148
+ 'orderId'=>'12344',
149
+ 'accountNumber'=>'1233456789103801'
150
+ }
151
+
152
+ result = ltlTxn.register_token_request(registerTokenHash)
153
+ assert_equal 'Planets', result.reportGroup
154
+ assert_equal '12345', result.transactionId
155
+ assert_equal '0987', result.customerId
156
+ assert_equal '12344', result.orderId
157
+ assert_equal '1233456789103801', result.accountNumber
158
+ end
159
+
160
+ def test_update_card_validation_num_on_token
161
+ ltlTxn = CnpTransaction.new
162
+ updateCardHash = {
163
+ 'merchantId' => '101',
164
+ 'version'=>'8.8',
165
+ 'reportGroup'=>'Planets',
166
+ 'id'=>'12345',
167
+ 'customerId'=>'0987',
168
+ 'orderId'=>'12344',
169
+ 'cnpToken'=>'1233456789103801',
170
+ 'cardValidationNum'=>'123'
171
+ }
172
+
173
+ result = ltlTxn.update_card_validation_num_on_token(updateCardHash)
174
+ assert_equal 'Planets', result.reportGroup
175
+ assert_equal '12345', result.transactionId
176
+ assert_equal '0987', result.customerId
177
+ assert_equal '12344', result.orderId
178
+ assert_equal '1233456789103801', result.cnpToken
179
+ assert_equal '123', result.cardValidationNum
180
+ end
181
+
182
+ def test_force_capture
183
+ ltlTxn = CnpTransaction.new
184
+ forceCaptHash = {
185
+ 'merchantId' => '101',
186
+ 'version'=>'8.8',
187
+ 'reportGroup'=>'Planets',
188
+ 'id'=>'12345',
189
+ 'customerId'=>'0987',
190
+ 'orderId'=>'12344',
191
+ 'amount'=>'106',
192
+ 'orderSource'=>'ecommerce',
193
+ 'card'=>{
194
+ 'type'=>'VI',
195
+ 'number' =>'4100000000000001',
196
+ 'expDate' =>'1210'
197
+ }}
198
+
199
+ result = ltlTxn.force_capture(forceCaptHash)
200
+ assert_equal 'Planets', result.reportGroup
201
+ assert_equal '12345', result.transactionId
202
+ assert_equal '0987', result.customerId
203
+ assert_equal '12344', result.orderId
204
+ assert_equal '106', result.amount
205
+ assert_equal 'ecommerce', result.orderSource
206
+ assert_equal 'VI', result.card.mop
207
+ assert_equal '4100000000000001', result.card.number
208
+ assert_equal '1210', result.card.expDate
209
+ end
210
+
211
+ def test_capture
212
+ ltlTxn = CnpTransaction.new
213
+ captHash = {
214
+ 'merchantId' => '101',
215
+ 'version'=>'8.8',
216
+ 'reportGroup'=>'Planets',
217
+ 'id'=>'12345',
218
+ 'customerId'=>'0987',
219
+ 'cnpTxnId'=>'123456000',
220
+ 'amount'=>'106',
221
+ }
222
+
223
+ result = ltlTxn.capture(captHash)
224
+ assert_equal 'Planets', result.reportGroup
225
+ assert_equal '12345', result.transactionId
226
+ assert_equal '0987', result.customerId
227
+ assert_equal '123456000', result.cnpTxnId
228
+ assert_equal '106', result.amount
229
+ end
230
+
231
+ def test_capture_given_auth
232
+ ltlTxn = CnpTransaction.new
233
+ captGivenAuthHash = {
234
+ 'merchantId' => '101',
235
+ 'version'=>'8.8',
236
+ 'reportGroup'=>'Planets',
237
+ 'id'=>'12345',
238
+ 'customerId'=>'0987',
239
+ 'orderId'=>'12344',
240
+ 'amount'=>'106',
241
+ 'authInformation' => {
242
+ 'authDate'=>'2002-10-09',
243
+ 'authCode'=>'543216',
244
+ 'authAmount'=>'12345'
245
+ },
246
+ 'orderSource'=>'ecommerce',
247
+ 'card'=>{
248
+ 'type'=>'VI',
249
+ 'number' =>'4100000000000000',
250
+ 'expDate' =>'1210'
251
+ }}
252
+
253
+ result = ltlTxn.capture_given_auth(captGivenAuthHash)
254
+ assert_equal 'Planets', result.reportGroup
255
+ assert_equal '12345', result.transactionId
256
+ assert_equal '0987', result.customerId
257
+ assert_equal '12344', result.orderId
258
+ assert_equal '106', result.amount
259
+ assert_equal 'ecommerce', result.orderSource
260
+ assert_equal 'VI', result.card.mop
261
+ assert_equal '4100000000000000', result.card.number
262
+ assert_equal '1210', result.card.expDate
263
+ assert_equal '2002-10-09', result.authInformation.authDate
264
+ assert_equal '543216', result.authInformation.authCode
265
+ assert_equal '12345', result.authInformation.authAmount
266
+ end
267
+
268
+ def test_echeck_verification
269
+ ltlTxn = CnpTransaction.new
270
+ echeckVerificationHash = {
271
+ 'merchantId' => '101',
272
+ 'version'=>'8.8',
273
+ 'reportGroup'=>'Planets',
274
+ 'id'=>'12345',
275
+ 'customerId'=>'0987',
276
+ 'amount'=>'123456',
277
+ 'orderId'=>'12345',
278
+ 'orderSource'=>'ecommerce',
279
+ 'echeck' => {'accType'=>'Checking',
280
+ 'accNum'=>'12345657890',
281
+ 'routingNum'=>'123456789',
282
+ 'checkNum'=>'123455'},
283
+ 'billToAddress'=>{'name'=>'Bob',
284
+ 'city'=>'lowell',
285
+ 'state'=>'MA',
286
+ 'email'=>'cnp.com'}
287
+ }
288
+
289
+ result = ltlTxn.echeck_verification(echeckVerificationHash)
290
+ assert_equal 'Planets', result.reportGroup
291
+ assert_equal '12345', result.transactionId
292
+ assert_equal '0987', result.customerId
293
+ assert_equal '12345', result.orderId
294
+ assert_equal '123456', result.amount
295
+ assert_equal 'ecommerce', result.orderSource
296
+ assert_equal 'Checking', result.echeck.accType
297
+ assert_equal '12345657890', result.echeck.accNum
298
+ assert_equal '123456789', result.echeck.routingNum
299
+ assert_equal '123455', result.echeck.checkNum
300
+ assert_equal 'Bob', result.billToAddress.name
301
+ assert_equal 'lowell', result.billToAddress.city
302
+ assert_equal 'MA', result.billToAddress.state
303
+ assert_equal 'cnp.com', result.billToAddress.email
304
+ end
305
+
306
+ def test_echeck_credit
307
+ ltlTxn = CnpTransaction.new
308
+ echeckCreditHash = {
309
+ 'merchantId' => '101',
310
+ 'version'=>'8.8',
311
+ 'reportGroup'=>'Planets',
312
+ 'id'=>'12345',
313
+ 'customerId'=>'0987',
314
+ 'cnpTxnId'=>'123456789101112',
315
+ 'amount'=>'12'
316
+ }
317
+
318
+ result = ltlTxn.echeck_credit(echeckCreditHash)
319
+ assert_equal 'Planets', result.reportGroup
320
+ assert_equal '12345', result.transactionId
321
+ assert_equal '0987', result.customerId
322
+ assert_equal '123456789101112', result.cnpTxnId
323
+ assert_equal '12', result.amount
324
+ end
325
+
326
+ def test_echeck_redeposit
327
+ ltlTxn = CnpTransaction.new
328
+ echeckRedeopsitHash = {
329
+ 'merchantId' => '101',
330
+ 'version'=>'8.8',
331
+ 'reportGroup'=>'Planets',
332
+ 'id'=>'12345',
333
+ 'customerId'=>'0987',
334
+ 'cnpTxnId'=>'123456'
335
+ }
336
+
337
+ result = ltlTxn.echeck_redeposit(echeckRedeopsitHash)
338
+ assert_equal 'Planets', result.reportGroup
339
+ assert_equal '12345', result.transactionId
340
+ assert_equal '0987', result.customerId
341
+ assert_equal '123456', result.cnpTxnId
342
+ end
343
+
344
+ def test_echeck_sale
345
+ ltlTxn = CnpTransaction.new
346
+ echeckSaleHash = {
347
+ 'merchantId' => '101',
348
+ 'version'=>'8.8',
349
+ 'reportGroup'=>'Planets',
350
+ 'id'=>'12345',
351
+ 'customerId'=>'0987',
352
+ 'amount'=>'123456',
353
+ 'verify'=>'true',
354
+ 'orderId'=>'12345',
355
+ 'orderSource'=>'ecommerce',
356
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
357
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'cnp.com'}
358
+ }
359
+
360
+ result = ltlTxn.echeck_sale(echeckSaleHash)
361
+ assert_equal 'Planets', result.reportGroup
362
+ assert_equal '12345', result.transactionId
363
+ assert_equal '0987', result.customerId
364
+ assert_equal '12345', result.orderId
365
+ assert_equal '123456', result.amount
366
+ assert_equal 'true', result.verify
367
+ assert_equal 'ecommerce', result.orderSource
368
+ assert_equal 'Checking', result.echeck.accType
369
+ assert_equal '12345657890', result.echeck.accNum
370
+ assert_equal '123456789', result.echeck.routingNum
371
+ assert_equal '123455', result.echeck.checkNum
372
+ assert_equal 'Bob', result.billToAddress.name
373
+ assert_equal 'lowell', result.billToAddress.city
374
+ assert_equal 'MA', result.billToAddress.state
375
+ assert_equal 'cnp.com', result.billToAddress.email
376
+ end
377
+
378
+ def test_account_update
379
+ ltlTxn = CnpTransaction.new
380
+ accountUpdateHash = {
381
+ 'reportGroup'=>'Planets',
382
+ 'id'=>'12345',
383
+ 'customerId'=>'0987',
384
+ 'card'=>{
385
+ 'type'=>'VI',
386
+ 'number' =>'4100000000000001',
387
+ 'expDate' =>'1210'
388
+ }}
389
+
390
+ result = ltlTxn.account_update(accountUpdateHash)
391
+ assert_equal 'Planets', result.reportGroup
392
+ assert_equal '12345', result.transactionId
393
+ assert_equal '0987', result.customerId
394
+ assert_equal "4100000000000001", result.card.number
395
+ assert_equal "VI", result.card.mop
396
+ assert_equal "1210", result.card.expDate
397
+ end
398
+
399
+
400
+ def test_queryTransaction
401
+ ltlTxn = CnpTransaction.new
402
+ queryTransactionHash = {
403
+ 'merchantId' => '101',
404
+ 'version'=>'8.8',
405
+ 'reportGroup'=>'Planets',
406
+ 'id'=>'12345',
407
+ 'customerId'=>'0987',
408
+ 'origId'=>'834262',
409
+ 'origActionType'=>'A',
410
+ 'origCnpTxnId'=>'123456',
411
+ 'origOrderId' => '65347567',
412
+ 'origAccountNumber'=>'4000000000000001'
413
+ }
414
+
415
+ result = ltlTxn.query_Transaction(queryTransactionHash)
416
+ assert_equal 'Planets', result.reportGroup
417
+ assert_equal '12345', result.transactionId
418
+ assert_equal '0987', result.customerId
419
+ assert_equal '834262', result.origId
420
+ assert_equal 'A', result.origActionType
421
+ assert_equal '123456', result.origCnpTxnId
422
+ #assert_equal '65347567', result.origOrderId
423
+ #assert_equal '4000000000000001', result.origAccountNumber
424
+ end
425
+ end
426
+ end
@@ -0,0 +1,139 @@
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
+
26
+
27
+ require File.expand_path("../../../lib/CnpOnline",__FILE__)
28
+ require 'test/unit'
29
+ require 'mocha/setup'
30
+
31
+ module CnpOnline
32
+ class TestCnpXmlMapper < Test::Unit::TestCase
33
+
34
+ def test_CnpXmlMapper_request_xml_response_0
35
+ hash =
36
+ {
37
+ 'merchantId' => '101',
38
+ 'id' => 'test',
39
+ 'version'=>'8.8',
40
+ 'reportGroup'=>'Planets',
41
+ 'cnpTxnId'=>'123456',
42
+ }
43
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"0\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
44
+ response = CnpXmlMapper.request("","")
45
+ assert_equal('0',response.response)
46
+ end
47
+
48
+ def test_CnpXmlMapper_request_xml_response_1
49
+ hash =
50
+ {
51
+ 'merchantId' => '101',
52
+ 'id' => 'test',
53
+ 'version'=>'8.8',
54
+ 'reportGroup'=>'Planets',
55
+ 'cnpTxnId'=>'123456',
56
+ }
57
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"1\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
58
+ #Get exceptions
59
+ exception = assert_raise(RuntimeError){
60
+ CnpXmlMapper.request("","")
61
+ }
62
+ #Test
63
+ assert(exception.message =~ /Error with http response, code: 1/)
64
+ end
65
+
66
+ def test_CnpXmlMapper_request_xml_response_2
67
+ hash =
68
+ {
69
+ 'merchantId' => '101',
70
+ 'id' => 'test',
71
+ 'version'=>'8.8',
72
+ 'reportGroup'=>'Planets',
73
+ 'cnpTxnId'=>'123456',
74
+ }
75
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"2\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
76
+ #Get exceptions
77
+ exception = assert_raise(RuntimeError){
78
+ CnpXmlMapper.request("","")
79
+ }
80
+ #Test
81
+ assert(exception.message =~ /Error with http response, code: 2/)
82
+ end
83
+
84
+ def test_CnpXmlMapper_request_xml_response_3
85
+ hash =
86
+ {
87
+ 'merchantId' => '101',
88
+ 'id' => 'test',
89
+ 'version'=>'8.8',
90
+ 'reportGroup'=>'Planets',
91
+ 'cnpTxnId'=>'123456',
92
+ }
93
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"3\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
94
+ #Get exceptions
95
+ exception = assert_raise(RuntimeError){
96
+ CnpXmlMapper.request("","")
97
+ }
98
+ #Test
99
+ assert(exception.message =~ /Error with http response, code: 3/)
100
+ end
101
+
102
+ def test_CnpXmlMapper_request_xml_response_4
103
+ hash =
104
+ {
105
+ 'merchantId' => '101',
106
+ 'id' => 'test',
107
+ 'version'=>'8.8',
108
+ 'reportGroup'=>'Planets',
109
+ 'cnpTxnId'=>'123456',
110
+ }
111
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"4\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
112
+ #Get exceptions
113
+ exception = assert_raise(RuntimeError){
114
+ CnpXmlMapper.request("","")
115
+ }
116
+ #Test
117
+ assert(exception.message =~ /Error with http response, code: 4/)
118
+ end
119
+
120
+ def test_CnpXmlMapper_request_xml_response_5
121
+ hash =
122
+ {
123
+ 'merchantId' => '101',
124
+ 'id' => 'test',
125
+ 'version'=>'8.8',
126
+ 'reportGroup'=>'Planets',
127
+ 'cnpTxnId'=>'123456',
128
+ }
129
+ Communications.expects(:http_post).returns("<cnpOnlineResponse version=\"1.0\" xmlns=\"http://www.vantivcnp.com/schema/online\" response=\"5\" message=\"Invalid credentials. Contact support@cnp.com.\"></cnpOnlineResponse>")
130
+ #Get exceptions
131
+ exception = assert_raise(RuntimeError){
132
+ CnpXmlMapper.request("","")
133
+ }
134
+ #Test
135
+ assert(exception.message =~ /Error with http response, code: 5/)
136
+ end
137
+
138
+ end
139
+ end