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,24 +22,24 @@ 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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestAuthReversal < Test::Unit::TestCase
|
31
31
|
def test_invalid_field
|
32
32
|
hash = {
|
33
33
|
'merchantId' => '101',
|
34
34
|
'version'=>'8.8',
|
35
|
-
'
|
35
|
+
'cnpTxnId'=>'12345678000',
|
36
36
|
'NonexistentField'=>'none',
|
37
37
|
'payPalNotes'=>'Notes',
|
38
38
|
'amount'=>'106',
|
39
39
|
'reportGroup'=>'Planets',
|
40
40
|
}
|
41
|
-
|
42
|
-
|
41
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>12345678000<\/cnpTxnId>.*/m), is_a(Hash))
|
42
|
+
CnpOnlineRequest.new.auth_reversal(hash)
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_logged_in_user
|
@@ -47,36 +47,36 @@ module LitleOnline
|
|
47
47
|
'merchantSdk' => 'Ruby;8.14.0',
|
48
48
|
'merchantId' => '101',
|
49
49
|
'version'=>'8.8',
|
50
|
-
'
|
50
|
+
'cnpTxnId'=>'12345678000',
|
51
51
|
'reportGroup'=>'Planets',
|
52
52
|
'amount'=>'5000',
|
53
53
|
'loggedInUser'=>'gdake'
|
54
54
|
}
|
55
|
-
|
56
|
-
|
55
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
56
|
+
CnpOnlineRequest.new.auth_reversal(hash)
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_surcharge_amount
|
60
60
|
hash = {
|
61
|
-
'
|
61
|
+
'cnpTxnId' => '3',
|
62
62
|
'amount' => '2',
|
63
63
|
'surchargeAmount' => '1',
|
64
64
|
'payPalNotes' => 'note',
|
65
65
|
'reportGroup' => 'Planets'
|
66
66
|
}
|
67
|
-
|
68
|
-
|
67
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><payPalNotes>note<\/payPalNotes>.*/m), is_a(Hash))
|
68
|
+
CnpOnlineRequest.new.auth_reversal(hash)
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_surcharge_amount_optional
|
72
72
|
hash = {
|
73
|
-
'
|
73
|
+
'cnpTxnId' => '3',
|
74
74
|
'amount' => '2',
|
75
75
|
'payPalNotes' => 'note',
|
76
76
|
'reportGroup' => 'Planets'
|
77
77
|
}
|
78
|
-
|
79
|
-
|
78
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><payPalNotes>note<\/payPalNotes>.*/m), is_a(Hash))
|
79
|
+
CnpOnlineRequest.new.auth_reversal(hash)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -22,10 +22,10 @@ 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
|
require 'mocha/setup'
|
28
|
-
module
|
28
|
+
module CnpOnline
|
29
29
|
class TestBalanceInquiry < Test::Unit::TestCase
|
30
30
|
|
31
31
|
def test_simple
|
@@ -43,8 +43,8 @@ module LitleOnline
|
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<balanceInquiry reportGroup="Planets"><orderId>11<\/orderId><orderSource>ecommerce<\/orderSource><card><type>GC<\/type><number>4100000000000001<\/number><expDate>1210<\/expDate><\/card><\/balanceInquiry>.*/m), is_a(Hash))
|
47
|
+
CnpOnlineRequest.new.balance_inquiry(hash)
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
@@ -22,10 +22,10 @@ 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
|
require 'mocha/setup'
|
28
|
-
module
|
28
|
+
module CnpOnline
|
29
29
|
class TestCancelSubscription < Test::Unit::TestCase
|
30
30
|
|
31
31
|
def test_simple
|
@@ -34,8 +34,8 @@ module LitleOnline
|
|
34
34
|
'merchantId' => '101',
|
35
35
|
'version'=>'8.8',
|
36
36
|
}
|
37
|
-
|
38
|
-
|
37
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cancelSubscription><subscriptionId>100<\/subscriptionId><\/cancelSubscription>.*/m), is_a(Hash))
|
38
|
+
CnpOnlineRequest.new.cancel_subscription(hash)
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
data/test/unit/test_capture.rb
CHANGED
@@ -22,76 +22,76 @@ 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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class Test_capture < Test::Unit::TestCase
|
31
31
|
def test_success_capture
|
32
32
|
hash = {
|
33
|
-
'
|
33
|
+
'cnpTxnId'=>'123456'
|
34
34
|
}
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>123456<\/cnpTxnId>.*/m), is_a(Hash))
|
37
|
+
CnpOnlineRequest.new.capture(hash)
|
38
38
|
end
|
39
39
|
def test_logged_in_user
|
40
40
|
hash = {
|
41
41
|
'merchantSdk' => 'Ruby;8.14.0',
|
42
|
-
'
|
42
|
+
'cnpTxnId'=>'123456',
|
43
43
|
'loggedInUser'=>'gdake'
|
44
44
|
}
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
47
|
+
CnpOnlineRequest.new.capture(hash)
|
48
48
|
end
|
49
49
|
def test_surcharge_amount
|
50
50
|
hash = {
|
51
|
-
'
|
51
|
+
'cnpTxnId' => '3',
|
52
52
|
'amount' => '2',
|
53
53
|
'surchargeAmount' => '1',
|
54
54
|
'payPalNotes' => 'note',
|
55
55
|
'reportGroup' => 'Planets'
|
56
56
|
}
|
57
|
-
|
58
|
-
|
57
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><payPalNotes>note<\/payPalNotes>.*/m), is_a(Hash))
|
58
|
+
CnpOnlineRequest.new.capture(hash)
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_surcharge_amount_optional
|
62
62
|
hash = {
|
63
|
-
'
|
63
|
+
'cnpTxnId' => '3',
|
64
64
|
'amount' => '2',
|
65
65
|
'payPalNotes' => 'note',
|
66
66
|
'reportGroup' => 'Planets'
|
67
67
|
}
|
68
|
-
|
69
|
-
|
68
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><payPalNotes>note<\/payPalNotes>.*/m), is_a(Hash))
|
69
|
+
CnpOnlineRequest.new.capture(hash)
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_pin
|
73
73
|
hash = {
|
74
|
-
'
|
74
|
+
'cnpTxnId' => '123456000',
|
75
75
|
'amount' => '2',
|
76
76
|
'payPalNotes' => 'note',
|
77
77
|
'pin' => '1234'
|
78
78
|
}
|
79
|
-
|
80
|
-
|
79
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<pin>1234<\/pin>.*/m), is_a(Hash))
|
80
|
+
CnpOnlineRequest.new.capture(hash)
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_custom_billing
|
84
84
|
hash = {
|
85
85
|
'payPalNotes'=>'Notes',
|
86
|
-
'
|
86
|
+
'cnpTxnId'=>'123456000',
|
87
87
|
'amount'=>'106',
|
88
88
|
'customBilling'=>{
|
89
89
|
'city' =>'boston',
|
90
90
|
'descriptor' => 'card was present',
|
91
91
|
}
|
92
92
|
}
|
93
|
-
|
94
|
-
|
93
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<customBilling><city>boston<\/city><descriptor>card was present<\/descriptor><\/customBilling>.*/m), is_a(Hash))
|
94
|
+
CnpOnlineRequest.new.capture(hash)
|
95
95
|
end
|
96
96
|
|
97
97
|
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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestcaptureGivenAuth < Test::Unit::TestCase
|
31
31
|
def test_both_choices_card_and_token
|
32
32
|
hash = {
|
@@ -41,7 +41,7 @@ module LitleOnline
|
|
41
41
|
'authAmount'=>'12345'
|
42
42
|
},
|
43
43
|
'token'=> {
|
44
|
-
'
|
44
|
+
'cnpToken'=>'123456789101112',
|
45
45
|
'expDate'=>'1210',
|
46
46
|
'cardValidationNum'=>'555',
|
47
47
|
'type'=>'VI'},
|
@@ -50,7 +50,7 @@ module LitleOnline
|
|
50
50
|
'number' =>'4100000000000001',
|
51
51
|
'expDate' =>'1210'
|
52
52
|
}}
|
53
|
-
exception = assert_raise(RuntimeError){
|
53
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.capture_given_auth(hash)}
|
54
54
|
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
55
55
|
end
|
56
56
|
|
@@ -77,13 +77,13 @@ module LitleOnline
|
|
77
77
|
'cardValidationNum'=>'555',
|
78
78
|
'type'=>'VI'},
|
79
79
|
'token'=> {
|
80
|
-
'
|
80
|
+
'cnpToken'=>'1234567890123',
|
81
81
|
'expDate'=>'1210',
|
82
82
|
'cardValidationNum'=>'555',
|
83
83
|
'type'=>'VI'
|
84
84
|
}}
|
85
85
|
|
86
|
-
exception = assert_raise(RuntimeError){
|
86
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.capture_given_auth(hash)}
|
87
87
|
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
88
88
|
end
|
89
89
|
|
@@ -106,8 +106,8 @@ module LitleOnline
|
|
106
106
|
'number' =>'4100000000000001',
|
107
107
|
'expDate' =>'1210'
|
108
108
|
}}
|
109
|
-
|
110
|
-
|
109
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
110
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
111
111
|
end
|
112
112
|
|
113
113
|
def test_secondary_amount
|
@@ -118,8 +118,8 @@ module LitleOnline
|
|
118
118
|
'orderSource' => 'ecommerce',
|
119
119
|
'reportGroup' => 'Planets'
|
120
120
|
}
|
121
|
-
|
122
|
-
|
121
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
122
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_surcharge_amount
|
@@ -129,8 +129,8 @@ module LitleOnline
|
|
129
129
|
'orderSource' => 'ecommerce',
|
130
130
|
'reportGroup' => 'Planets'
|
131
131
|
}
|
132
|
-
|
133
|
-
|
132
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
133
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_surcharge_amount_optional
|
@@ -139,8 +139,8 @@ module LitleOnline
|
|
139
139
|
'orderSource' => 'ecommerce',
|
140
140
|
'reportGroup' => 'Planets'
|
141
141
|
}
|
142
|
-
|
143
|
-
|
142
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
143
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
144
144
|
end
|
145
145
|
|
146
146
|
def test_fraudResult
|
@@ -159,8 +159,8 @@ module LitleOnline
|
|
159
159
|
}
|
160
160
|
}
|
161
161
|
}
|
162
|
-
|
163
|
-
|
162
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<advancedFraudResults><deviceReviewStatus>deviceReviewStatusString<\/deviceReviewStatus><deviceReputationScore>100<\/deviceReputationScore><\/advancedFraudResults>.*/m), is_a(Hash))
|
163
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
164
164
|
end
|
165
165
|
|
166
166
|
def test_fraudResult1
|
@@ -180,8 +180,8 @@ module LitleOnline
|
|
180
180
|
}
|
181
181
|
}
|
182
182
|
}
|
183
|
-
|
184
|
-
|
183
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<advancedFraudResults><deviceReviewStatus>deviceReviewStatusString<\/deviceReviewStatus><deviceReputationScore>100<\/deviceReputationScore><triggeredRule>rule1<\/triggeredRule><triggeredRule>rule2<\/triggeredRule><\/advancedFraudResults>.*/m), is_a(Hash))
|
184
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
185
185
|
end
|
186
186
|
|
187
187
|
def test_processingType
|
@@ -202,8 +202,8 @@ module LitleOnline
|
|
202
202
|
'number' =>'4100000000000001',
|
203
203
|
'expDate' =>'1210'
|
204
204
|
}}
|
205
|
-
|
206
|
-
|
205
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<processingType>initialRecurring<\/processingType>.*/m), is_a(Hash))
|
206
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
207
207
|
end
|
208
208
|
|
209
209
|
def test_originalNetworkTransactionId_originalTransactionAmount
|
@@ -226,8 +226,8 @@ module LitleOnline
|
|
226
226
|
'originalNetworkTransactionId'=>'987654321098765432109876543210',
|
227
227
|
'originalTransactionAmount'=>'10661'
|
228
228
|
}
|
229
|
-
|
230
|
-
|
229
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<originalNetworkTransactionId>987654321098765432109876543210<\/originalNetworkTransactionId><originalTransactionAmount>10661<\/originalTransactionAmount>.*/m), is_a(Hash))
|
230
|
+
CnpOnlineRequest.new.capture_given_auth(hash)
|
231
231
|
end
|
232
232
|
|
233
233
|
end
|
@@ -22,10 +22,10 @@ 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
|
require 'mocha/setup'
|
28
|
-
module
|
28
|
+
module CnpOnline
|
29
29
|
class TestCreatePlan < Test::Unit::TestCase
|
30
30
|
|
31
31
|
def test_simple
|
@@ -43,8 +43,8 @@ module LitleOnline
|
|
43
43
|
'trialIntervalType'=>'MONTH',
|
44
44
|
'active'=>'true'
|
45
45
|
}
|
46
|
-
|
47
|
-
|
46
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<createPlan><planCode>planCodeString<\/planCode><name>nameString<\/name><description>descriptionString<\/description><intervalType>ANNUAL<\/intervalType><amount>500<\/amount><numberOfPayments>2<\/numberOfPayments><trialNumberOfIntervals>1<\/trialNumberOfIntervals><trialIntervalType>MONTH<\/trialIntervalType><active>true<\/active><\/createPlan>.*/m), is_a(Hash))
|
47
|
+
CnpOnlineRequest.new.create_plan(hash)
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
data/test/unit/test_credit.rb
CHANGED
@@ -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
|
require 'mocha/setup'
|
28
28
|
|
29
|
-
module
|
29
|
+
module CnpOnline
|
30
30
|
class TestCredit < Test::Unit::TestCase
|
31
31
|
def test_both_choices_card_and_paypal
|
32
32
|
hash = {
|
@@ -48,7 +48,7 @@ module LitleOnline
|
|
48
48
|
'transactionId'=>'123456'
|
49
49
|
}}
|
50
50
|
|
51
|
-
exception = assert_raise(RuntimeError){
|
51
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
52
52
|
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
53
53
|
end
|
54
54
|
|
@@ -76,7 +76,7 @@ module LitleOnline
|
|
76
76
|
'token'=>'1234',
|
77
77
|
'transactionId'=>'123456'
|
78
78
|
}}
|
79
|
-
exception = assert_raise(RuntimeError){
|
79
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
80
80
|
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
81
81
|
end
|
82
82
|
|
@@ -108,14 +108,14 @@ module LitleOnline
|
|
108
108
|
'transactionId'=>'123456'
|
109
109
|
},
|
110
110
|
'token'=> {
|
111
|
-
'
|
111
|
+
'cnpToken'=>'1234567890123',
|
112
112
|
'expDate'=>'1210',
|
113
113
|
'cardValidationNum'=>'555',
|
114
114
|
'type'=>'VI'
|
115
115
|
}
|
116
116
|
}
|
117
117
|
|
118
|
-
exception = assert_raise(RuntimeError){
|
118
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
119
119
|
assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
|
120
120
|
end
|
121
121
|
|
@@ -129,8 +129,8 @@ module LitleOnline
|
|
129
129
|
'reportGroup'=>'Planets',
|
130
130
|
'actionReason'=> 'SUSPECT_FRAUD'
|
131
131
|
}
|
132
|
-
|
133
|
-
|
132
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<actionReason>SUSPECT_FRAUD<\/actionReason>.*/m), is_a(Hash))
|
133
|
+
CnpOnlineRequest.new.credit(hash)
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_simple_enhanced_data_incorrect_enum_for_country_code
|
@@ -147,13 +147,13 @@ module LitleOnline
|
|
147
147
|
'orderSource'=>'ecommerce',
|
148
148
|
'enhancedData'=>{
|
149
149
|
'destinationCountryCode'=>'001',
|
150
|
-
'customerReference'=>'
|
150
|
+
'customerReference'=>'Cnp',
|
151
151
|
'salesTax'=>'50',
|
152
152
|
'deliveryType'=>'TBD',
|
153
153
|
'shipFromPostalCode'=>'01741',
|
154
154
|
'destinationPostalCode'=>'01742'}
|
155
155
|
}
|
156
|
-
exception = assert_raise(RuntimeError){
|
156
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
157
157
|
assert_match /If enhancedData destinationCountryCode is specified, it must be/, exception.message
|
158
158
|
end
|
159
159
|
|
@@ -166,13 +166,13 @@ module LitleOnline
|
|
166
166
|
'amount'=>'106',
|
167
167
|
'orderSource'=>'ecommerce',
|
168
168
|
'token'=> {
|
169
|
-
'
|
169
|
+
'cnpToken'=>'123456789012',
|
170
170
|
'expDate'=>'1210',
|
171
171
|
'cardValidationNum'=>'555',
|
172
172
|
'type'=>'VI'
|
173
173
|
}}
|
174
|
-
exception = assert_raise(RuntimeError){
|
175
|
-
assert_match /If token
|
174
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
175
|
+
assert_match /If token cnpToken is specified, it must be between/, exception.message
|
176
176
|
end
|
177
177
|
|
178
178
|
def test_token_missing_token
|
@@ -188,8 +188,8 @@ module LitleOnline
|
|
188
188
|
'cardValidationNum'=>'555',
|
189
189
|
'type'=>'VI'
|
190
190
|
}}
|
191
|
-
exception = assert_raise(RuntimeError){
|
192
|
-
assert_match /If token is specified, it must have a
|
191
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
192
|
+
assert_match /If token is specified, it must have a cnpToken/, exception.message
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_pos_with_invalid_entry_mode
|
@@ -206,7 +206,7 @@ module LitleOnline
|
|
206
206
|
'number' =>'4100000000000001',
|
207
207
|
'expDate' =>'1210'
|
208
208
|
}}
|
209
|
-
exception = assert_raise(RuntimeError){
|
209
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
210
210
|
assert_match /If pos entryMode is specified, it must be in/, exception.message
|
211
211
|
end
|
212
212
|
|
@@ -223,7 +223,7 @@ module LitleOnline
|
|
223
223
|
'cardValidationNum'=>'555',
|
224
224
|
'type'=>'VI'
|
225
225
|
}}
|
226
|
-
exception = assert_raise(RuntimeError){
|
226
|
+
exception = assert_raise(RuntimeError){CnpOnlineRequest.new.credit(hash)}
|
227
227
|
assert_match /If paypage is specified, it must have a paypageRegistrationId/, exception.message
|
228
228
|
end
|
229
229
|
|
@@ -238,43 +238,43 @@ module LitleOnline
|
|
238
238
|
'orderSource'=>'ecommerce',
|
239
239
|
'reportGroup'=>'Planets'
|
240
240
|
}
|
241
|
-
|
242
|
-
|
241
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*(loggedInUser="gdake".*merchantSdk="Ruby;8.14.0")|(merchantSdk="Ruby;8.14.0".*loggedInUser="gdake").*/m), is_a(Hash))
|
242
|
+
CnpOnlineRequest.new.credit(hash)
|
243
243
|
end
|
244
244
|
|
245
245
|
def test_secondary_amount_tied
|
246
246
|
hash = {
|
247
247
|
'amount' => '2',
|
248
248
|
'secondaryAmount' => '1',
|
249
|
-
'
|
249
|
+
'cnpTxnId' => '3',
|
250
250
|
'processingInstructions' => {},
|
251
251
|
'reportGroup' => 'Planets'
|
252
252
|
}
|
253
|
-
|
254
|
-
|
253
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><process.*/m), is_a(Hash))
|
254
|
+
CnpOnlineRequest.new.credit(hash)
|
255
255
|
end
|
256
256
|
|
257
257
|
def test_surcharge_amount_tied
|
258
258
|
hash = {
|
259
259
|
'amount' => '2',
|
260
260
|
'surchargeAmount' => '1',
|
261
|
-
'
|
261
|
+
'cnpTxnId' => '3',
|
262
262
|
'processingInstructions' => {},
|
263
263
|
'reportGroup' => 'Planets'
|
264
264
|
}
|
265
|
-
|
266
|
-
|
265
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><process.*/m), is_a(Hash))
|
266
|
+
CnpOnlineRequest.new.credit(hash)
|
267
267
|
end
|
268
268
|
|
269
269
|
def test_surcharge_amount_tied_optional
|
270
270
|
hash = {
|
271
271
|
'amount' => '2',
|
272
|
-
'
|
272
|
+
'cnpTxnId' => '3',
|
273
273
|
'processingInstructions' => {},
|
274
274
|
'reportGroup' => 'Planets'
|
275
275
|
}
|
276
|
-
|
277
|
-
|
276
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><process.*/m), is_a(Hash))
|
277
|
+
CnpOnlineRequest.new.credit(hash)
|
278
278
|
end
|
279
279
|
|
280
280
|
def test_secondary_amount_orphan
|
@@ -284,8 +284,8 @@ module LitleOnline
|
|
284
284
|
'orderSource' => 'ecommerce',
|
285
285
|
'reportGroup' => 'Planets'
|
286
286
|
}
|
287
|
-
|
288
|
-
|
287
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><secondaryAmount>1<\/secondaryAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
288
|
+
CnpOnlineRequest.new.credit(hash)
|
289
289
|
end
|
290
290
|
|
291
291
|
def test_surcharge_amount_orphan
|
@@ -295,8 +295,8 @@ module LitleOnline
|
|
295
295
|
'orderSource' => 'ecommerce',
|
296
296
|
'reportGroup' => 'Planets'
|
297
297
|
}
|
298
|
-
|
299
|
-
|
298
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><surchargeAmount>1<\/surchargeAmount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
299
|
+
CnpOnlineRequest.new.credit(hash)
|
300
300
|
end
|
301
301
|
|
302
302
|
def test_surcharge_amount_orphan_optional
|
@@ -305,8 +305,8 @@ module LitleOnline
|
|
305
305
|
'orderSource' => 'ecommerce',
|
306
306
|
'reportGroup' => 'Planets'
|
307
307
|
}
|
308
|
-
|
309
|
-
|
308
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<amount>2<\/amount><orderSource>ecommerce<\/orderSource>.*/m), is_a(Hash))
|
309
|
+
CnpOnlineRequest.new.credit(hash)
|
310
310
|
end
|
311
311
|
|
312
312
|
def test_pos_tied
|
@@ -319,22 +319,22 @@ module LitleOnline
|
|
319
319
|
'cardholderId' => 'nopin',
|
320
320
|
'catLevel' => 'self service'
|
321
321
|
},
|
322
|
-
'
|
322
|
+
'cnpTxnId' => '3',
|
323
323
|
'reportGroup' => 'Planets',
|
324
324
|
'orderSource' => 'ecommerce',
|
325
325
|
'payPalNotes' => 'notes'
|
326
326
|
}
|
327
|
-
|
328
|
-
|
327
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><pos><capability>magstripe<\/capability><entryMode>keyed<\/entryMode><cardholderId>nopin<\/cardholderId><terminalId>abc123<\/terminalId><catLevel>self service<\/catLevel><\/pos><payPalNotes>.*/m), is_a(Hash))
|
328
|
+
CnpOnlineRequest.new.credit(hash)
|
329
329
|
end
|
330
330
|
|
331
331
|
def test_post_tied_optional
|
332
332
|
hash = {
|
333
333
|
'amount' => '2',
|
334
|
-
'
|
334
|
+
'cnpTxnId' => '3',
|
335
335
|
}
|
336
|
-
|
337
|
-
|
336
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<cnpTxnId>3<\/cnpTxnId><amount>2<\/amount><\/credit>.*/m), is_a(Hash))
|
337
|
+
CnpOnlineRequest.new.credit(hash)
|
338
338
|
end
|
339
339
|
|
340
340
|
def test_pin
|
@@ -344,11 +344,11 @@ module LitleOnline
|
|
344
344
|
'reportGroup'=>'Planets',
|
345
345
|
'amount'=>'106',
|
346
346
|
'secondaryAmount'=>'20',
|
347
|
-
'
|
347
|
+
'cnpTxnId'=>'1234',
|
348
348
|
'pin'=>'3333'
|
349
349
|
}
|
350
|
-
|
351
|
-
|
350
|
+
CnpXmlMapper.expects(:request).with(regexp_matches(/.*<pin>3333<\/pin>.*/m), is_a(Hash))
|
351
|
+
CnpOnlineRequest.new.credit(hash)
|
352
352
|
end
|
353
353
|
|
354
354
|
end
|