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,154 @@
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
+ require File.expand_path("../../../lib/CnpOnline",__FILE__)
27
+ require 'test/unit'
28
+ module CnpOnline
29
+ class TestqueryTransaction < Test::Unit::TestCase
30
+ def test_queryTransaction
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'id' => 'test',
34
+ 'version'=>'10.0',
35
+ 'reportGroup'=>'Some RG',
36
+ 'customerId' => '038945',
37
+ 'origId' => '834262',
38
+ 'origActionType' => 'A',
39
+ 'transactionId'=>'123456',
40
+ 'orderId'=>'65347567',
41
+ #'origAccountNumber' => '4000000000000001'
42
+ }
43
+ response= CnpOnlineRequest.new.query_Transaction(hash)
44
+ assert_equal('150', response.queryTransactionResponse.response)
45
+ end
46
+
47
+
48
+ def test_queryTransaction_noOrigId_noOrigActionType
49
+ hash = {
50
+ 'merchantId' => '101',
51
+ 'id' => 'test',
52
+ 'version'=>'10.0',
53
+ 'reportGroup'=>'Some RG',
54
+ 'customerId' => '038945',
55
+ 'transactionId'=>'123456',
56
+ 'orderId'=>'65347567',
57
+ #'origAccountNumber' => '4000000000000001'
58
+ }
59
+ response= CnpOnlineRequest.new.query_Transaction(hash)
60
+ assert_equal('150', response.queryTransactionResponse.response)
61
+ end
62
+
63
+ def test_queryTransaction_withShowStatusOnly
64
+ hash = {
65
+ 'merchantId' => '101',
66
+ 'id' => 'test',
67
+ 'version'=>'10.0',
68
+ 'reportGroup'=>'Some RG',
69
+ 'customerId' => '038945',
70
+ 'origId' => '834262',
71
+ 'origActionType' => 'A',
72
+ 'transactionId'=>'123456',
73
+ 'orderId'=>'65347567',
74
+ 'showStatusOnly' => 'Y'
75
+ #'origAccountNumber' => '4000000000000001'
76
+ }
77
+ response= CnpOnlineRequest.new.query_Transaction(hash)
78
+ assert_equal('150', response.queryTransactionResponse.response)
79
+ end
80
+
81
+ def test_queryTransaction_invalidShowStatusOnly
82
+ hash = {
83
+ 'merchantId' => '101',
84
+ 'id' => 'test',
85
+ 'version'=>'10.0',
86
+ 'reportGroup'=>'Some RG',
87
+ 'customerId' => '038945',
88
+ 'origId' => '834262',
89
+ 'origActionType' => 'A',
90
+ 'transactionId'=>'123456',
91
+ 'orderId'=>'65347567',
92
+ 'showStatusOnly' => 'A'
93
+ #'origAccountNumber' => '4000000000000001'
94
+ }
95
+ #Get exceptions
96
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
97
+ #Test
98
+ assert(exception.message =~ /Error validating xml data against the schema/)
99
+ end
100
+
101
+ def test_queryTransaction_valid_enum
102
+ hash = {
103
+ 'merchantId' => '101',
104
+ 'id' => 'test',
105
+ 'version'=>'10.0',
106
+ 'reportGroup'=>'Some RG',
107
+ 'customerId' => '038945',
108
+ 'origId' => '834262',
109
+ 'origActionType' => '',
110
+ 'transactionId'=>'123456',
111
+ 'orderId'=>'65347567',
112
+ #'origAccountNumber' => '4000000000000001'
113
+ }
114
+ response= CnpOnlineRequest.new.query_Transaction(hash)
115
+ assert('000', response.queryTransactionResponse.response)
116
+ end
117
+
118
+ def test_queryTransaction_invalid_values
119
+ hash = {
120
+ 'merchantId' => '101',
121
+ 'id' => 'test',
122
+ 'version'=>'10.0',
123
+ 'reportGroup'=>'Some RG',
124
+ 'customerId' => '038945',
125
+ 'origId' => '834262',
126
+ 'origActionType' => 'AAA',
127
+ 'transactionId'=>'123456',
128
+ 'orderId'=>'65347567',
129
+ #'origAccountNumber' => '4000000000000001'
130
+ }
131
+ #Get exceptions
132
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.query_Transaction(hash)}
133
+ #Test
134
+ assert(exception.message =~ /Error validating xml data against the schema/)
135
+ end
136
+
137
+ def test_queryTransaction_unavailable_response
138
+ hash = {
139
+ 'merchantId' => '101',
140
+ 'id' => 'test',
141
+ 'version'=>'10.0',
142
+ 'reportGroup'=>'Some RG',
143
+ 'customerId' => '038945',
144
+ 'origId' => 'aaa',
145
+ 'origActionType' => 'A',
146
+ 'transactionId'=>'123456',
147
+ 'orderId'=>'65347567',
148
+ #'origAccountNumber' => '4000000000000001'
149
+ }
150
+ response= CnpOnlineRequest.new.query_Transaction(hash)
151
+ assert_equal('152', response.queryTransactionUnavailableResponse.response)
152
+ end
153
+ end
154
+ 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
+
28
+ #test RefundReversal Transaction
29
+ module CnpOnline
30
+ class TestRefundReversal < Test::Unit::TestCase
31
+
32
+ def test_simple
33
+ hash = {
34
+ 'merchantId' => '101',
35
+ 'version'=>'8.8',
36
+ 'id'=>'test',
37
+ 'reportGroup'=>'Planets',
38
+ 'cnpTxnId' =>'5000',
39
+ 'card'=>{
40
+ 'type'=>'GC',
41
+ 'number' =>'400000000000001',
42
+ 'expDate' =>'0150',
43
+ 'pin' => '1234',
44
+ 'cardValidationNum' => '411'
45
+ },
46
+ 'originalRefCode' => '101',
47
+ 'originalAmount' => '34561',
48
+ 'originalTxnTime' => '2017-01-24T09:00:00',
49
+ 'originalSystemTraceId' => '33',
50
+ 'originalSequenceNumber' => '111111',
51
+ }
52
+
53
+ response= CnpOnlineRequest.new.deposit_reversal(hash)
54
+ assert_equal('000', response.depositReversalResponse.response)
55
+ end
56
+
57
+
58
+ def test_simple_error
59
+ hash = {
60
+ 'merchantId' => '101',
61
+ 'version'=>'8.8',
62
+ 'reportGroup'=>'Planets',
63
+ }
64
+
65
+ #Get exceptions
66
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.refund_reversal(hash)}
67
+ #Test
68
+ assert(exception.message =~ /Error validating xml data against the schema/)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,459 @@
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 TestSale < Test::Unit::TestCase
30
+ def test_simple_sale_with_card
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'id' => 'test',
34
+ 'version'=>'8.8',
35
+ 'reportGroup'=>'Planets',
36
+ 'cnpTxnId'=>'123456',
37
+ 'orderId'=>'12344',
38
+ 'amount'=>'106',
39
+ 'orderSource'=>'ecommerce',
40
+ 'card'=>{
41
+ 'type'=>'VI',
42
+ 'number' =>'4100000000000002',
43
+ 'expDate' =>'1210'
44
+ }}
45
+
46
+ response= CnpOnlineRequest.new.sale(hash)
47
+ assert_equal('000', response.saleResponse.response)
48
+ end
49
+
50
+ def test_simple_sale_with_paypal
51
+ hash = {
52
+ 'merchantId' => '101',
53
+ 'id' => 'test',
54
+ 'version'=>'8.8',
55
+ 'reportGroup'=>'Planets',
56
+ 'cnpTxnId'=>'123456',
57
+ 'orderId'=>'12344',
58
+ 'amount'=>'106',
59
+ 'orderSource'=>'ecommerce',
60
+ 'paypal'=>{
61
+ 'payerId'=>'1234',
62
+ 'token'=>'1234',
63
+ 'transactionId'=>'123456'
64
+ }}
65
+
66
+ response= CnpOnlineRequest.new.sale(hash)
67
+ assert_equal 'Valid Format', response.message
68
+ end
69
+
70
+ def test_simple_sale_with_applepay_and_secondaryAmount1
71
+ hash = {
72
+ 'merchantId' => '101',
73
+ 'id' => 'test',
74
+ 'version'=>'8.8',
75
+ 'reportGroup'=>'Planets',
76
+ 'cnpTxnId'=>'123456',
77
+ 'orderId'=>'12344',
78
+ 'amount'=>'110',
79
+ 'secondaryAmount'=>'50',
80
+ 'orderSource'=>'ecommerce',
81
+ 'applepay'=>{
82
+ 'data'=>'1234',
83
+ 'header'=>{
84
+ 'applicationData'=>'454657413164',
85
+ 'ephemeralPublicKey'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
86
+ 'publicKeyHash'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
87
+ 'transactionId'=>'1234'
88
+ },
89
+ 'signature' =>'1',
90
+ #'version'=>'1'
91
+ 'version'=>'10000'
92
+ }}
93
+ response= CnpOnlineRequest.new.sale(hash)
94
+ assert_equal('Insufficient Funds', response.saleResponse.message)
95
+ assert_equal('110', response.saleResponse.applepayResponse.transactionAmount)
96
+ end
97
+
98
+ def test_illegal_order_source
99
+ hash = {
100
+ 'merchantId' => '101',
101
+ 'id' => 'test',
102
+ 'version'=>'8.8',
103
+ 'reportGroup'=>'Planets',
104
+ 'cnpTxnId'=>'123456',
105
+ 'orderId'=>'12344',
106
+ 'amount'=>'106',
107
+ 'orderSource'=>'ecomerce',
108
+ 'card'=>{
109
+ 'type'=>'VI',
110
+ 'number' =>'4100000000000002',
111
+ 'expDate' =>'1210'
112
+ }}
113
+ #Get exceptions
114
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
115
+ #Test
116
+ assert(exception.message =~ /Error validating xml data against the schema/)
117
+ end
118
+
119
+ def test_no_report_group
120
+ hash = {
121
+ 'merchantId' => '101',
122
+ 'id' => 'test',
123
+ 'version'=>'8.8',
124
+ 'reportGroup'=>'Planets',
125
+ 'cnpTxnId'=>'123456',
126
+ 'orderId'=>'12344',
127
+ 'amount'=>'106',
128
+ 'orderSource'=>'ecommerce',
129
+ 'card'=>{
130
+ 'type'=>'VI',
131
+ 'number' =>'4100000000000000',
132
+ 'expDate' =>'1210'
133
+ }}
134
+ response= CnpOnlineRequest.new.sale(hash)
135
+ assert_equal('000', response.saleResponse.response)
136
+ end
137
+
138
+ def test_fields_out_of_order
139
+ hash = {
140
+ 'merchantId' => '101',
141
+ 'id' => 'test',
142
+ 'version'=>'8.8',
143
+ 'orderSource'=>'ecommerce',
144
+ 'cnpTxnId'=>'123456',
145
+ 'amount'=>'106',
146
+ 'card'=>{
147
+ 'type'=>'VI',
148
+ 'number' =>'4100000000000000',
149
+ 'expDate' =>'1210'
150
+ },
151
+ 'reportGroup'=>'Planets',
152
+ 'orderId'=>'12344'
153
+ }
154
+ response= CnpOnlineRequest.new.sale(hash)
155
+ assert_equal('000', response.saleResponse.response)
156
+ end
157
+
158
+ def test_invalid_field
159
+ hash = {
160
+ 'merchantId' => '101',
161
+ 'id' => 'test',
162
+ 'version'=>'8.8',
163
+ 'reportGroup'=>'Planets',
164
+ 'cnpTxnId'=>'123456',
165
+ 'orderId'=>'12344',
166
+ 'amount'=>'106',
167
+ 'orderSource'=>'ecommerce',
168
+ 'card'=>{
169
+ 'NOexistantField' => 'ShouldNotCauseError',
170
+ 'type'=>'VI',
171
+ 'number' =>'4100000000000000',
172
+ 'expDate' =>'1210'
173
+ }}
174
+ response= CnpOnlineRequest.new.sale(hash)
175
+ assert_equal('000', response.saleResponse.response)
176
+ end
177
+
178
+ def test_simple_sale_with_card1
179
+ hash = {
180
+ 'merchantId'=>'101',
181
+ 'id' => 'test',
182
+ 'version'=>'8.8',
183
+ 'reportGroup'=>'Planets',
184
+ 'cnpTxnId'=>'123456',
185
+ 'orderId'=>'12344',
186
+ 'amount'=>'106',
187
+ 'orderSource'=>'ecommerce',
188
+ 'card'=>{
189
+ 'type'=>'VI',
190
+ 'number' =>'4100000000000000',
191
+ 'expDate' =>'1210'
192
+ }}
193
+ response= CnpOnlineRequest.new.sale(hash)
194
+ assert_equal('000', response.saleResponse.response)
195
+ end
196
+
197
+ def test_no_order_id
198
+ hash = {
199
+ 'merchantId' => '101',
200
+ 'id' => 'test',
201
+ 'version'=>'8.8',
202
+ 'reportGroup'=>'Planets',
203
+ 'cnpTxnId'=>'123456',
204
+ 'amount'=>'106',
205
+ 'orderSource'=>'ecommerce',
206
+ 'card'=>{
207
+ 'type'=>'VI',
208
+ 'number' =>'4100000000000002',
209
+ 'expDate' =>'1210'
210
+ }}
211
+ #Get exceptions
212
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
213
+ #Test
214
+ assert(exception.message =~ /Error validating xml data against the schema/)
215
+ end
216
+
217
+ def test_no_amount
218
+ hash = {
219
+ 'merchantId' => '101',
220
+ 'id' => 'test',
221
+ 'version'=>'8.8',
222
+ 'reportGroup'=>'Planets',
223
+ 'cnpTxnId'=>'123456',
224
+ 'orderId'=>'12344',
225
+ 'orderSource'=>'ecommerce',
226
+ 'card'=>{
227
+ 'type'=>'VI',
228
+ 'number' =>'4100000000000002',
229
+ 'expDate' =>'1210'
230
+ }}
231
+ #Get exceptions
232
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
233
+ #Test
234
+ assert(exception.message =~ /Error validating xml data against the schema/)
235
+ end
236
+
237
+ def test_no_order_source
238
+ hash = {
239
+ 'merchantId' => '101',
240
+ 'id' => 'test',
241
+ 'version'=>'8.8',
242
+ 'reportGroup'=>'Planets',
243
+ 'cnpTxnId'=>'123456',
244
+ 'orderId'=>'12344',
245
+ 'amount'=>'106',
246
+ 'card'=>{
247
+ 'type'=>'VI',
248
+ 'number' =>'4100000000000002',
249
+ 'expDate' =>'1210'
250
+ }}
251
+ #Get exceptions
252
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
253
+ #Test
254
+ assert(exception.message =~ /Error validating xml data against the schema/)
255
+ end
256
+
257
+ def test_simple_sale_with_mpos
258
+ hash = {
259
+ 'merchantId' => '101',
260
+ 'id' => 'test',
261
+ 'version'=>'8.8',
262
+ 'reportGroup'=>'Planets',
263
+ 'cnpTxnId'=>'123456',
264
+ 'orderId'=>'12344',
265
+ 'amount'=>'106',
266
+ 'orderSource'=>'ecommerce',
267
+ 'mpos'=>
268
+ {
269
+ 'ksn'=>'ksnString',
270
+ 'formatId'=>'30',
271
+ 'encryptedTrack'=>'encryptedTrackString',
272
+ 'track1Status'=>'0',
273
+ 'track2Status'=>'0'
274
+ }
275
+ }
276
+ response= CnpOnlineRequest.new.sale(hash)
277
+ assert_equal('000', response.saleResponse.response)
278
+ end
279
+
280
+ def test_simple_sale_with_applepay_and_secondaryAmount
281
+ hash =
282
+ {
283
+ 'merchantId' => '101',
284
+ 'id' => 'test',
285
+ 'version'=>'8.8',
286
+ 'reportGroup'=>'Planets',
287
+ 'cnpTxnId'=>'123456',
288
+ 'orderId'=>'12344',
289
+ 'amount'=>'110',
290
+ 'secondaryAmount'=>'50',
291
+ 'orderSource'=>'ecommerce',
292
+ 'applepay'=>
293
+ {
294
+ 'data'=>'1234',
295
+ 'header'=>
296
+ {
297
+ 'applicationData'=>'454657413164',
298
+ 'ephemeralPublicKey'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
299
+ 'publicKeyHash'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
300
+ 'transactionId'=>'1234'
301
+ },
302
+
303
+ 'signature' =>'1',
304
+ 'version'=>'100000'
305
+ }}
306
+ response= CnpOnlineRequest.new.sale(hash)
307
+ assert_equal('Insufficient Funds', response.saleResponse.message)
308
+ assert_equal('110', response.saleResponse.applepayResponse.transactionAmount)
309
+ end
310
+
311
+ #SDK Ruby XML 10
312
+ def test_simple_sale_with_wallet1
313
+ hash =
314
+ {
315
+ 'merchantId' => '101',
316
+ 'id' => 'test',
317
+ 'version'=>'8.8',
318
+ 'reportGroup'=>'Planets',
319
+ 'cnpTxnId'=>'123456',
320
+ 'orderId'=>'12344',
321
+ 'amount'=>'106',
322
+ 'orderSource'=>'ecommerce',
323
+ 'paypal'=>
324
+ {
325
+ 'payerId'=>'1234',
326
+ 'token'=>'1234',
327
+ 'transactionId'=>'123456'
328
+ },
329
+ 'wallet'=>
330
+ {
331
+ 'walletSourceType' => 'MasterPass',
332
+ 'walletSourceTypeId' => '102'
333
+ }}
334
+ response= CnpOnlineRequest.new.sale(hash)
335
+ assert_equal 'Valid Format', response.message
336
+ end
337
+
338
+ def test_simple_sale_with_processingType
339
+ hash = {
340
+ 'merchantId' => '101',
341
+ 'id' => 'test',
342
+ 'version'=>'8.8',
343
+ 'reportGroup'=>'Planets',
344
+ 'cnpTxnId'=>'123456',
345
+ 'orderId'=>'12344',
346
+ 'amount'=>'106',
347
+ 'orderSource'=>'ecommerce',
348
+ 'processingType'=>'initialInstallment',
349
+ 'card'=>{
350
+ 'type'=>'VI',
351
+ 'number' =>'4100000000000002',
352
+ 'expDate' =>'1210'
353
+ }
354
+ }
355
+ response= CnpOnlineRequest.new.sale(hash)
356
+ assert_equal 'Valid Format', response.message
357
+ end
358
+
359
+ def test_simple_sale_with_originalNetworkTransactionId_originalTransactionAmount
360
+ hash = {
361
+ 'merchantId' => '101',
362
+ 'id' => 'test',
363
+ 'version'=>'8.8',
364
+ 'reportGroup'=>'Planets',
365
+ 'cnpTxnId'=>'123456',
366
+ 'orderId'=>'12344',
367
+ 'amount'=>'106',
368
+ 'orderSource'=>'ecommerce',
369
+ 'card'=>{
370
+ 'type'=>'VI',
371
+ 'number' =>'4100000000000002',
372
+ 'expDate' =>'1210'
373
+ },
374
+ 'originalNetworkTransactionId'=>'98765432109876543210',
375
+ 'originalTransactionAmount'=>'7001'
376
+ }
377
+ response= CnpOnlineRequest.new.sale(hash)
378
+ assert_equal 'Valid Format', response.message
379
+ assert_equal('63225578415568556365452427825', response.saleResponse.networkTransactionId)
380
+ end
381
+
382
+ def test_simple_sale_with_sepaDirectDebit
383
+ hash = {
384
+ 'merchantId' => '101',
385
+ 'id' => 'test',
386
+ 'version'=>'8.8',
387
+ 'reportGroup'=>'Planets',
388
+ 'cnpTxnId'=>'123456',
389
+ 'orderId'=>'12344',
390
+ 'amount'=>'106',
391
+ 'orderSource'=>'ecommerce',
392
+ 'sepaDirectDebit'=> {
393
+ 'mandateProvider'=>'Merchant',
394
+ 'sequenceType'=>'FirstRecurring',
395
+ 'iban'=>'123456789123456789'
396
+ }}
397
+ response= CnpOnlineRequest.new.sale(hash)
398
+ assert_equal 'Valid Format', response.message
399
+ assert_equal('http://redirect.url.vantiv.com', response.saleResponse.sepaDirectDebitResponse.redirectUrl)
400
+ assert_equal('jj2d1d372osmmt7tb8epm0a99q', response.saleResponse.sepaDirectDebitResponse.redirectToken)
401
+ assert_equal('1BADA58', response.saleResponse.sepaDirectDebitResponse.mandateReference)
402
+ end
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
457
+
458
+ end
459
+ end