LitleOnline 8.13.2 → 8.16.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.
data/CHANGELOG CHANGED
@@ -1,5 +1,22 @@
1
1
  = LitleOnline CHANGELOG
2
2
 
3
+ == Version 8.16.0 (March 29, 2013)
4
+
5
+ * Feature: Merged pull request #7 from pierre to add external logging support
6
+ * Feature: Add recyling to voidResponse
7
+ * Bugfix: Force the "version" attribute of a LitleOnlineRequest to be the major and minor version of the sdk submitting the transaction instead of using the value from the configuration file
8
+ * Bugfix: Add Connection: close header to reduce the chance of 403s from reaching the ip connection limit
9
+ * Bugfix: Merged pull request #5 from simeonwillbanks to fix a typo in sale when payPalOrderComplete is specified
10
+
11
+ == Version 8.15.0 (January 31, 2013)
12
+
13
+ * Feature: Add merchantData to echeck verifications and echeck redeposits
14
+
15
+ == Version 8.14.0 (January 31, 2013)
16
+
17
+ * Feature: Temporary storage of card validation num on tokens
18
+ * Feature: Updating card validation numbers on tokens
19
+
3
20
  == Version 8.13.2 (June 28, 2012)
4
21
 
5
22
  * Feature: Most schema validations are now handled by ruby code and throw errors.
@@ -0,0 +1,2 @@
1
+ Simeon Willbanks - https://github.com/LitleCo/litle-sdk-for-ruby/pull/5
2
+ Pierre-Alexandre Meyer - https://github.com/LitleCo/litle-sdk-for-ruby/pull/7
@@ -1,4 +1,4 @@
1
- Litle Online Ruby SDK created for version 8.13 of Litle XML online format, see the XSD schema for specific fields that are supported by this format.
1
+ Litle Online Ruby SDK created for version 8.16 of Litle XML online format, see the XSD schema for specific fields that are supported by this format.
2
2
 
3
3
  This gem contains an application interface in the Ruby programming language created by Litle & Co.
4
4
 
data/README.md CHANGED
@@ -65,6 +65,7 @@ puts "Litle Transaction ID: "+ response.saleResponse.litleTxnId
65
65
 
66
66
  Message: Valid Format
67
67
  Litle Transaction ID: <your-numeric-litle-txn-id>
68
-
68
+
69
+ More examples can be found here [Ruby Gists](https://gist.github.com/gists/search?q=Litle+Ruby+SDK&page=1)
69
70
 
70
71
  Please contact Lilte & Co. with any further questions. You can reach us at sdksupport@litle.com.
data/Rakefile CHANGED
@@ -30,11 +30,11 @@ require 'rake/clean'
30
30
  spec = Gem::Specification.new do |s|
31
31
  FileUtils.rm_rf('pkg')
32
32
  s.name = "LitleOnline"
33
- s.summary = "Ruby SDK produced by Litle & Co. for online transaction processing using Litle XML format v8.13"
33
+ s.summary = "Ruby SDK produced by Litle & Co. for online transaction processing using Litle XML format v8.16"
34
34
  s.description = File.read(File.join(File.dirname(__FILE__), 'DESCRIPTION'))
35
35
  s.requirements =
36
36
  [ 'Contact sdksupport@litle.com for more information' ]
37
- s.version = "8.13.2"
37
+ s.version = "8.16.0"
38
38
  s.author = "Litle & Co"
39
39
  s.email = "sdksupport@litle.com"
40
40
  s.homepage = "http://www.litle.com/developers"
data/SETUP.md CHANGED
@@ -40,8 +40,7 @@ Sample configuration file contents
40
40
  ```
41
41
  user: test_user
42
42
  password: test_password
43
- version: 8.13
44
- url: https://precert.litle.com/vap/communicator/online
43
+ url: https://www.testlitle.com/vap/communicator/online
45
44
  proxy_addr: yourproxyserver
46
45
  proxy_port: 8080
47
46
  ```
@@ -44,7 +44,6 @@ class Setup
44
44
  f.puts "currency_merchant_map:"
45
45
  f.puts " DEFAULT: " + gets
46
46
  f.puts "default_report_group: 'Default Report Group'"
47
- f.puts "version: '8.13'"
48
47
  puts "Please choose Litle url from the following list (example: 'cert') or directly input another URL: \nsandbox => https://www.testlitle.com/sandbox/communicator/online \ncert => https://cert.litle.com/vap/communicator/online \nprecert => https://precert.litle.com/vap/communicator/online \nproduction1 => https://payments.litle.com/vap/communicator/online \nproduction2 => https://payments2.litle.com/vap/communicator/online"
49
48
  f.puts "url: " + Setup.choice(gets)
50
49
  puts "Please input the proxy address, if no proxy hit enter key: "
@@ -49,12 +49,9 @@ module LitleOnline
49
49
  https.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
50
50
  end
51
51
  https.start { |http|
52
- response = http.request_post(url.path, post_data.to_s, {'Content-type'=>'text/xml'})
52
+ response = http.request_post(url.path, post_data.to_s, {'Content-Type'=>'text/xml','Connection'=>'close'})
53
53
  response_xml = response
54
54
  }
55
-
56
-
57
-
58
55
 
59
56
  # validate response, only an HTTP 200 will work, redirects are not followed
60
57
  case response_xml
@@ -30,6 +30,11 @@ require 'yaml'
30
30
  #
31
31
  module LitleOnline
32
32
  class Configuration
33
+ class << self
34
+ # External logger, if specified
35
+ attr_accessor :logger
36
+ end
37
+
33
38
  def config
34
39
  begin
35
40
  if !(ENV['LITLE_CONFIG_DIR'].nil?)
@@ -28,7 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE.
28
28
  # Defines the Gem
29
29
  #
30
30
  require 'rubygems'
31
- #require 'xmlsimple'
32
31
  require 'net/http'
33
32
  require 'xml-object'
34
33
  require 'yaml'
@@ -36,601 +36,282 @@ module LitleOnline
36
36
  #load configuration data
37
37
  @config_hash = Configuration.new.config
38
38
  end
39
-
40
- def authorization(hash_in)
41
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
42
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
43
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
44
-
45
- request = OnlineRequest.new
46
- authorization = Authorization.new
47
- authorization.reportGroup = get_report_group(hash_in)
48
- authorization.transactionId = hash_in['id']
49
- authorization.customerId = hash_in['customerId']
50
-
51
- authorization.litleTxnId = hash_in['litleTxnId']
52
- authorization.orderId = hash_in['orderId']
53
- authorization.amount = hash_in['amount']
54
- authorization.orderSource = hash_in['orderSource']
55
- authorization.customerInfo = CustomerInfo.from_hash(hash_in)
56
- authorization.billToAddress = Contact.from_hash(hash_in,'billToAddress')
57
- authorization.shipToAddress = Contact.from_hash(hash_in,'shipToAddress')
58
- authorization.card = Card.from_hash(hash_in)
59
- authorization.paypal = PayPal.from_hash(hash_in,'paypal')
60
- authorization.token = CardToken.from_hash(hash_in,'token')
61
- authorization.paypage = CardPaypage.from_hash(hash_in,'paypage')
62
- authorization.billMeLaterRequest = BillMeLaterRequest.from_hash(hash_in)
63
- authorization.cardholderAuthentication = FraudCheck.from_hash(hash_in)
64
- authorization.processingInstructions = ProcessingInstructions.from_hash(hash_in)
65
- authorization.pos = Pos.from_hash(hash_in)
66
- authorization.customBilling = CustomBilling.from_hash(hash_in)
67
- authorization.taxType = hash_in['taxType']
68
- authorization.enhancedData = EnhancedData.from_hash(hash_in)
69
- authorization.amexAggregatorData = AmexAggregatorData.from_hash(hash_in)
70
- authorization.allowPartialAuth = hash_in['allowPartialAuth']
71
- authorization.healthcareIIAS = HealthcareIIAS.from_hash(hash_in)
72
- authorization.filtering = Filtering.from_hash(hash_in)
73
- authorization.merchantData = MerchantData.from_hash(hash_in)
74
- authorization.recyclingRequest = RecyclingRequest.from_hash(hash_in)
75
- authorization.fraudFilterOverride = hash_in['fraudFilterOverride']
76
-
77
- request.authorization = authorization
78
-
79
- authentication = Authentication.new
80
- authentication.user = get_user(hash_in)
81
- authentication.password = get_password(hash_in)
82
- request.authentication = authentication
83
-
84
- request.merchantId = get_merchant_id(hash_in)
85
- request.version = get_version(hash_in)
86
- request.xmlns = "http://www.litle.com/schema"
87
- request.merchantSdk = get_merchant_sdk(hash_in)
88
-
89
- xml = request.save_to_xml.to_s
90
- LitleXmlMapper.request(xml, @config_hash)
39
+
40
+ def authorization(options)
41
+ transaction = Authorization.new
42
+ add_transaction_info(transaction, options)
43
+
44
+ commit(transaction, :authorization, options)
91
45
  end
92
-
93
- def sale(hash_in)
94
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
95
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
96
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
97
-
98
- request = OnlineRequest.new
99
- sale = Sale.new
100
- sale.reportGroup = get_report_group(hash_in)
101
- sale.transactionId = hash_in['id']
102
- sale.customerId = hash_in['customerId']
103
-
104
- sale.litleTxnId = hash_in['litleTxnId']
105
- sale.orderId = hash_in['orderId']
106
- sale.amount = hash_in['amount']
107
- sale.orderSource = hash_in['orderSource']
108
- sale.customerInfo = CustomerInfo.from_hash(hash_in)
109
- sale.billToAddress = Contact.from_hash(hash_in,'billToAddress')
110
- sale.shipToAddress = Contact.from_hash(hash_in,'shipToAddress')
111
- sale.card = Card.from_hash(hash_in)
112
- sale.paypal = PayPal.from_hash(hash_in,'paypal')
113
- sale.token = CardToken.from_hash(hash_in,'token')
114
- sale.paypage = CardPaypage.from_hash(hash_in,'paypage')
115
- sale.billMeLaterRequest = BillMeLaterRequest.from_hash(hash_in)
116
- sale.fraudCheck = FraudCheck.from_hash(hash_in,'fraudCheck')
117
- sale.cardholderAuthentication = FraudCheck.from_hash(hash_in,'cardholderAuthentication')
118
- sale.customBilling = CustomBilling.from_hash(hash_in)
119
- sale.taxType = hash_in['taxType']
120
- sale.enhancedData = EnhancedData.from_hash(hash_in)
121
- sale.processingInstructions = ProcessingInstructions.from_hash(hash_in)
122
- sale.pos = Pos.from_hash(hash_in)
123
- sale.payPalOrderComplete = hash_in['paPpalOrderComplete']
124
- sale.payPalNotes = hash_in['payPalNotes']
125
- sale.amexAggregatorData = AmexAggregatorData.from_hash(hash_in)
126
- sale.allowPartialAuth = hash_in['allowPartialAuth']
127
- sale.healthcareIIAS = HealthcareIIAS.from_hash(hash_in)
128
- sale.filtering = Filtering.from_hash(hash_in)
129
- sale.merchantData = MerchantData.from_hash(hash_in)
130
- sale.recyclingRequest = RecyclingRequest.from_hash(hash_in)
131
- sale.fraudFilterOverride = hash_in['fraudFilterOverride']
132
-
133
- request.sale = sale
134
-
135
- authentication = Authentication.new
136
- authentication.user = get_user(hash_in)
137
- authentication.password = get_password(hash_in)
138
- request.authentication = authentication
139
-
140
- request.merchantId = get_merchant_id(hash_in)
141
- request.version = get_version(hash_in)
142
- request.xmlns = "http://www.litle.com/schema"
143
- request.merchantSdk = get_merchant_sdk(hash_in)
144
-
145
- xml = request.save_to_xml.to_s
146
- LitleXmlMapper.request(xml, @config_hash)
46
+
47
+ def sale(options)
48
+ transaction = Sale.new
49
+ add_transaction_info(transaction, options)
50
+
51
+ transaction.fraudCheck = FraudCheck.from_hash(options,'fraudCheck')
52
+ transaction.payPalOrderComplete = options['payPalOrderComplete']
53
+ transaction.payPalNotes = options['payPalNotes']
54
+
55
+ commit(transaction, :sale, options)
147
56
  end
148
-
149
- def auth_reversal(hash_in)
150
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
151
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
152
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
153
-
154
- request = OnlineRequest.new
155
- auth_reversal = AuthReversal.new
156
- auth_reversal.reportGroup = get_report_group(hash_in)
157
- auth_reversal.transactionId = hash_in['id']
158
- auth_reversal.customerId = hash_in['customerId']
159
-
160
- auth_reversal.litleTxnId = hash_in['litleTxnId']
161
- auth_reversal.amount = hash_in['amount']
162
- auth_reversal.payPalNotes = hash_in['payPalNotes']
163
- auth_reversal.actionReason = hash_in['actionReason']
164
-
165
- request.authReversal = auth_reversal
166
-
167
- authentication = Authentication.new
168
- authentication.user = get_user(hash_in)
169
- authentication.password = get_password(hash_in)
170
- request.authentication = authentication
171
-
172
- request.merchantId = get_merchant_id(hash_in)
173
- request.version = get_version(hash_in)
174
- request.xmlns = "http://www.litle.com/schema"
175
- request.merchantSdk = get_merchant_sdk(hash_in)
176
-
177
- xml = request.save_to_xml.to_s
178
- LitleXmlMapper.request(xml, @config_hash)
57
+
58
+ def auth_reversal(options)
59
+ transaction = AuthReversal.new
60
+
61
+ transaction.litleTxnId = options['litleTxnId']
62
+ transaction.amount = options['amount']
63
+ transaction.payPalNotes = options['payPalNotes']
64
+ transaction.actionReason = options['actionReason']
65
+
66
+ commit(transaction, :authReversal, options)
179
67
  end
180
-
181
- def credit(hash_in)
182
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
183
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
184
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
185
-
186
- request = OnlineRequest.new
187
- credit = Credit.new
188
- credit.reportGroup = get_report_group(hash_in)
189
- credit.transactionId = hash_in['id']
190
- credit.customerId = hash_in['customerId']
191
-
192
- credit.litleTxnId = hash_in['litleTxnId']
193
- credit.orderId = hash_in['orderId']
194
- credit.amount = hash_in['amount']
195
- credit.orderSource = hash_in['orderSource']
196
- credit.billToAddress = Contact.from_hash(hash_in,'billToAddress')
197
- credit.card = Card.from_hash(hash_in)
198
- credit.paypal = CreditPayPal.from_hash(hash_in,'paypal')
199
- credit.token = CardToken.from_hash(hash_in,'token')
200
- credit.paypage = CardPaypage.from_hash(hash_in,'paypage')
201
- credit.customBilling = CustomBilling.from_hash(hash_in)
202
- credit.taxType = hash_in['taxType']
203
- credit.billMeLaterRequest = BillMeLaterRequest.from_hash(hash_in)
204
- credit.enhancedData = EnhancedData.from_hash(hash_in)
205
- credit.processingInstructions = ProcessingInstructions.from_hash(hash_in)
206
- credit.pos = Pos.from_hash(hash_in)
207
- credit.amexAggregatorData = AmexAggregatorData.from_hash(hash_in)
208
- credit.payPalNotes = hash_in['payPalNotes']
209
- credit.actionReason = hash_in['actionReason']
210
-
211
- request.credit = credit
212
-
213
- authentication = Authentication.new
214
- authentication.user = get_user(hash_in)
215
- authentication.password = get_password(hash_in)
216
- request.authentication = authentication
217
-
218
- request.merchantId = get_merchant_id(hash_in)
219
- request.version = get_version(hash_in)
220
- request.xmlns = "http://www.litle.com/schema"
221
- request.merchantSdk = get_merchant_sdk(hash_in)
222
-
223
- xml = request.save_to_xml.to_s
224
- LitleXmlMapper.request(xml, @config_hash)
68
+
69
+ def credit(options)
70
+ transaction = Credit.new
71
+ add_order_info(transaction, options)
72
+
73
+ transaction.litleTxnId = options['litleTxnId']
74
+ transaction.customBilling = CustomBilling.from_hash(options)
75
+ transaction.billMeLaterRequest = BillMeLaterRequest.from_hash(options)
76
+ transaction.payPalNotes = options['payPalNotes']
77
+ transaction.actionReason = options['actionReason']
78
+ transaction.paypal = CreditPayPal.from_hash(options,'paypal')
79
+
80
+ commit(transaction, :credit, options)
225
81
  end
226
-
227
- def register_token_request(hash_in)
228
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
229
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
230
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
231
-
232
- request = OnlineRequest.new
233
- token_request = RegisterTokenRequest.new
234
- token_request.reportGroup = get_report_group(hash_in)
235
- token_request.transactionId = hash_in['id']
236
- token_request.customerId = hash_in['customerId']
237
-
238
- token_request.orderId = hash_in['orderId']
239
- token_request.accountNumber = hash_in['accountNumber']
240
- token_request.echeckForToken = EcheckForToken.from_hash(hash_in)
241
- token_request.paypageRegistrationId = hash_in['paypageRegistrationId']
242
-
243
- request.registerTokenRequest = token_request
244
-
245
- authentication = Authentication.new
246
- authentication.user = get_user(hash_in)
247
- authentication.password = get_password(hash_in)
248
- request.authentication = authentication
249
-
250
- request.merchantId = get_merchant_id(hash_in)
251
- request.version = get_version(hash_in)
252
- request.xmlns = "http://www.litle.com/schema"
253
- request.merchantSdk = get_merchant_sdk(hash_in)
254
-
255
- xml = request.save_to_xml.to_s
256
- LitleXmlMapper.request(xml, @config_hash)
82
+
83
+ def register_token_request(options)
84
+ transaction = RegisterTokenRequest.new
85
+
86
+ transaction.orderId = options['orderId']
87
+ transaction.accountNumber = options['accountNumber']
88
+ transaction.echeckForToken = EcheckForToken.from_hash(options)
89
+ transaction.paypageRegistrationId = options['paypageRegistrationId']
90
+
91
+ commit(transaction, :registerTokenRequest, options)
257
92
  end
258
-
259
- def force_capture(hash_in)
260
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
261
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
262
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
263
-
264
- request = OnlineRequest.new
265
- force_capture = ForceCapture.new
266
- force_capture.reportGroup = get_report_group(hash_in)
267
- force_capture.transactionId = hash_in['id']
268
- force_capture.customerId = hash_in['customerId']
269
-
270
- force_capture.orderId = hash_in['orderId']
271
- force_capture.amount = hash_in['amount']
272
- force_capture.orderSource = hash_in['orderSource']
273
- force_capture.billToAddress = Contact.from_hash(hash_in,'billToAddress')
274
- force_capture.card = Card.from_hash(hash_in)
275
- force_capture.token = CardToken.from_hash(hash_in,'token')
276
- force_capture.paypage = CardPaypage.from_hash(hash_in,'paypage')
277
- force_capture.customBilling = CustomBilling.from_hash(hash_in)
278
- force_capture.taxType = hash_in['taxType']
279
- force_capture.enhancedData = EnhancedData.from_hash(hash_in)
280
- force_capture.processingInstructions = ProcessingInstructions.from_hash(hash_in)
281
- force_capture.pos = Pos.from_hash(hash_in)
282
- force_capture.amexAggregatorData = AmexAggregatorData.from_hash(hash_in)
283
-
284
- request.forceCapture = force_capture
93
+
94
+ def update_card_validation_num_on_token(options)
95
+ transaction = UpdateCardValidationNumOnToken.new
96
+
97
+ transaction.orderId = options['orderId']
98
+ transaction.litleToken = options['litleToken']
99
+ transaction.cardValidationNum = options['cardValidationNum']
285
100
 
286
- authentication = Authentication.new
287
- authentication.user = get_user(hash_in)
288
- authentication.password = get_password(hash_in)
289
- request.authentication = authentication
101
+ SchemaValidation.validate_length(transaction.litleToken, true, 13, 25, "updateCardValidationNumOnToken", "litleToken")
102
+ SchemaValidation.validate_length(transaction.cardValidationNum, true, 1, 4, "updateCardValidationNumOnToken", "cardValidationNum")
290
103
 
291
- request.merchantId = get_merchant_id(hash_in)
292
- request.version = get_version(hash_in)
293
- request.xmlns = "http://www.litle.com/schema"
294
- request.merchantSdk = get_merchant_sdk(hash_in)
295
-
296
- xml = request.save_to_xml.to_s
297
- LitleXmlMapper.request(xml, @config_hash)
104
+ commit(transaction, :updateCardValidationNumOnToken, options)
298
105
  end
299
-
300
- def capture(hash_in)
301
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
302
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
303
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
304
-
305
- request = OnlineRequest.new
306
- capture = Capture.new
307
- capture.reportGroup = get_report_group(hash_in)
308
- capture.transactionId = hash_in['id']
309
- capture.customerId = hash_in['customerId']
310
-
311
- capture.partial = hash_in['partial']
312
- capture.litleTxnId = hash_in['litleTxnId']
313
- capture.amount = hash_in['amount']
314
- capture.enhancedData = EnhancedData.from_hash(hash_in)
315
- capture.processingInstructions = ProcessingInstructions.from_hash(hash_in)
316
- capture.payPalOrderComplete = hash_in['payPalOrderComplete']
317
- capture.payPalNotes = hash_in['payPalNotes']
318
-
319
- request.captureTxn = capture
320
-
321
- authentication = Authentication.new
322
- authentication.user = get_user(hash_in)
323
- authentication.password = get_password(hash_in)
324
- request.authentication = authentication
325
-
326
- request.merchantId = get_merchant_id(hash_in)
327
- request.version = get_version(hash_in)
328
- request.xmlns = "http://www.litle.com/schema"
329
- request.merchantSdk = get_merchant_sdk(hash_in)
330
-
331
- xml = request.save_to_xml.to_s
332
- LitleXmlMapper.request(xml, @config_hash)
106
+
107
+ def force_capture(options)
108
+ transaction = ForceCapture.new
109
+ transaction.customBilling = CustomBilling.from_hash(options)
110
+
111
+ add_order_info(transaction, options)
112
+
113
+ commit(transaction, :forceCapture, options)
333
114
  end
334
-
335
- def capture_given_auth(hash_in)
336
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
337
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
338
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
339
-
340
- request = OnlineRequest.new
341
- capture_given_auth = CaptureGivenAuth.new
342
- capture_given_auth.reportGroup = get_report_group(hash_in)
343
- capture_given_auth.transactionId = hash_in['id']
344
- capture_given_auth.customerId = hash_in['customerId']
345
-
346
- capture_given_auth.orderId = hash_in['orderId']
347
- capture_given_auth.authInformation = AuthInformation.from_hash(hash_in)
348
- capture_given_auth.amount = hash_in['amount']
349
- capture_given_auth.orderSource = hash_in['orderSource']
350
- capture_given_auth.billToAddress = Contact.from_hash(hash_in,'billToAddress')
351
- capture_given_auth.shipToAddress = Contact.from_hash(hash_in,'shipToAddress')
352
- capture_given_auth.card = Card.from_hash(hash_in)
353
- capture_given_auth.token = CardToken.from_hash(hash_in,'token')
354
- capture_given_auth.paypage = CardPaypage.from_hash(hash_in,'paypage')
355
- capture_given_auth.customBilling = CustomBilling.from_hash(hash_in)
356
- capture_given_auth.taxType = hash_in['taxType']
357
- capture_given_auth.billMeLaterRequest = BillMeLaterRequest.from_hash(hash_in)
358
- capture_given_auth.enhancedData = EnhancedData.from_hash(hash_in)
359
- capture_given_auth.processingInstructions = ProcessingInstructions.from_hash(hash_in)
360
- capture_given_auth.pos = Pos.from_hash(hash_in)
361
- capture_given_auth.amexAggregatorData = AmexAggregatorData.from_hash(hash_in)
362
-
363
- request.captureGivenAuth = capture_given_auth
364
-
365
- authentication = Authentication.new
366
- authentication.user = get_user(hash_in)
367
- authentication.password = get_password(hash_in)
368
- request.authentication = authentication
369
-
370
- request.merchantId = get_merchant_id(hash_in)
371
- request.version = get_version(hash_in)
372
- request.xmlns = "http://www.litle.com/schema"
373
- request.merchantSdk = get_merchant_sdk(hash_in)
374
-
375
- xml = request.save_to_xml.to_s
376
- LitleXmlMapper.request(xml, @config_hash)
115
+
116
+ def capture(options)
117
+ transaction = Capture.new
118
+
119
+ transaction.partial = options['partial']
120
+ transaction.litleTxnId = options['litleTxnId']
121
+ transaction.amount = options['amount']
122
+ transaction.enhancedData = EnhancedData.from_hash(options)
123
+ transaction.processingInstructions = ProcessingInstructions.from_hash(options)
124
+ transaction.payPalOrderComplete = options['payPalOrderComplete']
125
+ transaction.payPalNotes = options['payPalNotes']
126
+
127
+ commit(transaction, :captureTxn, options)
377
128
  end
378
-
379
- def echeck_redeposit(hash_in)
380
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
381
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
382
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
383
-
384
- request = OnlineRequest.new
385
- echeck_redeposit = EcheckRedeposit.new
386
- echeck_redeposit.reportGroup = get_report_group(hash_in)
387
- echeck_redeposit.transactionId = hash_in['id']
388
- echeck_redeposit.customerId = hash_in['customerId']
389
-
390
- echeck_redeposit.litleTxnId = hash_in['litleTxnId']
391
- echeck_redeposit.echeck = Echeck.from_hash(hash_in)
392
- echeck_redeposit.echeckToken = EcheckToken.from_hash(hash_in)
393
-
394
- request.echeckRedeposit = echeck_redeposit
395
-
396
- authentication = Authentication.new
397
- authentication.user = get_user(hash_in)
398
- authentication.password = get_password(hash_in)
399
- request.authentication = authentication
400
-
401
- request.merchantId = get_merchant_id(hash_in)
402
- request.version = get_version(hash_in)
403
- request.xmlns = "http://www.litle.com/schema"
404
- request.merchantSdk = get_merchant_sdk(hash_in)
405
-
406
- xml = request.save_to_xml.to_s
407
- LitleXmlMapper.request(xml, @config_hash)
129
+
130
+ def capture_given_auth(options)
131
+ transaction = CaptureGivenAuth.new
132
+ add_order_info(transaction, options)
133
+
134
+ transaction.authInformation = AuthInformation.from_hash(options)
135
+ transaction.shipToAddress = Contact.from_hash(options,'shipToAddress')
136
+ transaction.customBilling = CustomBilling.from_hash(options)
137
+ transaction.billMeLaterRequest = BillMeLaterRequest.from_hash(options)
138
+
139
+ commit(transaction, :captureGivenAuth, options)
408
140
  end
409
-
410
- def echeck_sale(hash_in)
411
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
412
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
413
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
414
-
415
- request = OnlineRequest.new
416
- echeck_sale = EcheckSale.new
417
- echeck_sale.reportGroup = get_report_group(hash_in)
418
- echeck_sale.transactionId = hash_in['id']
419
- echeck_sale.customerId = hash_in['customerId']
420
-
421
- echeck_sale.litleTxnId = hash_in['litleTxnId']
422
- echeck_sale.orderId = hash_in['orderId']
423
- echeck_sale.verify = hash_in['verify']
424
- echeck_sale.amount = hash_in['amount']
425
- echeck_sale.orderSource = hash_in['orderSource']
426
- echeck_sale.billToAddress = Contact.from_hash(hash_in,'billToAddress')
427
- echeck_sale.shipToAddress = Contact.from_hash(hash_in,'shipToAddress')
428
- echeck_sale.echeck = Echeck.from_hash(hash_in)
429
- echeck_sale.echeckToken = EcheckToken.from_hash(hash_in)
430
- echeck_sale.customBilling = CustomBilling.from_hash(hash_in)
431
-
432
- request.echeckSale = echeck_sale
433
-
434
- authentication = Authentication.new
435
- authentication.user = get_user(hash_in)
436
- authentication.password = get_password(hash_in)
437
- request.authentication = authentication
438
-
439
- request.merchantId = get_merchant_id(hash_in)
440
- request.version = get_version(hash_in)
441
- request.xmlns = "http://www.litle.com/schema"
442
- request.merchantSdk = get_merchant_sdk(hash_in)
443
-
444
- xml = request.save_to_xml.to_s
445
- LitleXmlMapper.request(xml, @config_hash)
141
+
142
+ def void(options)
143
+ transaction = Void.new
144
+
145
+ transaction.litleTxnId = options['litleTxnId']
146
+ transaction.processingInstructions = ProcessingInstructions.from_hash(options)
147
+
148
+ commit(transaction, :void, options)
446
149
  end
447
-
448
- def echeck_credit(hash_in)
449
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
450
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
451
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
452
-
453
- request = OnlineRequest.new
454
- echeck_credit = EcheckCredit.new
455
- echeck_credit.reportGroup = get_report_group(hash_in)
456
- echeck_credit.transactionId = hash_in['id']
457
- echeck_credit.customerId = hash_in['customerId']
458
-
459
- echeck_credit.litleTxnId = hash_in['litleTxnId']
460
- echeck_credit.orderId = hash_in['orderId']
461
- echeck_credit.amount = hash_in['amount']
462
- echeck_credit.orderSource = hash_in['orderSource']
463
- echeck_credit.billToAddress = Contact.from_hash(hash_in,'billToAddress')
464
- echeck_credit.echeck = Echeck.from_hash(hash_in)
465
- echeck_credit.echeckToken = EcheckToken.from_hash(hash_in)
466
- echeck_credit.customBilling = CustomBilling.from_hash(hash_in)
467
-
468
- request.echeckCredit = echeck_credit
469
-
470
- authentication = Authentication.new
471
- authentication.user = get_user(hash_in)
472
- authentication.password = get_password(hash_in)
473
- request.authentication = authentication
474
-
475
- request.merchantId = get_merchant_id(hash_in)
476
- request.version = get_version(hash_in)
477
- request.xmlns = "http://www.litle.com/schema"
478
- request.merchantSdk = get_merchant_sdk(hash_in)
479
-
150
+
151
+ def echeck_redeposit(options)
152
+ transaction = EcheckRedeposit.new
153
+ add_echeck(transaction, options)
154
+
155
+ transaction.litleTxnId = options['litleTxnId']
156
+ transaction.merchantData = MerchantData.from_hash(options)
157
+
158
+ commit(transaction, :echeckRedeposit, options)
159
+ end
160
+
161
+ def echeck_sale(options)
162
+ transaction = EcheckSale.new
163
+ add_echeck(transaction, options)
164
+ add_echeck_order_info(transaction, options)
165
+
166
+ transaction.verify = options['verify']
167
+ transaction.shipToAddress = Contact.from_hash(options,'shipToAddress')
168
+ transaction.customBilling = CustomBilling.from_hash(options)
169
+
170
+ commit(transaction, :echeckSale, options)
171
+ end
172
+
173
+ def echeck_credit(options)
174
+ transaction = EcheckCredit.new
175
+ transaction.customBilling = CustomBilling.from_hash(options)
176
+
177
+ add_echeck_order_info(transaction, options)
178
+ add_echeck(transaction, options)
179
+
480
180
  begin
481
- xml = request.save_to_xml.to_s
181
+ commit(transaction, :echeckCredit, options)
482
182
  rescue XML::MappingError => e
483
183
  puts e
484
184
  response = LitleOnlineResponse.new
485
- response.message = "The content of element 'echeckCredit' is not complete"
185
+ response.message = "The content of element 'echeckCredit' is not complete"
486
186
  return response
487
187
  end
488
- LitleXmlMapper.request(xml, @config_hash)
489
188
  end
490
-
491
- def echeck_verification(hash_in)
492
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
493
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
494
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
495
-
496
- request = OnlineRequest.new
497
- echeck_verification = EcheckVerification.new
498
- echeck_verification.reportGroup = get_report_group(hash_in)
499
- echeck_verification.transactionId = hash_in['id']
500
- echeck_verification.customerId = hash_in['customerId']
501
-
502
- echeck_verification.litleTxnId = hash_in['litleTxnId']
503
- echeck_verification.orderId = hash_in['orderId']
504
- echeck_verification.amount = hash_in['amount']
505
- echeck_verification.orderSource = hash_in['orderSource']
506
- echeck_verification.billToAddress = Contact.from_hash(hash_in,'billToAddress')
507
- echeck_verification.echeck = Echeck.from_hash(hash_in)
508
- echeck_verification.echeckToken = EcheckToken.from_hash(hash_in)
509
-
510
- request.echeckVerification = echeck_verification
511
-
512
- authentication = Authentication.new
513
- authentication.user = get_user(hash_in)
514
- authentication.password = get_password(hash_in)
515
- request.authentication = authentication
189
+
190
+ def echeck_verification(options)
191
+ transaction = EcheckVerification.new
192
+
193
+ add_echeck_order_info(transaction, options)
194
+ add_echeck(transaction, options)
195
+ transaction.merchantData = MerchantData.from_hash(options)
516
196
 
517
- request.merchantId = get_merchant_id(hash_in)
518
- request.version = get_version(hash_in)
519
- request.xmlns = "http://www.litle.com/schema"
520
- request.merchantSdk = get_merchant_sdk(hash_in)
521
-
522
- xml = request.save_to_xml.to_s
523
- LitleXmlMapper.request(xml, @config_hash)
197
+
198
+ commit(transaction, :echeckVerification, options)
524
199
  end
525
-
526
- def void(hash_in)
527
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
528
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
529
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
530
-
531
- request = OnlineRequest.new
532
- void = Void.new
533
- void.reportGroup = get_report_group(hash_in)
534
- void.transactionId = hash_in['id']
535
- void.customerId = hash_in['customerId']
536
-
537
- void.litleTxnId = hash_in['litleTxnId']
538
- void.processingInstructions = ProcessingInstructions.from_hash(hash_in)
539
-
540
- request.void = void
541
-
542
- authentication = Authentication.new
543
- authentication.user = get_user(hash_in)
544
- authentication.password = get_password(hash_in)
545
- request.authentication = authentication
546
-
547
- request.merchantId = get_merchant_id(hash_in)
548
- request.version = get_version(hash_in)
549
- request.xmlns = "http://www.litle.com/schema"
550
- request.merchantSdk = get_merchant_sdk(hash_in)
551
-
552
- xml = request.save_to_xml.to_s
553
- LitleXmlMapper.request(xml, @config_hash)
200
+
201
+ def echeck_void(options)
202
+ transaction = EcheckVoid.new
203
+ transaction.litleTxnId = options['litleTxnId']
204
+
205
+ commit(transaction, :echeckVoid, options)
554
206
  end
555
-
556
- def echeck_void(hash_in)
557
- @config_hash['proxy_addr'] = hash_in['proxy_addr'].nil? ? @config_hash['proxy_addr'] : hash_in['proxy_addr']
558
- @config_hash['proxy_port'] = hash_in['proxy_port'].nil? ? @config_hash['proxy_port'] : hash_in['proxy_port']
559
- @config_hash['url'] = hash_in['url'].nil? ? @config_hash['url'] : hash_in['url']
560
-
207
+
208
+ private
209
+
210
+ def add_account_info(transaction, options)
211
+ transaction.reportGroup = get_report_group(options)
212
+ transaction.transactionId = options['id']
213
+ transaction.customerId = options['customerId']
214
+ end
215
+
216
+ def add_transaction_info(transaction, options)
217
+ transaction.litleTxnId = options['litleTxnId']
218
+ transaction.customerInfo = CustomerInfo.from_hash(options)
219
+ transaction.shipToAddress = Contact.from_hash(options,'shipToAddress')
220
+ transaction.billMeLaterRequest = BillMeLaterRequest.from_hash(options)
221
+ transaction.cardholderAuthentication = FraudCheck.from_hash(options)
222
+ transaction.allowPartialAuth = options['allowPartialAuth']
223
+ transaction.healthcareIIAS = HealthcareIIAS.from_hash(options)
224
+ transaction.filtering = Filtering.from_hash(options)
225
+ transaction.merchantData = MerchantData.from_hash(options)
226
+ transaction.recyclingRequest = RecyclingRequest.from_hash(options)
227
+ transaction.fraudFilterOverride = options['fraudFilterOverride']
228
+ transaction.customBilling = CustomBilling.from_hash(options)
229
+ transaction.paypal = PayPal.from_hash(options,'paypal')
230
+
231
+ add_order_info(transaction, options)
232
+ end
233
+
234
+ def add_order_info(transaction, options)
235
+ transaction.amount = options['amount']
236
+ transaction.orderId = options['orderId']
237
+ transaction.orderSource = options['orderSource']
238
+ transaction.taxType = options['taxType']
239
+ transaction.billToAddress = Contact.from_hash(options,'billToAddress')
240
+ transaction.enhancedData = EnhancedData.from_hash(options)
241
+ transaction.processingInstructions = ProcessingInstructions.from_hash(options)
242
+ transaction.pos = Pos.from_hash(options)
243
+ transaction.amexAggregatorData = AmexAggregatorData.from_hash(options)
244
+ transaction.card = Card.from_hash(options)
245
+ transaction.token = CardToken.from_hash(options,'token')
246
+ transaction.paypage = CardPaypage.from_hash(options,'paypage')
247
+ end
248
+
249
+ def add_echeck_order_info(transaction, options)
250
+ transaction.litleTxnId = options['litleTxnId']
251
+ transaction.orderId = options['orderId']
252
+ transaction.amount = options['amount']
253
+ transaction.orderSource = options['orderSource']
254
+ transaction.billToAddress = Contact.from_hash(options,'billToAddress')
255
+ end
256
+
257
+ def add_echeck(transaction, options)
258
+ transaction.echeck = Echeck.from_hash(options)
259
+ transaction.echeckToken = EcheckToken.from_hash(options)
260
+ end
261
+
262
+ def build_request(options)
561
263
  request = OnlineRequest.new
562
- void = EcheckVoid.new
563
- void.reportGroup = get_report_group(hash_in)
564
- void.transactionId = hash_in['id']
565
- void.customerId = hash_in['customerId']
566
-
567
- void.litleTxnId = hash_in['litleTxnId']
568
-
569
- request.echeckVoid = void
570
-
264
+
571
265
  authentication = Authentication.new
572
- authentication.user = get_user(hash_in)
573
- authentication.password = get_password(hash_in)
574
- request.authentication = authentication
575
-
576
- request.merchantId = get_merchant_id(hash_in)
577
- request.version = get_version(hash_in)
578
- request.xmlns = "http://www.litle.com/schema"
579
- request.merchantSdk = get_merchant_sdk(hash_in)
580
-
266
+ authentication.user = get_config(:user, options)
267
+ authentication.password = get_config(:password, options)
268
+
269
+ request.authentication = authentication
270
+ request.merchantId = get_merchant_id(options)
271
+ request.version = '8.16'
272
+ request.loggedInUser = get_logged_in_user(options)
273
+ request.xmlns = "http://www.litle.com/schema"
274
+ request.merchantSdk = get_merchant_sdk(options)
275
+
276
+ request
277
+ end
278
+
279
+ def commit(transaction, type, options)
280
+ configure_connection(options)
281
+
282
+ request = build_request(options)
283
+
284
+ add_account_info(transaction, options)
285
+ request.send(:"#{type}=", transaction)
286
+
581
287
  xml = request.save_to_xml.to_s
582
288
  LitleXmlMapper.request(xml, @config_hash)
583
289
  end
584
290
 
585
-
586
- private
587
-
588
- def get_merchant_id(hash_in)
589
- if (hash_in['merchantId'] == nil)
590
- return @config_hash['currency_merchant_map']['DEFAULT']
591
- else
592
- return hash_in['merchantId']
593
- end
291
+ def configure_connection(options={})
292
+ @config_hash['proxy_addr'] = options['proxy_addr'] unless options['proxy_addr'].nil?
293
+ @config_hash['proxy_port'] = options['proxy_port'] unless options['proxy_port'].nil?
294
+ @config_hash['url'] = options['url'] unless options['url'].nil?
594
295
  end
595
-
596
- def get_version(hash_in)
597
- if (hash_in['version'] == nil)
598
- return @config_hash['version']
599
- else
600
- return hash_in['version']
601
- end
296
+
297
+ def get_merchant_id(options)
298
+ options['merchantId'] || @config_hash['currency_merchant_map']['DEFAULT']
602
299
  end
603
-
604
- def get_merchant_sdk(hash_in)
605
- if(!hash_in['merchantSdk'])
606
- return 'Ruby;8.13.2'
607
- else
608
- return hash_in['merchantSdk']
609
- end
300
+
301
+ def get_merchant_sdk(options)
302
+ options['merchantSdk'] || 'Ruby;8.16.0'
610
303
  end
611
-
612
- def get_report_group(hash_in)
613
- if (!hash_in['reportGroup'])
614
- return @config_hash['default_report_group']
615
- else
616
- return hash_in['reportGroup']
617
- end
304
+
305
+ def get_report_group(options)
306
+ options['reportGroup'] || @config_hash['default_report_group']
618
307
  end
619
-
620
- def get_user(hash_in)
621
- if (hash_in['user'] == nil)
622
- return @config_hash['user']
623
- else
624
- return hash_in['user']
625
- end
308
+
309
+ def get_config(field, options)
310
+ options[field.to_s] == nil ? @config_hash[field.to_s] : options[field.to_s]
626
311
  end
627
312
 
628
- def get_password(hash_in)
629
- if (hash_in['password'] == nil)
630
- return @config_hash['password']
631
- else
632
- return hash_in['password']
633
- end
313
+ def get_logged_in_user(options)
314
+ options['loggedInUser'] || nil
634
315
  end
635
316
  end
636
- end
317
+ end