CnpOnline 11.4.0 → 12.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -164
- data/CHANGELOG~ +0 -0
- data/CONTRIBUTORS +0 -2
- data/DESCRIPTION +1 -1
- data/LICENSE +0 -0
- data/README.md +13 -15
- data/Rakefile +3 -2
- data/Rakefile~ +4 -3
- data/SETUP.md +13 -10
- data/bin/Setup.rb +26 -22
- data/bin/sample_batch_driver.rb +15 -15
- data/bin/sample_driver.rb +5 -5
- data/lib/{LitleBatchRequest.rb → CnpBatchRequest.rb} +68 -66
- data/lib/{LitleListeners.rb → CnpListeners.rb} +48 -40
- data/lib/{LitleOnline.rb → CnpOnline.rb} +8 -7
- data/lib/{LitleOnlineRequest.rb → CnpOnlineRequest.rb} +53 -53
- data/lib/{LitleRequest.rb → CnpRequest.rb} +186 -192
- data/lib/{LitleTransaction.rb → CnpTransaction.rb} +53 -52
- data/lib/{LitleXmlMapper.rb → CnpXmlMapper.rb} +7 -7
- data/lib/Communications.rb +8 -7
- data/lib/Configuration.rb +7 -6
- data/lib/EnvironmentVariables.rb +2 -2
- data/lib/XMLFields.rb +98 -108
- data/lib/cacert.pem +0 -0
- data/samples/Auth/CnpAuthReversalTransaction.rb +15 -0
- data/samples/Auth/{LitleAuthorizationTransaction.rb → CnpAuthorizationTransaction.rb} +4 -4
- data/samples/Auth/{LitlePaymentFullLifeCycle.rb → CnpPaymentFullLifeCycle.rb} +11 -11
- data/samples/Batch/AccountUpdate.rb +11 -11
- data/samples/Batch/SampleBatchDriver.rb +16 -16
- data/samples/Capture/{LitleCaptureGivenAuthTransaction.rb → CnpCaptureGivenAuthTransaction.rb} +4 -4
- data/samples/Capture/CnpCaptureTransaction.rb +14 -0
- data/samples/Capture/{LitleForceCaptureTransaction.rb → CnpForceCaptureTransaction.rb} +5 -5
- data/samples/Capture/CnpPartialCapture.rb +16 -0
- data/samples/Credit/CnpCreditTransaction.rb +16 -0
- data/samples/Credit/{LitleRefundTransaction.rb → CnpRefundTransaction.rb} +4 -4
- data/samples/Other/{LitleAvsTransaction.rb → CnpAvsTransaction.rb} +4 -4
- data/samples/Other/CnpVoidTransaction.rb +19 -0
- data/samples/Paypage/FullPaypageLifeCycle.rb +16 -16
- data/samples/Run_all.rb +12 -12
- data/samples/Sale/{LitleSaleTransaction.rb → CnpSaleTransaction.rb} +4 -4
- data/samples/Sale/SampleSaleTransaction.rb +5 -5
- data/test/certification/certTest1_base.rb +104 -103
- data/test/certification/certTest2_authenhanced.rb +90 -88
- data/test/certification/certTest3_authreversal.rb +29 -28
- data/test/certification/certTest4_echeck.rb +22 -20
- data/test/certification/certTest5_token.rb +51 -49
- data/test/certification/certTest_batchAll.rb +60 -60
- data/test/certification/ts_all.rb +1 -1
- data/test/functional/test_activate.rb +9 -8
- data/test/functional/test_activateReversal.rb +5 -5
- data/test/functional/test_auth.rb +31 -30
- data/test/functional/test_authReversal.rb +8 -8
- data/test/functional/test_balanceInquiry.rb +6 -6
- data/test/functional/test_batch.rb +32 -32
- data/test/functional/test_batchStream.rb +14 -14
- data/test/functional/test_cancelSubscription.rb +4 -4
- data/test/functional/test_capture.rb +14 -14
- data/test/functional/test_captureGivenAuth.rb +16 -16
- data/test/functional/test_configuration.rb +26 -26
- data/test/functional/test_createPlan.rb +5 -5
- data/test/functional/test_credit.rb +13 -33
- data/test/functional/test_deactivate.rb +6 -6
- data/test/functional/test_deactivateReversal.rb +5 -5
- data/test/functional/test_depositReversal.rb +5 -5
- data/test/functional/test_echeckCredit.rb +20 -20
- data/test/functional/test_echeckRedeposit.rb +16 -16
- data/test/functional/test_echeckSale.rb +35 -35
- data/test/functional/test_echeckVerification.rb +17 -17
- data/test/functional/test_echeckVoid.rb +4 -4
- data/test/functional/test_forceCapture.rb +21 -21
- data/test/functional/test_fraudCheck.rb +6 -5
- data/test/functional/test_giftCardAuthReversal.rb +5 -5
- data/test/functional/test_giftCardCapture.rb +5 -5
- data/test/functional/test_giftCardCredit.rb +5 -5
- data/test/functional/test_litle_requests.rb +101 -99
- data/test/functional/test_load.rb +6 -6
- data/test/functional/test_loadReversal.rb +5 -5
- data/test/functional/test_override.rb +9 -9
- data/test/functional/{test_pgp_litle_requests.rb → test_pgp_cnp_requests.rb} +61 -60
- data/test/functional/test_queryTransaction.rb +10 -10
- data/test/functional/test_refundReversal.rb +5 -5
- data/test/functional/test_sale.rb +36 -36
- data/test/functional/test_token.rb +10 -10
- data/test/functional/test_unload.rb +6 -6
- data/test/functional/test_unloadReversal.rb +5 -5
- data/test/functional/test_updateCardValidationNumOnToken.rb +4 -4
- data/test/functional/test_updatePlan.rb +4 -4
- data/test/functional/test_updateSubscription.rb +5 -5
- data/test/functional/test_wallet.rb +5 -5
- data/test/functional/test_xmlfields.rb +29 -69
- data/test/functional/ts_all.rb +2 -2
- data/test/unit/test_LitleAUBatch.rb +15 -15
- data/test/unit/test_LitleBatchRequest.rb +42 -76
- data/test/unit/test_LitleOnlineRequest.rb +38 -38
- data/test/unit/test_LitleRequest.rb +47 -47
- data/test/unit/test_LitleTransaction.rb +34 -34
- data/test/unit/test_LitleXmlMapper.rb +27 -27
- data/test/unit/test_activate.rb +8 -8
- data/test/unit/test_activateReversal.rb +5 -5
- data/test/unit/test_auth.rb +43 -43
- data/test/unit/test_authReversal.rb +14 -14
- data/test/unit/test_balanceInquiry.rb +4 -4
- data/test/unit/test_cancelSubscription.rb +4 -4
- data/test/unit/test_capture.rb +20 -20
- data/test/unit/test_captureGivenAuth.rb +22 -22
- data/test/unit/test_createPlan.rb +4 -4
- data/test/unit/test_credit.rb +43 -43
- data/test/unit/test_deactivate.rb +6 -6
- data/test/unit/test_deactivateReversal.rb +5 -5
- data/test/unit/test_depositReversal.rb +5 -5
- data/test/unit/test_echeckCredit.rb +16 -16
- data/test/unit/test_echeckRedeposit.rb +19 -19
- data/test/unit/test_echeckSale.rb +16 -16
- data/test/unit/test_echeckVerification.rb +11 -11
- data/test/unit/test_echeckVoid.rb +8 -8
- data/test/unit/test_forceCapture.rb +19 -19
- data/test/unit/test_fraudCheck.rb +4 -4
- data/test/unit/test_giftCardAuthReversal.rb +5 -5
- data/test/unit/test_giftCardCapture.rb +5 -5
- data/test/unit/test_giftCardCredit.rb +5 -5
- data/test/unit/test_load.rb +4 -4
- data/test/unit/test_loadReversal.rb +5 -5
- data/test/unit/{test_pgp_LitleRequest → test_pgp_CnpRequest.rb} +32 -32
- data/test/unit/test_queryTransaction.rb +8 -8
- data/test/unit/test_refundReversal.rb +5 -5
- data/test/unit/test_sale.rb +64 -64
- data/test/unit/test_token.rb +13 -13
- data/test/unit/test_unload.rb +4 -4
- data/test/unit/test_unloadReversal.rb +5 -5
- data/test/unit/test_updateCardValidationNumOnToken.rb +16 -16
- data/test/unit/test_updatePlan.rb +4 -4
- data/test/unit/test_updateSubscription.rb +11 -11
- data/test/unit/test_wallet.rb +13 -13
- data/test/unit/test_xmlfields.rb +119 -119
- data/test/unit/ts_unit.rb +6 -6
- metadata +35 -26
- data/samples/Auth/LitleAuthReversalTransaction.rb +0 -15
- data/samples/Capture/LitleCaptureTransaction.rb +0 -14
- data/samples/Capture/LitlePartialCapture.rb +0 -16
- data/samples/Credit/LitleCreditTransaction.rb +0 -16
- data/samples/Other/LitleVoidTransaction.rb +0 -19
@@ -22,11 +22,11 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
22
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
|
-
require File.expand_path("../../../lib/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test FraudCheck Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestFraudCheck < Test::Unit::TestCase
|
31
31
|
def test_fraud_check_happy_path
|
32
32
|
hash = {
|
@@ -40,10 +40,11 @@ module LitleOnline
|
|
40
40
|
'customAttribute2' => '55',
|
41
41
|
'customAttribute3' => '5'}
|
42
42
|
}
|
43
|
-
response =
|
43
|
+
response = CnpOnlineRequest.new.fraud_check_request(hash)
|
44
44
|
assert_equal('0', response.response)
|
45
45
|
assert_equal('pass', response.fraudCheckResponse.advancedFraudResults.deviceReviewStatus)
|
46
|
-
|
46
|
+
#sandbox is being updated to handle this correctly
|
47
|
+
#assert_equal('55', response.fraudCheckResponse.advancedFraudResults.deviceReputationScore)
|
47
48
|
assert_equal('triggered_rule_1', response.fraudCheckResponse.advancedFraudResults.triggeredRule[0])
|
48
49
|
assert_equal(5, response.fraudCheckResponse.advancedFraudResults.triggeredRule.size())
|
49
50
|
end
|
@@ -58,7 +59,7 @@ module LitleOnline
|
|
58
59
|
'threatMetrixSessionId' => 'test2-BXXXXXX003'
|
59
60
|
}
|
60
61
|
}
|
61
|
-
response =
|
62
|
+
response = CnpOnlineRequest.new.fraud_check_request(hash)
|
62
63
|
assert_equal('0', response.response)
|
63
64
|
assert_equal('pass', response.fraudCheckResponse.advancedFraudResults.deviceReviewStatus)
|
64
65
|
assert_equal('42', response.fraudCheckResponse.advancedFraudResults.deviceReputationScore)
|
@@ -22,11 +22,11 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
22
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
|
-
require File.expand_path("../../../lib/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test GiftCardAuthReversal Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestGiftCardAuthReversal < Test::Unit::TestCase
|
31
31
|
def test_giftCardAuthReversal
|
32
32
|
hash = {
|
@@ -34,7 +34,7 @@ module LitleOnline
|
|
34
34
|
'version'=>'8.8',
|
35
35
|
'id'=>'test',
|
36
36
|
'reportGroup'=>'Planets',
|
37
|
-
'
|
37
|
+
'cnpTxnId' =>'5000',
|
38
38
|
'card'=>{
|
39
39
|
'type'=>'GC',
|
40
40
|
'number' =>'400000000000000',
|
@@ -49,7 +49,7 @@ module LitleOnline
|
|
49
49
|
'originalSequenceNumber' => '111111',
|
50
50
|
}
|
51
51
|
|
52
|
-
response=
|
52
|
+
response= CnpOnlineRequest.new.giftCardAuth_reversal(hash)
|
53
53
|
assert_equal('000', response.giftCardAuthReversalResponse.response)
|
54
54
|
assert_equal('0', response.giftCardAuthReversalResponse.giftCardResponse.systemTraceId)
|
55
55
|
end
|
@@ -63,7 +63,7 @@ module LitleOnline
|
|
63
63
|
}
|
64
64
|
|
65
65
|
#Get exceptions
|
66
|
-
exception = assert_raise(RuntimeError){
|
66
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.giftCardAuth_reversal(hash)}
|
67
67
|
#Test
|
68
68
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
69
69
|
end
|
@@ -22,11 +22,11 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
22
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
|
-
require File.expand_path("../../../lib/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test GiftCardCapture Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestGiftCardCapture < Test::Unit::TestCase
|
31
31
|
def test_giftCardCapture
|
32
32
|
hash = {
|
@@ -35,7 +35,7 @@ module LitleOnline
|
|
35
35
|
'version'=>'8.8',
|
36
36
|
'id'=>'test',
|
37
37
|
'reportGroup'=>'Planets',
|
38
|
-
'
|
38
|
+
'cnpTxnId' =>'5000',
|
39
39
|
'card'=>{
|
40
40
|
'type'=>'GC',
|
41
41
|
'number' =>'400000000000000',
|
@@ -49,7 +49,7 @@ module LitleOnline
|
|
49
49
|
|
50
50
|
}
|
51
51
|
|
52
|
-
response=
|
52
|
+
response= CnpOnlineRequest.new.giftCardCapture(hash)
|
53
53
|
assert_equal('000', response.giftCardCaptureResponse.response)
|
54
54
|
assert_equal('0', response.giftCardCaptureResponse.giftCardResponse.systemTraceId)
|
55
55
|
end
|
@@ -63,7 +63,7 @@ module LitleOnline
|
|
63
63
|
}
|
64
64
|
|
65
65
|
#Get exceptions
|
66
|
-
exception = assert_raise(RuntimeError){
|
66
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.giftCardCapture(hash)}
|
67
67
|
#Test
|
68
68
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
69
69
|
end
|
@@ -22,18 +22,18 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
22
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
23
|
OTHER DEALINGS IN THE SOFTWARE.
|
24
24
|
=end
|
25
|
-
require File.expand_path("../../../lib/
|
25
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
26
26
|
require 'test/unit'
|
27
27
|
|
28
28
|
#test GiftCardCapture Transaction
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestGiftCardCredit < Test::Unit::TestCase
|
31
31
|
def test_giftCardCredit
|
32
32
|
hash = {
|
33
33
|
'id'=>'test',
|
34
34
|
'merchantId' => '101',
|
35
35
|
'version'=>'8.8',
|
36
|
-
'
|
36
|
+
'cnpTxnId' => '5000',
|
37
37
|
'creditAmount' =>'1000',
|
38
38
|
#'orderId' =>'1230',
|
39
39
|
'card'=>{
|
@@ -46,7 +46,7 @@ module LitleOnline
|
|
46
46
|
'reportGroup'=>'Planets',
|
47
47
|
}
|
48
48
|
|
49
|
-
response=
|
49
|
+
response= CnpOnlineRequest.new.giftCardCredit(hash)
|
50
50
|
assert_equal('000', response.giftCardCreditResponse.response)
|
51
51
|
assert_equal('0', response.giftCardCreditResponse.giftCardResponse.systemTraceId)
|
52
52
|
end
|
@@ -60,7 +60,7 @@ module LitleOnline
|
|
60
60
|
}
|
61
61
|
|
62
62
|
#Get exceptions
|
63
|
-
exception = assert_raise(RuntimeError){
|
63
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.giftCardCredit(hash)}
|
64
64
|
#Test
|
65
65
|
assert(exception.message =~ /Error validating xml data against the schema/)
|
66
66
|
end
|
@@ -19,15 +19,17 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
19
19
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
20
20
|
OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
=end
|
22
|
-
require File.expand_path("../../../lib/
|
22
|
+
require File.expand_path("../../../lib/CnpOnline",__FILE__)
|
23
23
|
require 'test/unit'
|
24
24
|
require 'fileutils'
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
CNP_SDK_TEST_FOLDER = '/cnp-sdk-for-ruby-test'
|
27
|
+
|
28
|
+
module CnpOnline
|
29
|
+
class TestCnpRequest < Test::Unit::TestCase
|
28
30
|
|
29
31
|
def setup
|
30
|
-
dir = '/tmp
|
32
|
+
dir = '/tmp' + CNP_SDK_TEST_FOLDER
|
31
33
|
FileUtils.rm_rf dir
|
32
34
|
Dir.mkdir dir
|
33
35
|
end
|
@@ -35,79 +37,79 @@ module LitleOnline
|
|
35
37
|
def test_request_creation
|
36
38
|
dir = '/tmp'
|
37
39
|
|
38
|
-
request =
|
39
|
-
request.
|
40
|
+
request = CnpRequest.new()
|
41
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
40
42
|
|
41
|
-
entries = Dir.entries(dir +
|
43
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
42
44
|
entries.sort!
|
43
45
|
|
44
46
|
assert_equal 4, entries.size
|
45
|
-
assert_not_nil entries[2] =~
|
46
|
-
assert_not_nil entries[3] =~
|
47
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
48
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_commit_batch_with_path
|
50
52
|
dir = '/tmp'
|
51
53
|
|
52
|
-
batch =
|
53
|
-
batch.create_new_batch(dir +
|
54
|
+
batch = CnpBatchRequest.new
|
55
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
54
56
|
batch.close_batch
|
55
|
-
entries = Dir.entries(dir +
|
57
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
56
58
|
|
57
59
|
assert_equal 3, entries.length
|
58
60
|
entries.sort!
|
59
61
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
60
62
|
|
61
|
-
request =
|
62
|
-
request.
|
63
|
-
entries = Dir.entries(dir +
|
63
|
+
request = CnpRequest.new
|
64
|
+
request.create_new_cnp_request(dir+ CNP_SDK_TEST_FOLDER)
|
65
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
64
66
|
entries.sort!
|
65
67
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
66
|
-
assert_not_nil entries[3] =~
|
67
|
-
assert_not_nil entries[4] =~
|
68
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
69
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
68
70
|
|
69
71
|
request.commit_batch(batch.get_batch_name)
|
70
|
-
entries = Dir.entries(dir +
|
72
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
71
73
|
entries.sort!
|
72
74
|
assert_equal 4,entries.length
|
73
|
-
assert_not_nil entries[2] =~
|
74
|
-
assert_not_nil entries[3] =~
|
75
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
76
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
75
77
|
end
|
76
78
|
|
77
79
|
def test_commit_batch_with_batch
|
78
80
|
dir = '/tmp'
|
79
81
|
|
80
|
-
batch =
|
81
|
-
batch.create_new_batch(dir +
|
82
|
+
batch = CnpBatchRequest.new
|
83
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
82
84
|
batch.close_batch
|
83
|
-
entries = Dir.entries(dir +
|
85
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
84
86
|
|
85
87
|
assert_equal 3, entries.length
|
86
88
|
entries.sort!
|
87
89
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
88
90
|
|
89
|
-
request =
|
90
|
-
request.
|
91
|
-
entries = Dir.entries(dir +
|
91
|
+
request = CnpRequest.new
|
92
|
+
request.create_new_cnp_request(dir+ CNP_SDK_TEST_FOLDER)
|
93
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
92
94
|
entries.sort!
|
93
95
|
assert_equal 5, entries.length
|
94
96
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
95
|
-
assert_not_nil entries[3] =~
|
96
|
-
assert_not_nil entries[4] =~
|
97
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
98
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
97
99
|
|
98
100
|
request.commit_batch(batch)
|
99
|
-
entries = Dir.entries(dir +
|
101
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
100
102
|
entries.sort!
|
101
103
|
assert_equal 4, entries.length
|
102
|
-
assert_not_nil entries[2] =~
|
103
|
-
assert_not_nil entries[3] =~
|
104
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
105
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
104
106
|
end
|
105
107
|
|
106
108
|
def test_commit_batch_with_batch_and_au
|
107
109
|
dir = '/tmp'
|
108
110
|
|
109
|
-
batch =
|
110
|
-
batch.create_new_batch(dir +
|
111
|
+
batch = CnpBatchRequest.new
|
112
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
111
113
|
accountUpdateHash = {
|
112
114
|
'reportGroup'=>'Planets',
|
113
115
|
'id'=>'12345',
|
@@ -120,84 +122,84 @@ module LitleOnline
|
|
120
122
|
batch.account_update(accountUpdateHash)
|
121
123
|
batch.close_batch
|
122
124
|
|
123
|
-
entries = Dir.entries(dir +
|
125
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
124
126
|
|
125
127
|
assert_equal 4, entries.length
|
126
128
|
entries.sort!
|
127
129
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
128
130
|
assert_not_nil entries[3] =~ /batch_\d+.closed-1\z/
|
129
131
|
|
130
|
-
request =
|
131
|
-
request.
|
132
|
-
entries = Dir.entries(dir +
|
132
|
+
request = CnpRequest.new
|
133
|
+
request.create_new_cnp_request(dir+ CNP_SDK_TEST_FOLDER)
|
134
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
133
135
|
entries.sort!
|
134
136
|
assert_equal 6, entries.length
|
135
137
|
assert_not_nil entries[2] =~ /batch_\d+.closed-0\z/
|
136
138
|
assert_not_nil entries[3] =~ /batch_\d+.closed-1\z/
|
137
|
-
assert_not_nil entries[4] =~
|
138
|
-
assert_not_nil entries[5] =~
|
139
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
140
|
+
assert_not_nil entries[5] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
139
141
|
|
140
142
|
request.commit_batch(batch)
|
141
|
-
entries = Dir.entries(dir +
|
143
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
142
144
|
entries.sort!
|
143
145
|
assert_equal 4, entries.length
|
144
|
-
assert_not_nil entries[2] =~
|
145
|
-
assert_not_nil entries[3] =~
|
146
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
147
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
146
148
|
end
|
147
149
|
|
148
150
|
def test_finish_request
|
149
151
|
dir = '/tmp'
|
150
152
|
|
151
|
-
request =
|
152
|
-
request.
|
153
|
+
request = CnpRequest.new()
|
154
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
153
155
|
|
154
|
-
entries = Dir.entries(dir +
|
156
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
155
157
|
entries.sort!
|
156
158
|
|
157
159
|
assert_equal 4, entries.size
|
158
|
-
assert_not_nil entries[2] =~
|
159
|
-
assert_not_nil entries[3] =~
|
160
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
161
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
160
162
|
|
161
163
|
request.finish_request
|
162
164
|
|
163
|
-
entries = Dir.entries(dir +
|
165
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
164
166
|
entries.sort!
|
165
167
|
|
166
168
|
assert_equal 3, entries.size
|
167
|
-
assert_not_nil entries[2] =~
|
169
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}\z/
|
168
170
|
end
|
169
171
|
|
170
172
|
def test_add_rfr
|
171
173
|
@config_hash = Configuration.new.config
|
172
174
|
|
173
175
|
dir = '/tmp'
|
174
|
-
temp = dir + '/
|
176
|
+
temp = dir + CNP_SDK_TEST_FOLDER + '/'
|
175
177
|
|
176
|
-
request =
|
177
|
-
request.add_rfr_request({'
|
178
|
+
request = CnpRequest.new()
|
179
|
+
request.add_rfr_request({'cnpSessionId' => '137813712'}, temp)
|
178
180
|
|
179
181
|
entries = Dir.entries(temp)
|
180
182
|
entries.sort!
|
181
183
|
|
182
184
|
assert_equal 3, entries.size
|
183
|
-
assert_not_nil entries[2] =~
|
185
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}\z/
|
184
186
|
end
|
185
187
|
|
186
|
-
def
|
188
|
+
def test_send_to_cnp
|
187
189
|
@config_hash = Configuration.new.config
|
188
190
|
|
189
191
|
dir = '/tmp'
|
190
192
|
|
191
|
-
request =
|
192
|
-
request.
|
193
|
+
request = CnpRequest.new()
|
194
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
193
195
|
request.finish_request
|
194
|
-
request.
|
196
|
+
request.send_to_cnp
|
195
197
|
|
196
|
-
entries = Dir.entries(dir +
|
198
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
197
199
|
entries.sort!
|
198
200
|
assert_equal 3, entries.size
|
199
201
|
puts entries[2]
|
200
|
-
assert_not_nil entries[2] =~
|
202
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
201
203
|
|
202
204
|
uploaded_file = entries[2]
|
203
205
|
|
@@ -217,33 +219,33 @@ module LitleOnline
|
|
217
219
|
}
|
218
220
|
assert_equal 3,ents.size
|
219
221
|
ents.sort!
|
220
|
-
assert_equal ents[2], uploaded_file.gsub(
|
222
|
+
assert_equal ents[2], uploaded_file.gsub(SENT_FILE_SUFFIX, '.asc')
|
221
223
|
sftp.remove('/inbound/' + ents[2])
|
222
224
|
end
|
223
225
|
end
|
224
226
|
|
225
|
-
def
|
227
|
+
def test_send_to_cnp_stream
|
226
228
|
@config_hash = Configuration.new.config
|
227
229
|
|
228
230
|
dir = '/tmp'
|
229
231
|
|
230
|
-
request =
|
231
|
-
request.
|
232
|
+
request = CnpRequest.new()
|
233
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
232
234
|
request.finish_request
|
233
|
-
request.
|
235
|
+
request.send_to_cnp_stream
|
234
236
|
|
235
|
-
entries = Dir.entries(dir +
|
237
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
236
238
|
entries.sort!
|
237
239
|
|
238
240
|
assert_equal 4, entries.size
|
239
|
-
assert_not_nil entries[2] =~
|
240
|
-
File.delete(dir + '/
|
241
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
242
|
+
File.delete(dir + CNP_SDK_TEST_FOLDER + '/' + entries[2])
|
241
243
|
|
242
|
-
entries = Dir.entries(dir + '/
|
244
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + RESPONSE_PATH_DIR)
|
243
245
|
entries.sort!
|
244
246
|
|
245
247
|
assert_equal 3, entries.size
|
246
|
-
assert_not_nil entries[2] =~
|
248
|
+
assert_not_nil entries[2] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}\z/
|
247
249
|
|
248
250
|
end
|
249
251
|
|
@@ -262,29 +264,29 @@ module LitleOnline
|
|
262
264
|
|
263
265
|
dir = '/tmp'
|
264
266
|
|
265
|
-
request =
|
266
|
-
request.
|
267
|
+
request = CnpRequest.new()
|
268
|
+
request.create_new_cnp_request(dir + CNP_SDK_TEST_FOLDER)
|
267
269
|
|
268
|
-
entries = Dir.entries(dir +
|
270
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
269
271
|
entries.sort!
|
270
272
|
|
271
273
|
assert_equal 4, entries.size
|
272
|
-
assert_not_nil entries[2] =~
|
273
|
-
assert_not_nil entries[3] =~
|
274
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
275
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
274
276
|
|
275
277
|
#create five batches, each with 10 sales
|
276
278
|
5.times{
|
277
|
-
batch =
|
278
|
-
batch.create_new_batch(dir +
|
279
|
+
batch = CnpBatchRequest.new
|
280
|
+
batch.create_new_batch(dir + CNP_SDK_TEST_FOLDER)
|
279
281
|
|
280
|
-
entries = Dir.entries(dir +
|
282
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
281
283
|
|
282
284
|
assert_equal 6, entries.length
|
283
285
|
entries.sort!
|
284
286
|
assert_not_nil entries[2] =~ /batch_\d+\z/
|
285
287
|
assert_not_nil entries[3] =~ /batch_\d+_txns\z/
|
286
|
-
assert_not_nil entries[4] =~
|
287
|
-
assert_not_nil entries[5] =~
|
288
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
289
|
+
assert_not_nil entries[5] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
288
290
|
#add the same sale ten times
|
289
291
|
10.times{
|
290
292
|
#batch.account_update(accountUpdateHash)
|
@@ -294,50 +296,50 @@ module LitleOnline
|
|
294
296
|
|
295
297
|
#close the batch, indicating we plan to add no more transactions
|
296
298
|
batch.close_batch()
|
297
|
-
entries = Dir.entries(dir +
|
299
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
298
300
|
|
299
301
|
assert_equal 5, entries.length
|
300
302
|
entries.sort!
|
301
303
|
assert_not_nil entries[2] =~ /batch_\d+.closed-\d+\z/
|
302
|
-
assert_not_nil entries[3] =~
|
303
|
-
assert_not_nil entries[4] =~
|
304
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
305
|
+
assert_not_nil entries[4] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
304
306
|
|
305
|
-
#add the batch to the
|
307
|
+
#add the batch to the CnpRequest
|
306
308
|
request.commit_batch(batch)
|
307
|
-
entries = Dir.entries(dir +
|
309
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
308
310
|
assert_equal 4, entries.length
|
309
311
|
entries.sort!
|
310
|
-
assert_not_nil entries[2] =~
|
311
|
-
assert_not_nil entries[3] =~
|
312
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+\z/
|
313
|
+
assert_not_nil entries[3] =~ /#{REQUEST_FILE_PREFIX}\d+_batches\z/
|
312
314
|
}
|
313
|
-
#finish the
|
315
|
+
#finish the Cnp Request, indicating we plan to add no more batches
|
314
316
|
request.finish_request
|
315
|
-
entries = Dir.entries(dir +
|
317
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
316
318
|
assert_equal 3, entries.length
|
317
319
|
entries.sort!
|
318
|
-
assert_not_nil entries[2] =~
|
320
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+.complete\z/
|
319
321
|
|
320
322
|
#send the batch files at the given directory over sFTP
|
321
|
-
request.
|
322
|
-
entries = Dir.entries(dir +
|
323
|
+
request.send_to_cnp
|
324
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
323
325
|
assert_equal entries.length, 3
|
324
326
|
entries.sort!
|
325
|
-
assert_not_nil entries[2] =~
|
327
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
326
328
|
#grab the expected number of responses from the sFTP server and save them to the given path
|
327
329
|
request.get_responses_from_server()
|
328
330
|
#process the responses from the server with a listener which applies the given block
|
329
|
-
request.process_responses({:transaction_listener =>
|
331
|
+
request.process_responses({:transaction_listener => CnpOnline::DefaultCnpListener.new do |transaction| end})
|
330
332
|
|
331
|
-
entries = Dir.entries(dir +
|
332
|
-
assert_equal 4, entries.length
|
333
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER)
|
334
|
+
assert_equal 4, entries.length # 3 -> 4
|
333
335
|
entries.sort!
|
334
|
-
assert_not_nil entries[2] =~
|
335
|
-
File.delete(dir + '/
|
336
|
+
assert_not_nil entries[2] =~ /#{REQUEST_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}#{SENT_FILE_SUFFIX}\z/
|
337
|
+
File.delete(dir + CNP_SDK_TEST_FOLDER + '/' + entries[2])
|
336
338
|
|
337
|
-
entries = Dir.entries(dir + '/
|
339
|
+
entries = Dir.entries(dir + CNP_SDK_TEST_FOLDER + '/' + entries[3])
|
338
340
|
entries.sort!
|
339
341
|
assert_equal 3, entries.length
|
340
|
-
assert_not_nil entries[2] =~
|
342
|
+
assert_not_nil entries[2] =~ /#{RESPONSE_FILE_PREFIX}\d+#{COMPLETE_FILE_SUFFIX}.asc#{RECEIVED_FILE_SUFFIX}.processed\z/
|
341
343
|
end
|
342
344
|
|
343
345
|
def get_config(field, options)
|