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,137 @@
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 TestToken < Test::Unit::TestCase
30
+ def test_simple_token
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'version'=>'8.8',
34
+ 'id'=>'test',
35
+ 'reportGroup'=>'Planets',
36
+ 'orderId'=>'12344',
37
+ 'accountNumber'=>'1233456789103801'
38
+ }
39
+ response= CnpOnlineRequest.new.register_token_request(hash)
40
+ assert_equal('Valid Format', response.message)
41
+ end
42
+
43
+ def test_simple_token_with_paypage
44
+ hash = {
45
+ 'merchantId' => '101',
46
+ 'version'=>'8.8',
47
+ 'id'=>'test',
48
+ 'reportGroup'=>'Planets',
49
+ 'orderId'=>'12344',
50
+ 'paypageRegistrationId'=>'QU1pTFZnV2NGQWZrZzRKeTNVR0lzejB1K2Q5VDdWMTVqb2J5WFJ2Snh4U0U4eTBxaFg2cEVWaDBWSlhtMVZTTw=='
51
+ }
52
+ response= CnpOnlineRequest.new.register_token_request(hash)
53
+ assert_equal('Valid Format', response.message)
54
+ assert_equal('1111222233334444', response.registerTokenResponse.cnpToken)
55
+ end
56
+
57
+ def test_simple_token_with_applepay
58
+ hash = {
59
+ 'merchantId' => '101',
60
+ 'version'=>'8.8',
61
+ 'id'=>'test',
62
+ 'reportGroup'=>'Planets',
63
+ 'orderId'=>'12344',
64
+ 'applepay'=>{
65
+ 'data'=>'1234',
66
+ 'header'=>{
67
+ 'applicationData'=>'454657413164',
68
+ 'ephemeralPublicKey'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
69
+ 'publicKeyHash'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
70
+ 'transactionId'=>'1234'
71
+ },
72
+ 'signature' =>'1',
73
+ 'version'=>'10000'
74
+ }
75
+ }
76
+ response= CnpOnlineRequest.new.register_token_request(hash)
77
+ assert_equal('Valid Format', response.message)
78
+ assert_equal('0', response.registerTokenResponse.applepayResponse.transactionAmount)
79
+ end
80
+
81
+ def test_simple_token_echeck
82
+ hash = {
83
+ 'reportGroup'=>'Planets',
84
+ 'merchantId' => '101',
85
+ 'id'=>'test',
86
+ 'version'=>'8.8',
87
+ 'orderId'=>'12344',
88
+ 'echeckForToken'=>{'accNum'=>'12344565','routingNum'=>'123476545'}
89
+ }
90
+ response= CnpOnlineRequest.new.register_token_request(hash)
91
+ assert_equal('Valid Format', response.message)
92
+ end
93
+
94
+ def test_fields_out_of_order
95
+ hash = {
96
+ 'merchantId' => '101',
97
+ 'version'=>'8.8',
98
+ 'id'=>'test',
99
+ 'orderId'=>'12344',
100
+ 'accountNumber'=>'1233456789103801',
101
+ 'reportGroup'=>'Planets',
102
+ }
103
+ response= CnpOnlineRequest.new.register_token_request(hash)
104
+ assert_equal('Valid Format', response.message)
105
+ end
106
+
107
+ def test_invalid_field
108
+ hash = {
109
+ 'merchantId' => '101',
110
+ 'version'=>'8.8',
111
+ 'id'=>'test',
112
+ 'NOSUCHFIELD'=>'none',
113
+ 'orderId'=>'12344',
114
+ 'accountNumber'=>'1233456789103801',
115
+ 'reportGroup'=>'Planets',
116
+ }
117
+ response= CnpOnlineRequest.new.register_token_request(hash)
118
+ assert_equal('Valid Format', response.message)
119
+ end
120
+
121
+ def test_simple_token_with_androidpay
122
+ hash = {
123
+ 'merchantId' => '101',
124
+ 'version'=>'8.8',
125
+ 'reportGroup'=>'Planets',
126
+ 'id'=>'test',
127
+ 'orderId'=>'androidpay',
128
+ 'accountNumber'=>'1233456789103801'
129
+ }
130
+ response= CnpOnlineRequest.new.register_token_request(hash)
131
+ assert_equal('Account number was successfully registered', response.registerTokenResponse.message)
132
+ assert_equal('01', response.registerTokenResponse.androidpayResponse.expMonth)
133
+ assert_equal('2050', response.registerTokenResponse.androidpayResponse.expYear)
134
+ assert_equal('aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ0K', response.registerTokenResponse.androidpayResponse.cryptogram)
135
+ end
136
+ end
137
+ 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
@@ -0,0 +1,108 @@
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 Unload Transaction
29
+ module CnpOnline
30
+ class TestUnload < Test::Unit::TestCase
31
+
32
+ def test_simple_happy
33
+ hash = {
34
+ 'merchantId' => '101',
35
+ 'version'=>'8.8',
36
+ 'id'=>'test',
37
+ 'reportGroup'=>'Planets',
38
+ 'orderId' =>'1001',
39
+ 'amount' =>'500',
40
+ 'orderSource' =>'ecommerce',
41
+ 'card'=>{
42
+ 'type'=>'GC',
43
+ 'number' =>'4100000000000001',
44
+ 'expDate' =>'1210'
45
+ }
46
+ }
47
+
48
+ response= CnpOnlineRequest.new.unload_request(hash)
49
+ assert_equal('Valid Format', response.message)
50
+ end
51
+
52
+ def test_simple_out_of_order
53
+ hash = {
54
+ 'merchantId' => '101',
55
+ 'version'=>'8.8',
56
+ 'id'=>'test',
57
+ 'reportGroup'=>'Planets',
58
+ 'amount' =>'500',
59
+ 'orderId' =>'1001',
60
+ 'orderSource' =>'ecommerce',
61
+ 'card'=>{
62
+ 'type'=>'GC',
63
+ 'number' =>'4100000000000001',
64
+ 'expDate' =>'1210'
65
+ }
66
+ }
67
+
68
+ response= CnpOnlineRequest.new.unload_request(hash)
69
+ assert_equal('Valid Format', response.message)
70
+ end
71
+
72
+ def test_simple_error
73
+ hash = {
74
+ 'merchantId' => '101',
75
+ 'version'=>'8.8',
76
+ 'reportGroup'=>'Planets',
77
+ 'amount' =>'500',
78
+ }
79
+
80
+ #Get exceptions
81
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.unload_request(hash)}
82
+ #Test
83
+ assert(exception.message =~ /Error validating xml data against the schema/)
84
+ end
85
+
86
+ def test_GiftCardCardType_NotPresent
87
+ hash = {
88
+ 'merchantId' => '101',
89
+ 'version'=>'8.8',
90
+ 'id' =>'test',
91
+ 'reportGroup'=>'Planets',
92
+ 'amount' =>'500',
93
+ 'orderId' =>'1001',
94
+ 'orderSource' =>'ecommerce',
95
+ 'card'=>{
96
+ 'type'=>'VI',
97
+ 'number' =>'4100000000000001',
98
+ 'expDate' =>'1210'
99
+ }
100
+ }
101
+
102
+ #Get exceptions
103
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.unload_request(hash)}
104
+ #Test
105
+ assert(exception.message =~ /Error validating xml data against the schema/)
106
+ end
107
+ end
108
+ 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 unloadReversal Transaction
29
+ module CnpOnline
30
+ class TestUnloadReversal < 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.unload_reversal(hash)}
67
+ #Test
68
+ assert(exception.message =~ /Error validating xml data against the schema/)
69
+ end
70
+ end
71
+ end