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,56 @@
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 TestLoadReversal < Test::Unit::TestCase
30
+
31
+ def test_simple
32
+ hash = {
33
+ 'merchantId' => '101',
34
+ 'version'=>'8.8',
35
+ 'reportGroup'=>'Planets',
36
+ 'cnpTxnId' => '5000',
37
+ 'card'=>{
38
+ 'type'=>'GC',
39
+ 'number' =>'400000000000001',
40
+ 'expDate' =>'0150',
41
+ 'pin' => '1234',
42
+ 'cardValidationNum' => '411'
43
+ },
44
+ 'originalRefCode' => '101',
45
+ 'originalAmount' => '34561',
46
+ 'originalTxnTime' => '2017-01-24T09:00:00',
47
+ 'originalSystemTraceId' => '33',
48
+ 'originalSequenceNumber' => '111111',
49
+ }
50
+
51
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>5000<\/cnpTxnId><card><type>GC<\/type><number>400000000000001<\/number><expDate>0150<\/expDate><cardValidationNum>411<\/cardValidationNum><pin>1234<\/pin><\/card>.*/m), is_a(Hash))
52
+ CnpOnlineRequest.new.deposit_reversal(hash)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,139 @@
1
+ =begin
2
+ Copyright (c) 2017 Vantiv eCommerce
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20
+ OTHER DEALINGS IN THE SOFTWARE.
21
+ =end
22
+ require File.expand_path("../../../lib/CnpOnline",__FILE__)
23
+ require 'test/unit'
24
+ require 'mocha/setup'
25
+ require 'fileutils'
26
+
27
+ CNP_SDK_TEST_FOLDER = '/cnp-sdk-for-ruby-test'
28
+
29
+ module CnpOnline
30
+
31
+ class TestPgpCnpRequest < Test::Unit::TestCase
32
+
33
+ def setup
34
+ dir = '/tmp' + CNP_SDK_TEST_FOLDER
35
+ FileUtils.rm_rf dir
36
+ Dir.mkdir dir
37
+
38
+ end
39
+
40
+ def test_noPublicKey
41
+ config_dir = ENV['CNP_CONFIG_DIR']
42
+ ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
43
+ dir = '/tmp'
44
+
45
+ test = ''
46
+ request = CnpRequest.new()
47
+ ENV['CNP_CONFIG_DIR'] = config_dir
48
+ request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
49
+ request.finish_request
50
+ request.send_to_cnp(dir + CNP_SDK_TEST_FOLDER, {'vantivPublicKeyID' => ''})
51
+
52
+ rescue RuntimeError => e
53
+ test = e.message
54
+
55
+ clear_outbound
56
+ assert_equal "The public key to encrypt batch file requests is missing from the config", test
57
+ end
58
+
59
+ def test_incorrectPublicKey
60
+ config_dir = ENV['CNP_CONFIG_DIR']
61
+ ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
62
+ dir = '/tmp'
63
+
64
+ test = ''
65
+ request = CnpRequest.new()
66
+ ENV['CNP_CONFIG_DIR'] = config_dir
67
+ request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
68
+ request.finish_request
69
+ request.send_to_cnp(dir + CNP_SDK_TEST_FOLDER, {'vantivPublicKeyID' => '7E25EB2X'})
70
+
71
+
72
+ rescue ArgumentError => e
73
+ test = e.message
74
+ clear_outbound
75
+ assert_match(/Please check if you have entered correct vantivePublicKeyID to config and that vantiv's public key is added to your gpg keyring and is trusted/, test)
76
+ end
77
+
78
+ def test_noPassphrase
79
+ config_dir = ENV['CNP_CONFIG_DIR']
80
+ ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
81
+ dir = '/tmp'
82
+
83
+ test = ''
84
+ request = CnpRequest.new()
85
+ ENV['CNP_CONFIG_DIR'] = config_dir
86
+ request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
87
+ request.finish_request
88
+ request.send_to_cnp
89
+ request.get_responses_from_server({'passphrase' => ''})
90
+
91
+ rescue RuntimeError => e
92
+ test = e.message
93
+ clear_outbound
94
+ assert_equal "The passphrase to decrypt the batch file responses is missing from the config", test
95
+
96
+ end
97
+
98
+ def test_incorrectPassphrase
99
+ config_dir = ENV['CNP_CONFIG_DIR']
100
+ ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
101
+ dir = '/tmp'
102
+
103
+ test = ''
104
+ request = CnpRequest.new()
105
+ ENV['CNP_CONFIG_DIR'] = config_dir
106
+ request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
107
+ request.finish_request
108
+ request.send_to_cnp
109
+ request.get_responses_from_server({'passphrase' => 'gameover:('})
110
+
111
+ rescue ArgumentError => e
112
+ test = e.message
113
+ clear_outbound
114
+ assert_match(/Please check if you have entered correct passphrase to config and that your merchant private key is added to your gpg keyring and is trusted/, test)
115
+ end
116
+
117
+
118
+ def clear_outbound
119
+ config_dir = ENV['CNP_CONFIG_DIR']
120
+ ENV['CNP_CONFIG_DIR'] = '/tmp/pgp_ruby'
121
+ options = Configuration.new.config
122
+ sftp_username = options['sftp_username']
123
+ sftp_password = options['sftp_password']
124
+ sftp_url = options['sftp_url']
125
+ ENV['CNP_CONFIG_DIR'] = config_dir
126
+
127
+ Net::SFTP.start(sftp_url, sftp_username, :password => sftp_password) do |sftp|
128
+ handle = sftp.opendir!('/outbound/')
129
+ files_on_srv = sftp.readdir!(handle)
130
+ files_on_srv.each {|file|
131
+ if (file.name =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{ENCRYPTED_FILE_SUFFIX}.asc\z/) != nil
132
+ sftp.remove('/outbound/' + file.name)
133
+ end
134
+ }
135
+ end
136
+ end
137
+
138
+ end
139
+ end
@@ -0,0 +1,106 @@
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
+ # TESTING THE QUERY TRANSACTION FEATURE
32
+
33
+
34
+ module CnpOnline
35
+ =begin
36
+ Definition: Class Definition for the Testing Class TestQueryTransaction
37
+ Created on: 01-29-2016
38
+ Reason: To test the incorporation new features developed in Ruby SDK as per XML 10.1 schema.
39
+ =end
40
+
41
+ class TestQueryTransaction < Test::Unit::TestCase
42
+
43
+ =begin
44
+ Name - test_queryTransaction
45
+ Description - To validate request by providing valid query transaction fields
46
+ Expected Response - Success
47
+ =end
48
+ def test_queryTransaction
49
+ hash =
50
+ {
51
+ 'merchantId' => '101',
52
+ 'id' => 'test',
53
+ 'version'=>'10.0',
54
+ 'reportGroup'=>'Some RG',
55
+ 'customerId' => '038945',
56
+ 'origId' => '834262',
57
+ 'origActionType' => 'A',
58
+ 'transactionId'=>'123456',
59
+ 'orderId'=>'65347567',
60
+ #'origAccountNumber' => '4000000000000001'
61
+ }
62
+
63
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*?<cnpOnlineRequest.*?<queryTransaction.*?<origId>834262<\/origId><origActionType>A<\/origActionType>.*?<\/queryTransaction>.*?/m), is_a(Hash))
64
+ CnpOnlineRequest.new.query_Transaction(hash)
65
+ end
66
+
67
+
68
+ =begin
69
+ Name - test_queryTransaction_no_optional_fields
70
+ Description - To validate request by providing valid query transaction without providing optional fields
71
+ Expected Response - Success
72
+ =end
73
+ def test_queryTransaction_no_optional_fields
74
+ hash =
75
+ {
76
+ 'merchantId' => '101',
77
+ 'id' => 'test',
78
+ 'version'=>'10.0',
79
+ 'reportGroup'=>'Some RG',
80
+ 'customerId' => '038945',
81
+ 'origId' => '834262',
82
+ 'origActionType' => 'A',
83
+ 'transactionId'=>'123456'
84
+ }
85
+
86
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*?<cnpOnlineRequest.*?<queryTransaction.*?<origId>834262<\/origId><origActionType>A<\/origActionType>.*?<\/queryTransaction>.*?/m), is_a(Hash))
87
+ CnpOnlineRequest.new.query_Transaction(hash)
88
+ end
89
+
90
+ def test_queryTransaction_no_origId1
91
+ hash =
92
+ {
93
+ 'merchantId' => '101',
94
+ 'id' => 'test',
95
+ 'version'=>'10.0',
96
+ 'reportGroup'=>'Some RG',
97
+ 'customerId' => '038945',
98
+ 'origActionType' => 'A',
99
+ 'transactionId'=>'123456'
100
+ }
101
+
102
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*?<cnpOnlineRequest.*?<queryTransaction.*?<origActionType>A<\/origActionType>.*?<\/queryTransaction>.*?/m), is_a(Hash))
103
+ CnpOnlineRequest.new.query_Transaction(hash)
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,56 @@
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 TestRefundReversal < Test::Unit::TestCase
30
+
31
+ def test_simple
32
+ hash = {
33
+ 'merchantId' => '101',
34
+ 'version'=>'8.8',
35
+ 'reportGroup'=>'Planets',
36
+ 'cnpTxnId' => '5000',
37
+ 'card'=>{
38
+ 'type'=>'GC',
39
+ 'number' =>'400000000000001',
40
+ 'expDate' =>'0150',
41
+ 'pin' => '1234',
42
+ 'cardValidationNum' => '411'
43
+ },
44
+ 'originalRefCode' => '101',
45
+ 'originalAmount' => '34561',
46
+ 'originalTxnTime' => '2017-01-24T09:00:00',
47
+ 'originalSystemTraceId' => '33',
48
+ 'originalSequenceNumber' => '111111',
49
+ }
50
+
51
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>5000<\/cnpTxnId><card><type>GC<\/type><number>400000000000001<\/number><expDate>0150<\/expDate><cardValidationNum>411<\/cardValidationNum><pin>1234<\/pin><\/card>.*/m), is_a(Hash))
52
+ CnpOnlineRequest.new.deposit_reversal(hash)
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,551 @@
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 TestSale < Test::Unit::TestCase
31
+ def test_both_choices_fraud_check_and_card_holder
32
+ hash = {
33
+ 'merchantId' => '101',
34
+ 'version'=>'8.8',
35
+ 'reportGroup'=>'Planets',
36
+ 'cnpTxnId'=>'123456',
37
+ 'orderId'=>'12344',
38
+ 'amount'=>'106',
39
+ 'orderSource'=>'ecommerce',
40
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
41
+ 'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
42
+ 'card'=>{
43
+ 'type'=>'VI',
44
+ 'number' =>'4100000000000002',
45
+ 'expDate' =>'1210'
46
+ }}
47
+
48
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
49
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
50
+ end
51
+
52
+ def test_success_applepay
53
+ hash = {
54
+ 'merchantId' => '101',
55
+ 'version'=>'8.8',
56
+ 'reportGroup'=>'Planets',
57
+ 'cnpTxnId'=>'123456',
58
+ 'orderId'=>'12344',
59
+ 'amount'=>'106',
60
+ 'orderSource'=>'ecommerce',
61
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
62
+ 'applepay'=>{
63
+ 'data'=>'user',
64
+ 'header'=>{
65
+ 'applicationData'=>'454657413164',
66
+ 'ephemeralPublicKey'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
67
+ 'publicKeyHash'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
68
+ 'transactionId'=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
69
+ },
70
+ 'signature' =>'sign',
71
+ # 'version' =>'1'
72
+ 'version' =>'10000'
73
+ }
74
+ }
75
+
76
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*?<cnpOnlineRequest.*?<sale.*?<applepay>.*?<data>user<\/data>.*?<\/applepay>.*?<\/sale>.*?/m), is_a(Hash))
77
+ CnpOnlineRequest.new.sale(hash)
78
+ end
79
+
80
+ # for test the choice functionality
81
+ def test_success_card
82
+ hash = {
83
+ 'merchantId' => '101',
84
+ 'version'=>'8.8',
85
+ 'reportGroup'=>'Planets',
86
+ 'cnpTxnId'=>'123456',
87
+ 'orderId'=>'12344',
88
+ 'amount'=>'106',
89
+ 'orderSource'=>'ecommerce',
90
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'}, #for test
91
+ 'card'=>{
92
+ 'type'=>'VI',
93
+ 'number' =>'4100000000000002',
94
+ 'expDate' =>'1210'
95
+ }
96
+ }
97
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*?<cnpOnlineRequest.*?<sale.*?<card>.*?<type>VI<\/type>.*?<\/card>.*?<\/sale>.*?/m), is_a(Hash))
98
+ CnpOnlineRequest.new.sale(hash)
99
+ end
100
+
101
+ def test_both_choices_card_and_paypal
102
+ hash = {
103
+ 'merchantId' => '101',
104
+ 'version'=>'8.8',
105
+ 'reportGroup'=>'Planets',
106
+ 'cnpTxnId'=>'123456',
107
+ 'orderId'=>'12344',
108
+ 'amount'=>'106',
109
+ 'orderSource'=>'ecommerce',
110
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
111
+ 'card'=>{
112
+ 'type'=>'VI',
113
+ 'number' =>'4100000000000002',
114
+ 'expDate' =>'1210'
115
+ },
116
+ 'paypal'=>{
117
+ 'payerId'=>'1234',
118
+ 'token'=>'1234',
119
+ 'transactionId'=>'123456'
120
+ }}
121
+
122
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
123
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
124
+ end
125
+
126
+ def test_both_choices_card_and_token
127
+ hash = {
128
+ 'merchantId' => '101',
129
+ 'version'=>'8.8',
130
+ 'reportGroup'=>'Planets',
131
+ 'cnpTxnId'=>'123456',
132
+ 'orderId'=>'12344',
133
+ 'amount'=>'106',
134
+ 'orderSource'=>'ecommerce',
135
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
136
+ 'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
137
+ 'card'=>{
138
+ 'type'=>'VI',
139
+ 'number' =>'4100000000000002',
140
+ 'expDate' =>'1210'
141
+ },
142
+ 'token'=> {
143
+ 'cnpToken'=>'1234567890123',
144
+ 'expDate'=>'1210',
145
+ 'cardValidationNum'=>'555',
146
+ 'type'=>'VI'
147
+ }}
148
+
149
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
150
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
151
+ end
152
+
153
+ def test_both_choices_card_and_paypage
154
+ hash = {
155
+ 'merchantId' => '101',
156
+ 'version'=>'8.8',
157
+ 'reportGroup'=>'Planets',
158
+ 'cnpTxnId'=>'123456',
159
+ 'orderId'=>'12344',
160
+ 'amount'=>'106',
161
+ 'orderSource'=>'ecommerce',
162
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
163
+ 'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
164
+ 'card'=>{
165
+ 'type'=>'VI',
166
+ 'number' =>'4100000000000002',
167
+ 'expDate' =>'1210'
168
+ },
169
+ 'paypage'=> {
170
+ 'paypageRegistrationId'=>'1234',
171
+ 'expDate'=>'1210',
172
+ 'cardValidationNum'=>'555',
173
+ 'type'=>'VI'
174
+ }}
175
+
176
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
177
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
178
+ end
179
+
180
+ def test_three_choices_card_and_paypage_and_paypal
181
+ hash = {
182
+ 'merchantId' => '101',
183
+ 'version'=>'8.8',
184
+ 'reportGroup'=>'Planets',
185
+ 'cnpTxnId'=>'123456',
186
+ 'orderId'=>'12344',
187
+ 'amount'=>'106',
188
+ 'orderSource'=>'ecommerce',
189
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
190
+ 'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
191
+ 'card'=>{
192
+ 'type'=>'VI',
193
+ 'number' =>'4100000000000002',
194
+ 'expDate' =>'1210'
195
+ },
196
+ 'paypage'=> {
197
+ 'paypageRegistrationId'=>'1234',
198
+ 'expDate'=>'1210',
199
+ 'cardValidationNum'=>'555',
200
+ 'type'=>'VI'},
201
+ 'paypal'=>{
202
+ 'payerId'=>'1234',
203
+ 'token'=>'1234',
204
+ 'transactionId'=>'123456'
205
+ }}
206
+
207
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
208
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
209
+ end
210
+
211
+ def test_all_choices_card_and_paypage_and_paypal_and_token
212
+ hash = {
213
+ 'merchantId' => '101',
214
+ 'version'=>'8.8',
215
+ 'reportGroup'=>'Planets',
216
+ 'cnpTxnId'=>'123456',
217
+ 'orderId'=>'12344',
218
+ 'amount'=>'106',
219
+ 'orderSource'=>'ecommerce',
220
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
221
+ 'cardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
222
+ 'card'=>{
223
+ 'type'=>'VI',
224
+ 'number' =>'4100000000000002',
225
+ 'expDate' =>'1210'
226
+ },
227
+ 'paypage'=> {
228
+ 'paypageRegistrationId'=>'1234',
229
+ 'expDate'=>'1210',
230
+ 'cardValidationNum'=>'555',
231
+ 'type'=>'VI'},
232
+ 'paypal'=>{
233
+ 'payerId'=>'1234',
234
+ 'token'=>'1234',
235
+ 'transactionId'=>'123456'},
236
+ 'token'=> {
237
+ 'cnpToken'=>'1234567890123',
238
+ 'expDate'=>'1210',
239
+ 'cardValidationNum'=>'555',
240
+ 'type'=>'VI'
241
+ }}
242
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
243
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
244
+ end
245
+
246
+ def test_merchant_data_sale
247
+ hash = {
248
+ 'merchantId' => '101',
249
+ 'version'=>'8.12',
250
+ 'orderId'=>'1',
251
+ 'amount'=>'0',
252
+ 'orderSource'=>'ecommerce',
253
+ 'reportGroup'=>'Planets',
254
+ 'merchantData'=> {
255
+ 'affiliate'=>'bar'
256
+ }
257
+ }
258
+
259
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<merchantData>.*?<affiliate>bar<\/affiliate>.*?<\/merchantData>.*/m), is_a(Hash))
260
+ CnpOnlineRequest.new.sale(hash)
261
+ end
262
+
263
+ def test_invalid_embedded_field_values
264
+ #becasue there are sub fields under fraud check that are not specified
265
+ hash = {
266
+ 'merchantId' => '101',
267
+ 'version'=>'8.8',
268
+ 'reportGroup'=>'Planets',
269
+ 'cnpTxnId'=>'123456',
270
+ 'orderId'=>'12344',
271
+ 'amount'=>'106',
272
+ 'orderSource'=>'ecommerce',
273
+ 'fraudCheck'=>'one',
274
+ 'cardholderAuthentication'=>'two',
275
+ 'card'=>{
276
+ 'type'=>'VI',
277
+ 'number' =>'4100000000000000',
278
+ }}
279
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
280
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
281
+ end
282
+
283
+ def test_fraud_filter_override
284
+ hash = {
285
+ 'merchantId' => '101',
286
+ 'version'=>'8.12',
287
+ 'orderId'=>'1',
288
+ 'amount'=>'0',
289
+ 'orderSource'=>'ecommerce',
290
+ 'reportGroup'=>'Planets',
291
+ 'fraudFilterOverride'=> 'false'
292
+ }
293
+
294
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<sale.*?<fraudFilterOverride>false<\/fraudFilterOverride>.*?<\/sale>.*/m), is_a(Hash))
295
+ CnpOnlineRequest.new.sale(hash)
296
+ end
297
+
298
+ def test_illegal_card_type
299
+ hash = {
300
+ 'merchantId' => '101',
301
+ 'version'=>'8.8',
302
+ 'reportGroup'=>'Planets',
303
+ 'cnpTxnId'=>'123456',
304
+ 'orderId'=>'12344',
305
+ 'amount'=>'106',
306
+ 'orderSource'=>'ecommerce',
307
+ 'card'=>{
308
+ 'type'=>'NO',
309
+ 'number' =>'4100000000000002',
310
+ 'expDate' =>'1210'
311
+ }}
312
+ exception = assert_raise(RuntimeError){CnpOnlineRequest.new.sale(hash)}
313
+ assert_match /If card type is specified, it must be in /, exception.message
314
+ end
315
+
316
+ def test_logged_in_user
317
+ hash = {
318
+ 'loggedInUser' => 'gdake',
319
+ 'merchantSdk' => 'Ruby;8.14.0',
320
+ 'merchantId' => '101',
321
+ 'version'=>'8.8',
322
+ 'reportGroup'=>'Planets',
323
+ 'cnpTxnId'=>'123456',
324
+ 'orderId'=>'12344',
325
+ 'amount'=>'106',
326
+ 'orderSource'=>'ecommerce',
327
+ 'card'=>{
328
+ 'type'=>'VI',
329
+ 'number' =>'4100000000000002',
330
+ 'expDate' =>'1210'
331
+ }}
332
+
333
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
334
+ CnpOnlineRequest.new.sale(hash)
335
+ end
336
+
337
+ def test_surcharge_amount
338
+ hash = {
339
+ 'orderId' => '12344',
340
+ 'amount' => '2',
341
+ 'surchargeAmount' => '1',
342
+ 'orderSource' => 'ecommerce',
343
+ 'reportGroup' => 'Planets'
344
+ }
345
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
346
+ CnpOnlineRequest.new.sale(hash)
347
+ end
348
+
349
+ def test_secondary_amount
350
+ hash = {
351
+ 'orderId' => '12344',
352
+ 'amount' => '2',
353
+ 'secondaryAmount' => '1',
354
+ 'orderSource' => 'ecommerce',
355
+ 'reportGroup' => 'Planets'
356
+ }
357
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
358
+ CnpOnlineRequest.new.sale(hash)
359
+ end
360
+
361
+ def test_surcharge_amount_optional
362
+ hash = {
363
+ 'orderId' => '12344',
364
+ 'amount' => '2',
365
+ 'orderSource' => 'ecommerce',
366
+ 'reportGroup' => 'Planets'
367
+ }
368
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
369
+ CnpOnlineRequest.new.sale(hash)
370
+ end
371
+
372
+ def test_recurringRequest
373
+ hash = {
374
+ 'card'=>{
375
+ 'type'=>'VI',
376
+ 'number'=>'4100000000000001',
377
+ 'expDate'=>'1213',
378
+ },
379
+ 'orderId'=>'12344',
380
+ 'amount'=>'2',
381
+ 'orderSource'=>'ecommerce',
382
+ 'fraudFilterOverride'=>'true',
383
+ 'recurringRequest'=>{
384
+ 'subscription'=>{
385
+ 'planCode'=>'abc123',
386
+ 'numberOfPayments'=>'12'
387
+ }
388
+ }
389
+ }
390
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><recurringRequest><subscription><planCode>abc123<\/planCode><numberOfPayments>12<\/numberOfPayments><\/subscription><\/recurringRequest>.*/m), is_a(Hash))
391
+ CnpOnlineRequest.new.sale(hash)
392
+ end
393
+
394
+ def test_recurringRequest_optional
395
+ hash = {
396
+ 'card'=>{
397
+ 'type'=>'VI',
398
+ 'number'=>'4100000000000001',
399
+ 'expDate'=>'1213',
400
+ },
401
+ 'orderId'=>'12344',
402
+ 'amount'=>'2',
403
+ 'orderSource'=>'ecommerce',
404
+ 'fraudFilterOverride'=>'true',
405
+ }
406
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><\/sale>.*/m), is_a(Hash))
407
+ CnpOnlineRequest.new.sale(hash)
408
+ end
409
+
410
+ def test_cnpInternalRecurringRequest
411
+ hash = {
412
+ 'card'=>{
413
+ 'type'=>'VI',
414
+ 'number'=>'4100000000000001',
415
+ 'expDate'=>'1213',
416
+ },
417
+ 'orderId'=>'12344',
418
+ 'amount'=>'2',
419
+ 'orderSource'=>'ecommerce',
420
+ 'fraudFilterOverride'=>'true',
421
+ 'cnpInternalRecurringRequest'=>{
422
+ 'subscriptionId'=>'1234567890123456789',
423
+ 'recurringTxnId'=>'1234567890123456789',
424
+ 'finalPayment'=>'false'
425
+ },
426
+ }
427
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><cnpInternalRecurringRequest><subscriptionId>1234567890123456789<\/subscriptionId><recurringTxnId>1234567890123456789<\/recurringTxnId><finalPayment>false<\/finalPayment><\/cnpInternalRecurringRequest>.*/m), is_a(Hash))
428
+ CnpOnlineRequest.new.sale(hash)
429
+ end
430
+
431
+ def test_cnpInternalRecurringRequest_optional
432
+ hash = {
433
+ 'card'=>{
434
+ 'type'=>'VI',
435
+ 'number'=>'4100000000000001',
436
+ 'expDate'=>'1213',
437
+ },
438
+ 'orderId'=>'12344',
439
+ 'amount'=>'2',
440
+ 'orderSource'=>'ecommerce',
441
+ 'fraudFilterOverride'=>'true',
442
+ }
443
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<fraudFilterOverride>true<\/fraudFilterOverride><\/sale>.*/m), is_a(Hash))
444
+ CnpOnlineRequest.new.sale(hash)
445
+ end
446
+
447
+ def test_advanced_fraud_check
448
+ hash = {
449
+ 'orderId' => '12344',
450
+ 'amount' => '2',
451
+ 'orderSource' => 'ecommerce',
452
+ 'card' => {
453
+ 'number' => '4141000000000000',
454
+ 'expDate' => '1210',
455
+ 'type' => 'GC'
456
+ } ,
457
+ 'advancedFraudChecks' => {'threatMetrixSessionId'=>'1234'}
458
+ }
459
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<advancedFraudChecks><threatMetrixSessionId>1234<\/threatMetrixSessionId><\/advancedFraudChecks>.*/m), is_a(Hash))
460
+ CnpOnlineRequest.new.sale(hash)
461
+ end
462
+
463
+ def test_processingType
464
+ hash = {
465
+ 'merchantId' => '101',
466
+ 'version'=>'8.8',
467
+ 'reportGroup'=>'Planets',
468
+ 'cnpTxnId'=>'123456',
469
+ 'orderId'=>'12344',
470
+ 'amount'=>'106',
471
+ 'orderSource'=>'ecommerce',
472
+ 'card'=>
473
+ {
474
+ 'type'=>'MC',
475
+ 'number' =>'5400000000000000',
476
+ 'expDate' =>'1210'
477
+ },
478
+ 'processingType'=>'initialInstallment'
479
+ }
480
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<processingType>initialInstallment<\/processingType>.*/m), is_a(Hash))
481
+ CnpOnlineRequest.new.sale(hash)
482
+ end
483
+
484
+ def test_originalNetworkTransactionId_originalTransactionAmount_pin
485
+ hash = {
486
+ 'merchantId' => '101',
487
+ 'version'=>'8.8',
488
+ 'reportGroup'=>'Planets',
489
+ 'cnpTxnId'=>'123456',
490
+ 'orderId'=>'12344',
491
+ 'amount'=>'106',
492
+ 'orderSource'=>'ecommerce',
493
+ 'card'=>
494
+ {
495
+ 'type'=>'VI',
496
+ 'number' =>'4100700000000000',
497
+ 'expDate' =>'1210',
498
+ 'pin'=>'1111'
499
+ },
500
+ 'originalNetworkTransactionId'=>'98765432109876543210',
501
+ 'originalTransactionAmount'=>'7001'
502
+ }
503
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<originalNetworkTransactionId>98765432109876543210<\/originalNetworkTransactionId><originalTransactionAmount>7001<\/originalTransactionAmount>.*/m), is_a(Hash))
504
+ CnpOnlineRequest.new.sale(hash)
505
+ end
506
+
507
+ def test_wallet
508
+ hash = {
509
+ 'merchantId' => '101',
510
+ 'version'=>'8.8',
511
+ 'reportGroup'=>'Planets',
512
+ 'cnpTxnId'=>'123456',
513
+ 'orderId'=>'12344',
514
+ 'amount'=>'106',
515
+ 'orderSource'=>'ecommerce',
516
+ 'card'=>
517
+ {
518
+ 'type'=>'VI',
519
+ 'number' =>'4100700000000000',
520
+ 'expDate' =>'1210',
521
+ },
522
+ 'wallet'=>{
523
+ 'walletSourceType'=>'VisaCheckout',
524
+ 'walletSourceTypeId'=>'VCIND'
525
+ }
526
+ }
527
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<wallet><walletSourceType>VisaCheckout<\/walletSourceType><walletSourceTypeId>VCIND<\/walletSourceTypeId><\/wallet>.*/m), is_a(Hash))
528
+ CnpOnlineRequest.new.sale(hash)
529
+ end
530
+
531
+
532
+ def test_sepaDirectDebit
533
+ hash = {
534
+ 'merchantId' => '101',
535
+ 'version'=>'8.8',
536
+ 'reportGroup'=>'Planets',
537
+ 'cnpTxnId'=>'123456',
538
+ 'orderId'=>'12344',
539
+ 'amount'=>'106',
540
+ 'orderSource'=>'ecommerce',
541
+ 'sepaDirectDebit'=> {
542
+ 'mandateProvider'=>'Merchant',
543
+ 'sequenceType'=>'OneTime',
544
+ 'iban'=>'123456789123456789',
545
+ }}
546
+ CnpXmlMapper.expects(:request).with(regexp_matches(/.*<sepaDirectDebit><mandateProvider>Merchant<\/mandateProvider><sequenceType>OneTime<\/sequenceType><iban>123456789123456789<\/iban><\/sepaDirectDebit>.*/m), is_a(Hash))
547
+ CnpOnlineRequest.new.sale(hash)
548
+ end
549
+
550
+ end
551
+ end