LitleOnline 8.12.3 → 8.12.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG +4 -0
  2. data/Rakefile +1 -1
  3. data/lib/Communications.rb +34 -32
  4. data/lib/Configuration.rb +13 -11
  5. data/lib/LitleOnline.rb +0 -1
  6. data/lib/LitleOnlineRequest.rb +546 -543
  7. data/lib/LitleXmlMapper.rb +17 -15
  8. data/lib/XMLFields.rb +903 -901
  9. data/test/certification/certTest1_base.rb +935 -933
  10. data/test/certification/certTest2_authenhanced.rb +548 -546
  11. data/test/certification/certTest3_authreversal.rb +179 -177
  12. data/test/certification/certTest4_echeck.rb +245 -243
  13. data/test/certification/certTest5_token.rb +198 -196
  14. data/test/functional/test_auth.rb +205 -204
  15. data/test/functional/test_authReversal.rb +41 -39
  16. data/test/functional/test_capture.rb +54 -52
  17. data/test/functional/test_captureGivenAuth.rb +153 -152
  18. data/test/functional/test_credit.rb +126 -126
  19. data/test/functional/test_echeckCredit.rb +88 -87
  20. data/test/functional/test_echeckRedeposit.rb +85 -84
  21. data/test/functional/test_echeckSale.rb +132 -131
  22. data/test/functional/test_echeckVerification.rb +97 -95
  23. data/test/functional/test_forceCapture.rb +113 -111
  24. data/test/functional/test_sale.rb +200 -198
  25. data/test/functional/test_token.rb +75 -73
  26. data/test/functional/test_xmlfields.rb +558 -558
  27. data/test/unit/test_LitleOnlineRequest.rb +210 -207
  28. data/test/unit/test_auth.rb +119 -116
  29. data/test/unit/test_authReversal.rb +16 -16
  30. data/test/unit/test_capture.rb +10 -8
  31. data/test/unit/test_captureGivenAuth.rb +62 -59
  32. data/test/unit/test_credit.rb +103 -100
  33. data/test/unit/test_echeckCredit.rb +15 -14
  34. data/test/unit/test_echeckRedeposit.rb +14 -13
  35. data/test/unit/test_echeckSale.rb +16 -15
  36. data/test/unit/test_echeckVerification.rb +14 -13
  37. data/test/unit/test_forceCapture.rb +61 -58
  38. data/test/unit/test_sale.rb +206 -205
  39. data/test/unit/test_token.rb +43 -41
  40. data/test/unit/test_xmlfields.rb +101 -99
  41. metadata +58 -77
  42. data/lib/Obj2xml.rb +0 -37
@@ -27,176 +27,199 @@ require 'lib/LitleOnlineRequest'
27
27
  require 'test/unit'
28
28
  require 'mocha'
29
29
 
30
- class Newtest < Test::Unit::TestCase
31
- def test_set_merchant_id
32
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}})
33
- litle = LitleOnlineRequest.new
34
- assert_equal '2', litle.send(:get_merchant_id, {'merchantId'=>'2'})
35
- assert_equal '1', litle.send(:get_merchant_id, {'NotMerchantId'=>'2'})
36
- end
37
-
38
- def test_simple
39
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
40
- hash = {
41
- 'reportGroup'=>'Planets',
42
- 'orderId'=>'12344',
43
- 'amount'=>'106',
44
- 'orderSource'=>'ecommerce',
45
- 'card'=>{
46
- 'type'=>'VI',
47
- 'number' =>'4100000000000001',
48
- 'expDate' =>'1210'
49
- }}
50
-
51
- Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest .*/m),kind_of(Hash))
52
- XMLObject.expects(:new)
53
-
54
- response = LitleOnlineRequest.new.authorization(hash)
55
- end
56
-
57
- def test_authorization_attributes
58
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
59
- hash={
60
- 'reportGroup'=>'Planets',
61
- 'id' => '003',
62
- 'orderId'=>'12344',
63
- 'amount'=>'106',
64
- 'orderSource'=>'ecommerce',
65
- 'card'=>{
66
- 'type'=>'VI',
67
- 'number' =>'4100000000000001',
68
- 'expDate' =>'1210'
69
- }}
70
-
71
- Communications.expects(:http_post).with(regexp_matches(/.*<authorization ((reportGroup="Planets" id="003")|(id="003" reportGroup="Planets")).*/m),kind_of(Hash))
72
- XMLObject.expects(:new)
73
-
74
- response = LitleOnlineRequest.new.authorization(hash)
75
- end
76
-
77
- def test_authorization_elements
78
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
79
- hash={
80
- 'reportGroup'=>'Planets',
81
- 'id' => '004',
82
- 'orderId'=>'12344',
83
- 'amount'=>'106',
84
- 'orderSource'=>'ecommerce',
85
- 'card'=>{
86
- 'type'=>'VI',
87
- 'number' =>'4100000000000001',
88
- 'expDate' =>'1210'
89
- }}
90
-
91
- Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<orderId>12344.*<amount>106.*<orderSource>ecommerce.*/m),kind_of(Hash))
92
- XMLObject.expects(:new)
93
-
94
- response = LitleOnlineRequest.new.authorization(hash)
95
- end
96
-
97
- def test_authorization_card_field
98
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
99
- hash={
100
- 'reportGroup'=>'Planets',
101
- 'id' => '005',
102
- 'orderId'=>'12344',
103
- 'amount'=>'106',
104
- 'orderSource'=>'ecommerce',
105
- 'card'=>{
106
- 'type'=>'VI',
107
- 'number' =>'4100000000000001',
108
- 'expDate' =>'1210'
109
- }}
110
-
111
- Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
112
- XMLObject.expects(:new)
113
-
114
- response = LitleOnlineRequest.new.authorization(hash)
115
- end
116
-
117
- def test_sale_card_field
118
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
119
- hash={
120
- 'reportGroup'=>'Planets',
121
- 'id' => '006',
122
- 'orderId'=>'12344',
123
- 'amount'=>'106',
124
- 'orderSource'=>'ecommerce',
125
- 'card'=>{
126
- 'type'=>'VI',
127
- 'number' =>'4100000000000001',
128
- 'expDate' =>'1210'
129
- }}
130
-
131
- Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*<sale.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
132
- XMLObject.expects(:new)
133
-
134
- response = LitleOnlineRequest.new.sale(hash)
135
- end
136
-
137
- def test_capture_amount_unset_should_not_be_in_xml
138
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
139
- hash={
140
- 'id' => '006',
141
- 'reportGroup'=>'Planets',
142
- 'litleTxnId'=>'123456789012345678',
143
- }
144
-
145
- Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
146
- XMLObject.expects(:new)
147
-
148
- response = LitleOnlineRequest.new.capture(hash)
149
- end
150
-
151
- def test_force_capture_amount_unset_should_not_be_in_xml
152
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
153
- hash={
154
- 'id' => '006',
155
- 'orderId'=>'12344',
156
- 'reportGroup'=>'Planets',
157
- 'orderSource'=>'ecommerce',
158
- 'litleTxnId'=>'123456789012345678',
159
- }
160
-
161
- Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
162
- XMLObject.expects(:new)
163
-
164
- response = LitleOnlineRequest.new.force_capture(hash)
165
- end
166
-
167
- def test_amount_is_not_required_in_echeck_credit
168
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
169
- hash={
170
- 'id' => '006',
171
- 'orderId'=>'12344',
172
- 'reportGroup'=>'Planets',
173
- 'orderSource'=>'ecommerce',
174
- 'litleTxnId'=>'123456789012345678',
175
- }
176
-
177
- Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
178
- XMLObject.expects(:new)
179
-
180
- response = LitleOnlineRequest.new.echeck_credit(hash)
181
- end
182
-
183
- def test_amount_is_not_required_in_echeck_sale
184
- Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
185
- hash={
186
- 'id' => '006',
187
- 'orderId'=>'12344',
188
- 'reportGroup'=>'Planets',
189
- 'orderSource'=>'ecommerce',
190
- 'litleTxnId'=>'123456789012345678',
191
- }
192
-
193
- Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
194
- XMLObject.expects(:new)
195
-
196
- response = LitleOnlineRequest.new.echeck_sale(hash)
197
- end
198
-
199
- def test_choice_between_card_token
30
+ module LitleOnline
31
+
32
+ class Newtest < Test::Unit::TestCase
33
+ def test_set_merchant_id
34
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}})
35
+ litle = LitleOnlineRequest.new
36
+ assert_equal '2', litle.send(:get_merchant_id, {'merchantId'=>'2'})
37
+ assert_equal '1', litle.send(:get_merchant_id, {'NotMerchantId'=>'2'})
38
+ end
39
+
40
+ def test_simple
41
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
42
+ hash = {
43
+ 'reportGroup'=>'Planets',
44
+ 'orderId'=>'12344',
45
+ 'amount'=>'106',
46
+ 'orderSource'=>'ecommerce',
47
+ 'card'=>{
48
+ 'type'=>'VI',
49
+ 'number' =>'4100000000000001',
50
+ 'expDate' =>'1210'
51
+ }}
52
+
53
+ Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest .*/m),kind_of(Hash))
54
+ XMLObject.expects(:new)
55
+
56
+ response = LitleOnlineRequest.new.authorization(hash)
57
+ end
58
+
59
+ def test_authorization_attributes
60
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
61
+ hash={
62
+ 'reportGroup'=>'Planets',
63
+ 'id' => '003',
64
+ 'orderId'=>'12344',
65
+ 'amount'=>'106',
66
+ 'orderSource'=>'ecommerce',
67
+ 'card'=>{
68
+ 'type'=>'VI',
69
+ 'number' =>'4100000000000001',
70
+ 'expDate' =>'1210'
71
+ }}
72
+
73
+ Communications.expects(:http_post).with(regexp_matches(/.*<authorization ((reportGroup="Planets" id="003")|(id="003" reportGroup="Planets")).*/m),kind_of(Hash))
74
+ XMLObject.expects(:new)
75
+
76
+ response = LitleOnlineRequest.new.authorization(hash)
77
+ end
78
+
79
+ def test_authorization_elements
80
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
81
+ hash={
82
+ 'reportGroup'=>'Planets',
83
+ 'id' => '004',
84
+ 'orderId'=>'12344',
85
+ 'amount'=>'106',
86
+ 'orderSource'=>'ecommerce',
87
+ 'card'=>{
88
+ 'type'=>'VI',
89
+ 'number' =>'4100000000000001',
90
+ 'expDate' =>'1210'
91
+ }}
92
+
93
+ Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<orderId>12344.*<amount>106.*<orderSource>ecommerce.*/m),kind_of(Hash))
94
+ XMLObject.expects(:new)
95
+
96
+ response = LitleOnlineRequest.new.authorization(hash)
97
+ end
98
+
99
+ def test_authorization_card_field
100
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
101
+ hash={
102
+ 'reportGroup'=>'Planets',
103
+ 'id' => '005',
104
+ 'orderId'=>'12344',
105
+ 'amount'=>'106',
106
+ 'orderSource'=>'ecommerce',
107
+ 'card'=>{
108
+ 'type'=>'VI',
109
+ 'number' =>'4100000000000001',
110
+ 'expDate' =>'1210'
111
+ }}
112
+
113
+ Communications.expects(:http_post).with(regexp_matches(/.*<authorization.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
114
+ XMLObject.expects(:new)
115
+
116
+ response = LitleOnlineRequest.new.authorization(hash)
117
+ end
118
+
119
+ def test_sale_card_field
120
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
121
+ hash={
122
+ 'reportGroup'=>'Planets',
123
+ 'id' => '006',
124
+ 'orderId'=>'12344',
125
+ 'amount'=>'106',
126
+ 'orderSource'=>'ecommerce',
127
+ 'card'=>{
128
+ 'type'=>'VI',
129
+ 'number' =>'4100000000000001',
130
+ 'expDate' =>'1210'
131
+ }}
132
+
133
+ Communications.expects(:http_post).with(regexp_matches(/<litleOnlineRequest.*<sale.*<card>.*<number>4100000000000001.*<expDate>1210.*/m),kind_of(Hash))
134
+ XMLObject.expects(:new)
135
+
136
+ response = LitleOnlineRequest.new.sale(hash)
137
+ end
138
+
139
+ def test_capture_amount_unset_should_not_be_in_xml
140
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
141
+ hash={
142
+ 'id' => '006',
143
+ 'reportGroup'=>'Planets',
144
+ 'litleTxnId'=>'123456789012345678',
145
+ }
146
+
147
+ Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
148
+ XMLObject.expects(:new)
149
+
150
+ response = LitleOnlineRequest.new.capture(hash)
151
+ end
152
+
153
+ def test_force_capture_amount_unset_should_not_be_in_xml
154
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
155
+ hash={
156
+ 'id' => '006',
157
+ 'orderId'=>'12344',
158
+ 'reportGroup'=>'Planets',
159
+ 'orderSource'=>'ecommerce',
160
+ 'litleTxnId'=>'123456789012345678',
161
+ }
162
+
163
+ Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
164
+ XMLObject.expects(:new)
165
+
166
+ response = LitleOnlineRequest.new.force_capture(hash)
167
+ end
168
+
169
+ def test_amount_is_not_required_in_echeck_credit
170
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
171
+ hash={
172
+ 'id' => '006',
173
+ 'orderId'=>'12344',
174
+ 'reportGroup'=>'Planets',
175
+ 'orderSource'=>'ecommerce',
176
+ 'litleTxnId'=>'123456789012345678',
177
+ }
178
+
179
+ Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
180
+ XMLObject.expects(:new)
181
+
182
+ response = LitleOnlineRequest.new.echeck_credit(hash)
183
+ end
184
+
185
+ def test_amount_is_not_required_in_echeck_sale
186
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'})
187
+ hash={
188
+ 'id' => '006',
189
+ 'orderId'=>'12344',
190
+ 'reportGroup'=>'Planets',
191
+ 'orderSource'=>'ecommerce',
192
+ 'litleTxnId'=>'123456789012345678',
193
+ }
194
+
195
+ Communications.expects(:http_post).with(Not(regexp_matches(/.*amount.*/m)),kind_of(Hash))
196
+ XMLObject.expects(:new)
197
+
198
+ response = LitleOnlineRequest.new.echeck_sale(hash)
199
+ end
200
+
201
+ def test_choice_between_card_token
202
+ start_hash = {
203
+ 'orderId'=>'12344',
204
+ 'merchantId'=>'101',
205
+ 'reportGroup'=>'Planets',
206
+ 'amount'=>'101',
207
+ 'orderSource'=>'ecommerce'
208
+ }
209
+
210
+ card_only = {
211
+ 'card' => {
212
+ 'type' => 'VI',
213
+ 'number' => '1111222233334444'
214
+ }
215
+ }
216
+
217
+ XMLObject.expects(:new)
218
+ Communications.expects(:http_post).with(regexp_matches(/.*card.*/m),kind_of(Hash))
219
+ LitleOnlineRequest.new.authorization(start_hash.merge(card_only))
220
+ end
221
+
222
+ def test_choice_between_card_token2
200
223
  start_hash = {
201
224
  'orderId'=>'12344',
202
225
  'merchantId'=>'101',
@@ -204,46 +227,26 @@ class Newtest < Test::Unit::TestCase
204
227
  'amount'=>'101',
205
228
  'orderSource'=>'ecommerce'
206
229
  }
207
-
208
- card_only = {
209
- 'card' => {
210
- 'type' => 'VI',
211
- 'number' => '1111222233334444'
230
+
231
+ token_only = {
232
+ 'token'=> {
233
+ 'litleToken' => '1111222233334444'
212
234
  }
213
235
  }
214
-
236
+
215
237
  XMLObject.expects(:new)
216
- Communications.expects(:http_post).with(regexp_matches(/.*card.*/m),kind_of(Hash))
217
- LitleOnlineRequest.new.authorization(start_hash.merge(card_only))
238
+ Communications.expects(:http_post).with(regexp_matches(/.*token.*/m),kind_of(Hash))
239
+ LitleOnlineRequest.new.authorization(start_hash.merge(token_only))
218
240
  end
219
241
 
220
- def test_choice_between_card_token2
221
- start_hash = {
222
- 'orderId'=>'12344',
223
- 'merchantId'=>'101',
224
- 'reportGroup'=>'Planets',
225
- 'amount'=>'101',
226
- 'orderSource'=>'ecommerce'
227
- }
228
-
229
- token_only = {
230
- 'token'=> {
231
- 'litleToken' => '1111222233334444'
232
- }
233
- }
234
-
235
- XMLObject.expects(:new)
236
- Communications.expects(:http_post).with(regexp_matches(/.*token.*/m),kind_of(Hash))
237
- LitleOnlineRequest.new.authorization(start_hash.merge(token_only))
238
- end
239
-
240
- def test_set_merchant_sdk
241
- litle = LitleOnlineRequest.new
242
- #Explicit - used for integrations
243
- assert_equal 'ActiveMerchant;3.2', litle.send(:get_merchant_sdk, {'merchantSdk'=>'ActiveMerchant;3.2'})
244
- #Implicit - used raw when nothing is specified
245
- assert_equal 'Ruby;8.12.3', litle.send(:get_merchant_sdk, {'NotMerchantSdk'=>'ActiveMerchant;3.2'})
246
- end
247
-
242
+ def test_set_merchant_sdk
243
+ litle = LitleOnlineRequest.new
244
+ #Explicit - used for integrations
245
+ assert_equal 'ActiveMerchant;3.2', litle.send(:get_merchant_sdk, {'merchantSdk'=>'ActiveMerchant;3.2'})
246
+ #Implicit - used raw when nothing is specified
247
+ assert_equal 'Ruby;8.12.4', litle.send(:get_merchant_sdk, {'NotMerchantSdk'=>'ActiveMerchant;3.2'})
248
+ end
248
249
 
249
- end
250
+
251
+ end
252
+ end
@@ -27,123 +27,126 @@ require 'test/unit'
27
27
  require 'mocha'
28
28
 
29
29
  #test Authorization Transaction
30
- class TestAuth < Test::Unit::TestCase
31
- def test_success_re_auth
32
- hash = {
33
- 'merchantId' => '101',
34
- 'version'=>'8.8',
35
- 'reportGroup'=>'Planets',
36
- 'litleTxnId'=>'123456'
37
- }
38
-
39
- LitleXmlMapper.expects(:request).with(regexp_matches(/.*<litleTxnId>123456<\/litleTxnId>.*/m), is_a(Hash))
40
- LitleOnlineRequest.new.authorization(hash)
41
- end
42
-
43
-
44
- def test_both_choices_card_and_paypal
45
- hash = {
46
- 'merchantId' => '101',
47
- 'version'=>'8.8',
48
- 'reportGroup'=>'Planets',
49
- 'orderId'=>'12344',
50
- 'amount'=>'106',
51
- 'orderSource'=>'ecommerce',
52
- 'card'=>{
53
- 'type'=>'VI',
54
- 'number' =>'4100000000000001',
55
- 'expDate' =>'1210'
56
- },
57
- 'paypal'=>{
58
- 'payerId'=>'1234',
59
- 'token'=>'1234',
60
- 'transactionId'=>'123456'
61
- }}
62
-
63
- exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
64
- assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
65
- end
66
-
67
- def test_three_choices_card_and_paypage_and_paypal
68
- hash = {
69
- 'merchantId' => '101',
70
- 'version'=>'8.8',
71
- 'reportGroup'=>'Planets',
72
- 'orderId'=>'12344',
73
- 'amount'=>'106',
74
- 'orderSource'=>'ecommerce',
75
- 'card'=>{
76
- 'type'=>'VI',
77
- 'number' =>'4100000000000001',
78
- 'expDate' =>'1210'
79
- },
80
- 'paypage'=> {
81
- 'paypageRegistrationId'=>'1234',
82
- 'expDate'=>'1210',
83
- 'cardValidationNum'=>'555',
84
- 'type'=>'VI'},
85
- 'paypal'=>{
86
- 'payerId'=>'1234',
87
- 'token'=>'1234',
88
- 'transactionId'=>'123456'
89
- }}
90
- exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
91
- assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
92
- end
93
-
94
- def test_all_choices_card_and_paypage_and_paypal_and_token
95
- hash = {
96
- 'merchantId' => '101',
97
- 'version'=>'8.8',
98
- 'reportGroup'=>'Planets',
99
- # 'litleTxnId'=>'123456',
100
- 'orderId'=>'12344',
101
- 'amount'=>'106',
102
- 'orderSource'=>'ecommerce',
103
- 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
104
- 'bypassVelocityCheckcardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
105
- 'card'=>{
106
- 'type'=>'VI',
107
- 'number' =>'4100000000000001',
108
- 'expDate' =>'1210'
109
- },
110
- 'paypage'=> {
111
- 'paypageRegistrationId'=>'1234',
112
- 'expDate'=>'1210',
113
- 'cardValidationNum'=>'555',
114
- 'type'=>'VI'},
115
- 'paypal'=>{
116
- 'payerId'=>'1234',
117
- 'token'=>'1234',
118
- 'transactionId'=>'123456'},
119
- 'token'=> {
120
- 'litleToken'=>'1234',
121
- 'expDate'=>'1210',
122
- 'cardValidationNum'=>'555',
123
- 'type'=>'VI'
124
- }}
125
-
126
- exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
127
- assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
128
- end
129
-
130
- def test_merchant_data_auth
131
- hash = {
132
- 'merchantId' => '101',
133
- 'version'=>'8.12',
134
- 'orderId'=>'1',
135
- 'amount'=>'0',
136
- 'orderSource'=>'ecommerce',
137
- 'reportGroup'=>'Planets',
138
- 'merchantData'=> {
139
- 'campaign'=>'foo'
30
+ module LitleOnline
31
+
32
+ class TestAuth < Test::Unit::TestCase
33
+ def test_success_re_auth
34
+ hash = {
35
+ 'merchantId' => '101',
36
+ 'version'=>'8.8',
37
+ 'reportGroup'=>'Planets',
38
+ 'litleTxnId'=>'123456'
140
39
  }
141
- }
142
40
 
143
- XMLObject.expects(:new)
144
- Communications.expects(:http_post).with(regexp_matches(/.*<merchantData>.*?<campaign>foo<\/campaign>.*?<\/merchantData>.*/m),kind_of(Hash))
145
- LitleOnlineRequest.new.authorization(hash)
146
- end
41
+ LitleXmlMapper.expects(:request).with(regexp_matches(/.*<litleTxnId>123456<\/litleTxnId>.*/m), is_a(Hash))
42
+ LitleOnlineRequest.new.authorization(hash)
43
+ end
44
+
45
+
46
+ def test_both_choices_card_and_paypal
47
+ hash = {
48
+ 'merchantId' => '101',
49
+ 'version'=>'8.8',
50
+ 'reportGroup'=>'Planets',
51
+ 'orderId'=>'12344',
52
+ 'amount'=>'106',
53
+ 'orderSource'=>'ecommerce',
54
+ 'card'=>{
55
+ 'type'=>'VI',
56
+ 'number' =>'4100000000000001',
57
+ 'expDate' =>'1210'
58
+ },
59
+ 'paypal'=>{
60
+ 'payerId'=>'1234',
61
+ 'token'=>'1234',
62
+ 'transactionId'=>'123456'
63
+ }}
64
+
65
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
66
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
67
+ end
147
68
 
148
- end
69
+ def test_three_choices_card_and_paypage_and_paypal
70
+ hash = {
71
+ 'merchantId' => '101',
72
+ 'version'=>'8.8',
73
+ 'reportGroup'=>'Planets',
74
+ 'orderId'=>'12344',
75
+ 'amount'=>'106',
76
+ 'orderSource'=>'ecommerce',
77
+ 'card'=>{
78
+ 'type'=>'VI',
79
+ 'number' =>'4100000000000001',
80
+ 'expDate' =>'1210'
81
+ },
82
+ 'paypage'=> {
83
+ 'paypageRegistrationId'=>'1234',
84
+ 'expDate'=>'1210',
85
+ 'cardValidationNum'=>'555',
86
+ 'type'=>'VI'},
87
+ 'paypal'=>{
88
+ 'payerId'=>'1234',
89
+ 'token'=>'1234',
90
+ 'transactionId'=>'123456'
91
+ }}
92
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
93
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
94
+ end
95
+
96
+ def test_all_choices_card_and_paypage_and_paypal_and_token
97
+ hash = {
98
+ 'merchantId' => '101',
99
+ 'version'=>'8.8',
100
+ 'reportGroup'=>'Planets',
101
+ # 'litleTxnId'=>'123456',
102
+ 'orderId'=>'12344',
103
+ 'amount'=>'106',
104
+ 'orderSource'=>'ecommerce',
105
+ 'fraudCheck'=>{'authenticationTransactionId'=>'123'},
106
+ 'bypassVelocityCheckcardholderAuthentication'=>{'authenticationTransactionId'=>'123'},
107
+ 'card'=>{
108
+ 'type'=>'VI',
109
+ 'number' =>'4100000000000001',
110
+ 'expDate' =>'1210'
111
+ },
112
+ 'paypage'=> {
113
+ 'paypageRegistrationId'=>'1234',
114
+ 'expDate'=>'1210',
115
+ 'cardValidationNum'=>'555',
116
+ 'type'=>'VI'},
117
+ 'paypal'=>{
118
+ 'payerId'=>'1234',
119
+ 'token'=>'1234',
120
+ 'transactionId'=>'123456'},
121
+ 'token'=> {
122
+ 'litleToken'=>'1234',
123
+ 'expDate'=>'1210',
124
+ 'cardValidationNum'=>'555',
125
+ 'type'=>'VI'
126
+ }}
127
+
128
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.authorization(hash)}
129
+ assert_match /Entered an Invalid Amount of Choices for a Field, please only fill out one Choice!!!!/, exception.message
130
+ end
131
+
132
+ def test_merchant_data_auth
133
+ hash = {
134
+ 'merchantId' => '101',
135
+ 'version'=>'8.12',
136
+ 'orderId'=>'1',
137
+ 'amount'=>'0',
138
+ 'orderSource'=>'ecommerce',
139
+ 'reportGroup'=>'Planets',
140
+ 'merchantData'=> {
141
+ 'campaign'=>'foo'
142
+ }
143
+ }
144
+
145
+ XMLObject.expects(:new)
146
+ Communications.expects(:http_post).with(regexp_matches(/.*<merchantData>.*?<campaign>foo<\/campaign>.*?<\/merchantData>.*/m),kind_of(Hash))
147
+ LitleOnlineRequest.new.authorization(hash)
148
+ end
149
+
150
+ end
149
151
 
152
+ end