LitleOnline 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/DESCRIPTION +5 -0
  2. data/LICENSE +22 -0
  3. data/README.md +69 -0
  4. data/Rakefile +92 -0
  5. data/SETUP.md +47 -0
  6. data/bin/Setup.rb +103 -0
  7. data/bin/sample_driver.rb +49 -0
  8. data/index.html +176 -0
  9. data/index.html.1 +176 -0
  10. data/lib/Checker.rb +56 -0
  11. data/lib/Communications.rb +85 -0
  12. data/lib/Configuration.rb +45 -0
  13. data/lib/LitleOnline.rb +52 -0
  14. data/lib/LitleOnlineRequest.rb +399 -0
  15. data/lib/LitleXmlMapper.rb +48 -0
  16. data/lib/Obj2xml.rb +37 -0
  17. data/lib/XMLFields.rb +378 -0
  18. data/test/certification/certTest1_base.rb +948 -0
  19. data/test/certification/certTest2_authenhanced.rb +571 -0
  20. data/test/certification/certTest3_authreversal.rb +184 -0
  21. data/test/certification/certTest4_echeck.rb +279 -0
  22. data/test/certification/certTest5_token.rb +222 -0
  23. data/test/certification/ts_all.rb +31 -0
  24. data/test/functional/test_auth.rb +135 -0
  25. data/test/functional/test_authReversal.rb +68 -0
  26. data/test/functional/test_capture.rb +71 -0
  27. data/test/functional/test_captureGivenAuth.rb +161 -0
  28. data/test/functional/test_credit.rb +154 -0
  29. data/test/functional/test_echeckCredit.rb +116 -0
  30. data/test/functional/test_echeckRedeposit.rb +78 -0
  31. data/test/functional/test_echeckSale.rb +157 -0
  32. data/test/functional/test_echeckVerification.rb +92 -0
  33. data/test/functional/test_forceCapture.rb +105 -0
  34. data/test/functional/test_sale.rb +198 -0
  35. data/test/functional/test_token.rb +102 -0
  36. data/test/functional/test_xmlfields.rb +403 -0
  37. data/test/functional/ts_all.rb +39 -0
  38. data/test/unit/test_Checker.rb +58 -0
  39. data/test/unit/test_LitleOnlineRequest.rb +288 -0
  40. data/test/unit/test_auth.rb +168 -0
  41. data/test/unit/test_authReversal.rb +41 -0
  42. data/test/unit/test_capture.rb +40 -0
  43. data/test/unit/test_captureGivenAuth.rb +108 -0
  44. data/test/unit/test_credit.rb +117 -0
  45. data/test/unit/test_echeckCredit.rb +45 -0
  46. data/test/unit/test_echeckRedeposit.rb +76 -0
  47. data/test/unit/test_echeckSale.rb +45 -0
  48. data/test/unit/test_echeckVerification.rb +75 -0
  49. data/test/unit/test_forceCapture.rb +122 -0
  50. data/test/unit/test_sale.rb +249 -0
  51. data/test/unit/test_token.rb +70 -0
  52. data/test/unit/test_xmlfields.rb +173 -0
  53. data/test/unit/ts_unit.rb +41 -0
  54. metadata +166 -0
@@ -0,0 +1,78 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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 'lib/LitleOnline'
26
+ require 'test/unit'
27
+
28
+ class Test_echeckRedeposit < Test::Unit::TestCase
29
+ def test_simple_echeckRedeposit
30
+ hash = {
31
+ 'merchantId' => '101',
32
+ 'version'=>'8.8',
33
+ 'reportGroup'=>'Planets',
34
+ 'litleTxnId'=>'123456'
35
+ }
36
+ response= LitleOnlineRequest.new.echeckRedeposit(hash)
37
+ assert_equal('Valid Format', response.message)
38
+ end
39
+
40
+ def test_echeckRedeposit_withecheck
41
+ hash = {
42
+ 'merchantId' => '101',
43
+ 'version'=>'8.8',
44
+ 'reportGroup'=>'Planets',
45
+ 'litleTxnId'=>'123456',
46
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
47
+ }
48
+ response= LitleOnlineRequest.new.echeckRedeposit(hash)
49
+ assert_equal('Valid Format', response.message)
50
+ end
51
+
52
+ def test_echeckRedeposit_withecheckToken
53
+ hash = {
54
+ 'merchantId' => '101',
55
+ 'version'=>'8.8',
56
+ 'reportGroup'=>'Planets',
57
+ 'litleTxnId'=>'123456',
58
+ 'echeckToken' => {'accType'=>'Checking','litleToken'=>'1234565789012','routingNum'=>'123456789','checkNum'=>'123455'}
59
+ }
60
+ response= LitleOnlineRequest.new.echeckRedeposit(hash)
61
+ assert_equal('Valid Format', response.message)
62
+ end
63
+
64
+ def test_extrafieldand_incorrectOrder
65
+ hash = {
66
+ 'merchantId' => '101',
67
+ 'version'=>'8.8',
68
+ 'reportGroup'=>'Planets',
69
+ 'invalidfield'=>'nonexistant',
70
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
71
+ 'litleTxnId'=>'123456'
72
+ }
73
+ response= LitleOnlineRequest.new.echeckRedeposit(hash)
74
+ assert_equal('Valid Format', response.message)
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,157 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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 'lib/LitleOnline'
26
+ require 'test/unit'
27
+
28
+ class Test_echeckSale < Test::Unit::TestCase
29
+ def test_echeckSalewithecheck
30
+ hash = {
31
+ 'merchantId' => '101',
32
+ 'version'=>'8.8',
33
+ 'reportGroup'=>'Planets',
34
+ 'amount'=>'123456',
35
+ 'verify'=>'true',
36
+ 'orderId'=>'12345',
37
+ 'orderSource'=>'ecommerce',
38
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
39
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
40
+ }
41
+ response= LitleOnlineRequest.new.echeckSale(hash)
42
+ assert_equal('Valid Format', response.message)
43
+ end
44
+
45
+ def test_noamount
46
+ hash = {
47
+ 'merchantId' => '101',
48
+ 'version'=>'8.8',
49
+ 'reportGroup'=>'Planets'
50
+ }
51
+ response = LitleOnlineRequest.new.echeckSale(hash)
52
+ assert_match /The content of element 'echeckSale' is not complete/, response.message
53
+ end
54
+
55
+ def test_echeckSalewithecheck
56
+ hash = {
57
+ 'merchantId' => '101',
58
+ 'version'=>'8.8',
59
+ 'reportGroup'=>'Planets',
60
+ 'amount'=>'123456',
61
+ 'verify'=>'true',
62
+ 'orderId'=>'12345',
63
+ 'orderSource'=>'ecommerce',
64
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
65
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
66
+ }
67
+ response= LitleOnlineRequest.new.echeckSale(hash)
68
+ assert_equal('Valid Format', response.message)
69
+ end
70
+
71
+ def test_echeckSalewith_shipto
72
+ hash = {
73
+ 'merchantId' => '101',
74
+ 'version'=>'8.8',
75
+ 'reportGroup'=>'Planets',
76
+ 'amount'=>'123456',
77
+ 'verify'=>'true',
78
+ 'orderId'=>'12345',
79
+ 'orderSource'=>'ecommerce',
80
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
81
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'},
82
+ 'shipToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
83
+ }
84
+ response= LitleOnlineRequest.new.echeckSale(hash)
85
+ assert_equal('Valid Format', response.message)
86
+ end
87
+
88
+ def test_echeckSale_withechecktoken
89
+ hash = {
90
+ 'merchantId' => '101',
91
+ 'version'=>'8.8',
92
+ 'reportGroup'=>'Planets',
93
+ 'amount'=>'123456',
94
+ 'verify'=>'true',
95
+ 'orderId'=>'12345',
96
+ 'orderSource'=>'ecommerce',
97
+ 'echeckToken' => {'accType'=>'Checking','litleToken'=>'1234565789012','routingNum'=>'123456789','checkNum'=>'123455'},
98
+ 'customBilling'=>{'phone'=>'123456789','descriptor'=>'good'},
99
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
100
+ }
101
+ response= LitleOnlineRequest.new.echeckSale(hash)
102
+ assert_equal('Valid Format', response.message)
103
+ end
104
+
105
+ def test_extrafieldand_incorrectOrder
106
+ hash = {
107
+ 'merchantId' => '101',
108
+ 'version'=>'8.8',
109
+ 'reportGroup'=>'Planets',
110
+ 'amount'=>'123',
111
+ 'invalidfield'=>'nonexistant',
112
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
113
+ 'verify'=>'true',
114
+ 'orderId'=>'12345',
115
+ 'orderSource'=>'ecommerce',
116
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
117
+ }
118
+ response= LitleOnlineRequest.new.echeckSale(hash)
119
+ assert_equal('Valid Format', response.message)
120
+ end
121
+
122
+ def test_extrafieldand_missingBilling
123
+ hash = {
124
+ 'merchantId' => '101',
125
+ 'version'=>'8.8',
126
+ 'reportGroup'=>'Planets',
127
+ 'amount'=>'123',
128
+ 'invalidfield'=>'nonexistant',
129
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
130
+ 'verify'=>'true',
131
+ 'orderId'=>'12345',
132
+ 'orderSource'=>'ecommerce',
133
+ }
134
+ response= LitleOnlineRequest.new.echeckSale(hash)
135
+ assert(response.message =~ /Error validating xml data against the schema/)
136
+ end
137
+ # def test_simple_echecksale
138
+ # hash = {
139
+ # 'reportGroup'=>'Planets',
140
+ # 'litleTxnId'=>'123456789101112',
141
+ # 'amount'=>'12'
142
+ # }
143
+ # response= LitleOnlineRequest.new.echeckSale(hash)
144
+ # assert_equal('Valid Format', response.message)
145
+ # end
146
+ # def test_simple_echeckSalewithCustombilling
147
+ # hash = {
148
+ # 'reportGroup'=>'Planets',
149
+ # 'litleTxnId'=>'123456',
150
+ # 'amount'=>'10',
151
+ # }
152
+ # response= LitleOnlineRequest.new.echeckSale(hash)
153
+ # assert_equal('Valid Format', response.message)
154
+ # end
155
+
156
+ end
157
+
@@ -0,0 +1,92 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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 'lib/LitleOnline'
26
+ require 'test/unit'
27
+
28
+ class Test_echeckVerification < Test::Unit::TestCase
29
+
30
+ def test_simple_echeckVerification
31
+ hash = {
32
+ 'merchantId' => '101',
33
+ 'version'=>'8.8',
34
+ 'reportGroup'=>'Planets',
35
+ 'amount'=>'123456',
36
+ 'orderId'=>'12345',
37
+ 'orderSource'=>'ecommerce',
38
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
39
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
40
+ }
41
+ response= LitleOnlineRequest.new.echeckVerification(hash)
42
+ assert_equal('Valid Format', response.message)
43
+ end
44
+
45
+ def test_echeckVerification_withechecktoken
46
+ hash = {
47
+ 'merchantId' => '101',
48
+ 'version'=>'8.8',
49
+ 'reportGroup'=>'Planets',
50
+ 'amount'=>'123456',
51
+ 'orderId'=>'12345',
52
+ 'orderSource'=>'ecommerce',
53
+ 'echeckToken' => {'accType'=>'Checking','litleToken'=>'1234565789012','routingNum'=>'123456789','checkNum'=>'123455'},
54
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
55
+ }
56
+ response= LitleOnlineRequest.new.echeckVerification(hash)
57
+ assert_equal('Valid Format', response.message)
58
+ end
59
+
60
+ def test_extrafieldand_incorrectOrder
61
+ hash = {
62
+ 'merchantId' => '101',
63
+ 'version'=>'8.8',
64
+ 'reportGroup'=>'Planets',
65
+ 'amount'=>'123',
66
+ 'invalidfield'=>'nonexistant',
67
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
68
+ 'orderId'=>'12345',
69
+ 'orderSource'=>'ecommerce',
70
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
71
+ }
72
+ response= LitleOnlineRequest.new.echeckVerification(hash)
73
+ assert_equal('Valid Format', response.message)
74
+ end
75
+
76
+ def test_extrafieldand_missingBilling
77
+ hash = {
78
+ 'merchantId' => '101',
79
+ 'version'=>'8.8',
80
+ 'reportGroup'=>'Planets',
81
+ 'amount'=>'123',
82
+ 'invalidfield'=>'nonexistant',
83
+ 'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
84
+ 'orderId'=>'12345',
85
+ 'orderSource'=>'ecommerce',
86
+ }
87
+ response= LitleOnlineRequest.new.echeckVerification(hash)
88
+ assert(response.message =~ /Error validating xml data against the schema/)
89
+ end
90
+
91
+ end
92
+
@@ -0,0 +1,105 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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 'lib/LitleOnline'
26
+ require 'test/unit'
27
+
28
+ class TestForceCapture < Test::Unit::TestCase
29
+ def test_simple_forceCapturewithCard
30
+ hash = {
31
+ 'merchantId' => '101',
32
+ 'version'=>'8.8',
33
+ 'reportGroup'=>'Planets',
34
+ 'litleTxnId'=>'123456',
35
+ 'orderId'=>'12344',
36
+ 'amount'=>'106',
37
+ 'orderSource'=>'ecommerce',
38
+ 'card'=>{
39
+ 'type'=>'VI',
40
+ 'number' =>'4100000000000001',
41
+ 'expDate' =>'1210'
42
+ }}
43
+ response= LitleOnlineRequest.new.forceCapture(hash)
44
+ assert_equal('000', response.forceCaptureResponse.response)
45
+ end
46
+
47
+ def test_simple_forceCapturewithtoken
48
+ hash = {
49
+ 'merchantId' => '101',
50
+ 'version'=>'8.8',
51
+ 'reportGroup'=>'Planets',
52
+ 'litleTxnId'=>'123456',
53
+ 'orderId'=>'12344',
54
+ 'amount'=>'106',
55
+ 'orderSource'=>'ecommerce',
56
+ 'token'=> {
57
+ 'litleToken'=>'123456789101112',
58
+ 'expDate'=>'1210',
59
+ 'cardValidationNum'=>'555',
60
+ 'type'=>'VI'
61
+ }}
62
+ response= LitleOnlineRequest.new.forceCapture(hash)
63
+ assert_equal('Valid Format', response.message)
64
+ end
65
+
66
+ def test_FieldsOutOfOrder
67
+ hash = {
68
+ 'merchantId' => '101',
69
+ 'version'=>'8.8',
70
+ 'orderSource'=>'ecommerce',
71
+ 'litleTxnId'=>'123456',
72
+ 'amount'=>'106',
73
+ 'card'=>{
74
+ 'type'=>'VI',
75
+ 'number' =>'4100000000000001',
76
+ 'expDate' =>'1210'
77
+ },
78
+ 'reportGroup'=>'Planets',
79
+ 'orderId'=>'12344'
80
+ }
81
+ response= LitleOnlineRequest.new.forceCapture(hash)
82
+ assert_equal('Valid Format', response.message)
83
+ end
84
+
85
+ def test_InvalidField
86
+ hash = {
87
+ 'merchantId' => '101',
88
+ 'version'=>'8.8',
89
+ 'reportGroup'=>'Planets',
90
+ 'litleTxnId'=>'123456',
91
+ 'orderId'=>'12344',
92
+ 'amount'=>'106',
93
+ 'orderSource'=>'ecommerce',
94
+ 'card'=>{
95
+ 'NOexistantField' => 'ShouldNotCauseError',
96
+ 'type'=>'VI',
97
+ 'number' =>'4100000000000001',
98
+ 'expDate' =>'1210'
99
+ }}
100
+ response= LitleOnlineRequest.new.forceCapture(hash)
101
+ assert_equal('Valid Format', response.message)
102
+ end
103
+
104
+ end
105
+
@@ -0,0 +1,198 @@
1
+ =begin
2
+ Copyright (c) 2012 Litle & Co.
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 'lib/LitleOnline'
26
+ require 'test/unit'
27
+
28
+ class TestSale < Test::Unit::TestCase
29
+ def test_simpleSalewithCard
30
+ hash = {
31
+ 'merchantId' => '101',
32
+ 'version'=>'8.8',
33
+ 'reportGroup'=>'Planets',
34
+ 'litleTxnId'=>'123456',
35
+ 'orderId'=>'12344',
36
+ 'amount'=>'106',
37
+ 'orderSource'=>'ecommerce',
38
+ 'card'=>{
39
+ 'type'=>'VI',
40
+ 'number' =>'4100000000000002',
41
+ 'expDate' =>'1210'
42
+ }}
43
+ response= LitleOnlineRequest.new.sale(hash)
44
+ assert_equal('000', response.saleResponse.response)
45
+ end
46
+
47
+ def test_simpleSalewithpaypal
48
+ hash = {
49
+ 'merchantId' => '101',
50
+ 'version'=>'8.8',
51
+ 'reportGroup'=>'Planets',
52
+ 'litleTxnId'=>'123456',
53
+ 'orderId'=>'12344',
54
+ 'amount'=>'106',
55
+ 'orderSource'=>'ecommerce',
56
+ 'paypal'=>{
57
+ 'payerId'=>'1234',
58
+ 'token'=>'1234',
59
+ 'transactionId'=>'123456'
60
+ }}
61
+ response= LitleOnlineRequest.new.sale(hash)
62
+ assert_equal 'Valid Format', response.message
63
+ end
64
+
65
+ def test_illegalorderSource
66
+ hash = {
67
+ 'merchantId' => '101',
68
+ 'version'=>'8.8',
69
+ 'reportGroup'=>'Planets',
70
+ 'litleTxnId'=>'123456',
71
+ 'orderId'=>'12344',
72
+ 'amount'=>'106',
73
+ 'orderSource'=>'ecomerce',
74
+ 'card'=>{
75
+ 'type'=>'VI',
76
+ 'number' =>'4100000000000002',
77
+ 'expDate' =>'1210'
78
+ }}
79
+ response= LitleOnlineRequest.new.sale(hash)
80
+ assert(response.message =~ /Error validating xml data against the schema/)
81
+ end
82
+
83
+ def test_illegalcardType
84
+ hash = {
85
+ 'merchantId' => '101',
86
+ 'version'=>'8.8',
87
+ 'reportGroup'=>'Planets',
88
+ 'litleTxnId'=>'123456',
89
+ 'orderId'=>'12344',
90
+ 'amount'=>'106',
91
+ 'orderSource'=>'ecommerce',
92
+ 'card'=>{
93
+ 'type'=>'NO',
94
+ 'number' =>'4100000000000002',
95
+ 'expDate' =>'1210'
96
+ }}
97
+ response= LitleOnlineRequest.new.sale(hash)
98
+ assert(response.message =~ /Error validating xml data against the schema/)
99
+ end
100
+
101
+ def test_noReportGroup
102
+ hash = {
103
+ 'merchantId' => '101',
104
+ 'version'=>'8.8',
105
+ 'reportGroup'=>'Planets',
106
+ 'litleTxnId'=>'123456',
107
+ 'orderId'=>'12344',
108
+ 'amount'=>'106',
109
+ 'orderSource'=>'ecommerce',
110
+ 'card'=>{
111
+ 'type'=>'VI',
112
+ 'number' =>'4100000000000002',
113
+ 'expDate' =>'1210'
114
+ }}
115
+ response= LitleOnlineRequest.new.sale(hash)
116
+ assert_equal('000', response.saleResponse.response)
117
+ end
118
+
119
+ def test_FieldsOutOfOrder
120
+ hash = {
121
+ 'merchantId' => '101',
122
+ 'version'=>'8.8',
123
+ 'orderSource'=>'ecommerce',
124
+ 'litleTxnId'=>'123456',
125
+ 'amount'=>'106',
126
+ 'card'=>{
127
+ 'type'=>'VI',
128
+ 'number' =>'4100000000000002',
129
+ 'expDate' =>'1210'
130
+ },
131
+ 'reportGroup'=>'Planets',
132
+ 'orderId'=>'12344'
133
+ }
134
+ response= LitleOnlineRequest.new.sale(hash)
135
+ assert_equal('000', response.saleResponse.response)
136
+ end
137
+
138
+ def test_InvalidField
139
+ hash = {
140
+ 'merchantId' => '101',
141
+ 'version'=>'8.8',
142
+ 'reportGroup'=>'Planets',
143
+ 'litleTxnId'=>'123456',
144
+ 'orderId'=>'12344',
145
+ 'amount'=>'106',
146
+ 'orderSource'=>'ecommerce',
147
+ 'card'=>{
148
+ 'NOexistantField' => 'ShouldNotCauseError',
149
+ 'type'=>'VI',
150
+ 'number' =>'4100000000000002',
151
+ 'expDate' =>'1210'
152
+ }}
153
+ response= LitleOnlineRequest.new.sale(hash)
154
+ assert_equal('000', response.saleResponse.response)
155
+ end
156
+
157
+ def test_InvalidEmbeddedFieldValues
158
+ #becasue there are sub fields under fraud check that are not specified
159
+ hash = {
160
+ 'merchantId' => '101',
161
+ 'version'=>'8.8',
162
+ 'reportGroup'=>'Planets',
163
+ 'litleTxnId'=>'123456',
164
+ 'orderId'=>'12344',
165
+ 'amount'=>'106',
166
+ 'orderSource'=>'ecommerce',
167
+ 'fraudCheck'=>'one',
168
+ 'cardholderAuthentication'=>'two',
169
+ 'card'=>{
170
+ 'type'=>'VI',
171
+ 'number' =>'4100000000000002',
172
+ }}
173
+ response= LitleOnlineRequest.new.sale(hash)
174
+ assert_equal('000', response.saleResponse.response)
175
+ end
176
+
177
+ def test_simpleSalewithCard
178
+ hash = {
179
+ 'merchantId'=>'101',
180
+ 'proxy_addr' => '10.1.2.254',
181
+ 'proxy_port' => '8080',
182
+ 'version'=>'8.8',
183
+ 'reportGroup'=>'Planets',
184
+ 'litleTxnId'=>'123456',
185
+ 'orderId'=>'12344',
186
+ 'amount'=>'106',
187
+ 'orderSource'=>'ecommerce',
188
+ 'card'=>{
189
+ 'type'=>'VI',
190
+ 'number' =>'4100000000000002',
191
+ 'expDate' =>'1210'
192
+ }}
193
+ response= LitleOnlineRequest.new.sale(hash)
194
+ assert_equal('000', response.saleResponse.response)
195
+ end
196
+
197
+ end
198
+