LitleOnline 9.3.0 → 9.3.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjA0NmZkY2RjYzk5ZGVjZjY1NDE4N2MxZjBjMzE1ZWVhNzU1YWU0OA==
4
+ ODVmZTNmOTY5YmQ2MjEwNmY3NmU3MTJkYmVmNDYzMDYyNTQ2ZmZlNA==
5
5
  data.tar.gz: !binary |-
6
- YTk3ODYwODdhZjJmODIyZjIwNDRmMjkyNjY0OTUzM2UxZWRmYTFlYQ==
6
+ MWE0MTBhMWVhODk5NmZiZTM2ODk2Zjk1MGFjMjM0ZDY5ZDkzYzRmZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjI5OGQ1ZWJmMjkyOTI2N2EzZTY0OTBlYzgzZjRhYzAxOGQwN2JjOTgzM2M3
10
- Y2ZmZGI2NDIxMzdkNzliOTg5YzM2NzNjOTY3YTYzN2YxZWUwMmUyODRkYjU3
11
- OGJiYjI3Y2U0ODczNWJlYjBlZGZjZDAwNmMyOTBkYzZlNGZjNjI=
9
+ OTRkYzE5YTQ1YzllODk4MWY1ZWMwMTBhMzkxYzBhMDI2M2Q3MzhjYjdkODFk
10
+ YTFkNTA4NjNiYmVhZTM5ZTI1ZmE4YTg2MTM3ZWIyZDU0YmM3ZGRkOTcyYTg0
11
+ OWExOGM3N2VhMjg5YmJkNzM4ZTAyMWMzMDYzMTJlOWQ2MWM5ZGI=
12
12
  data.tar.gz: !binary |-
13
- MjkwMjhmODZhYzZlZDE4OThjNGZjNzRiMDI1YTQ0OTNhZWY0YzNjNWE4N2I4
14
- ZGU4ZGQ5MWY3MTgxMTM4NjU2ODgzZTU0MzA3ODdjZjA1MmVlZDhjMWNmOWJh
15
- MGUxODlkNDhhMjRiNTUzODNjNmI1YmY2YzQ5YTkxMjcwZjI5OTM=
13
+ YTZmZjNlOTU5YjNhZmE1YjhmM2YyN2NmZmRiN2U4YzdlOTNlMGFiOGVkZGNh
14
+ MGU2MGY3NjMxMzM5MTIzZmNiMjc0MGIxYTU2ZTk3NjkzYTY2NThlYzA5ZGY1
15
+ NTMzMmI4Y2JjOTc2MWEyNGFjOTcwYWM4YTc3ODJlZjRjZmU4ZDg=
data/CHANGELOG CHANGED
@@ -1,11 +1,14 @@
1
1
  = LitleOnline CHANGELOG
2
2
 
3
- == Version 9.03.0
3
+ ==Version 9.3.1 (March 9, 2015)
4
+ *Feature: PFIF instruction transaction support was added
5
+
6
+ == Version 9.3.0
4
7
  * Feature: Applepay support was added
5
8
  * Feature: Secondary amount support was added
6
9
  * Feature: Add support for new Batch transaction in version 9.3 schema
7
10
 
8
- == Version 9.00.0 (August 27,2014)
11
+ == Version 9.0.0 (August 27,2014)
9
12
  * Feature: Add support for new element in version 9 schema
10
13
 
11
14
  == Version 8.27.0 (August 27,2014)
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
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 = "9.3.0"
37
+ s.version = "9.3.1"
38
38
  s.author = "Litle & Co"
39
39
  s.email = "sdksupport@litle.com"
40
40
  s.homepage = "http://www.litle.com/developers"
@@ -41,7 +41,7 @@ module LitleOnline
41
41
  # setup https or http post
42
42
  url = URI.parse(litle_url)
43
43
 
44
- response_xml = nil
44
+ response_xml = nil
45
45
  https = Net::HTTP.new(url.host, url.port, proxy_addr, proxy_port)
46
46
  if(url.scheme == 'https')
47
47
  https.use_ssl = url.scheme=='https'
@@ -30,42 +30,51 @@ require_relative 'Configuration'
30
30
  # to Litle.
31
31
  #
32
32
  module LitleOnline
33
-
34
33
  class LitleBatchRequest
35
34
  include XML::Mapping
36
- def initialize
35
+ def initialize ()
37
36
  #load configuration data
38
37
  @config_hash = Configuration.new.config
39
-
38
+
40
39
  @txn_counts = { :id=>nil,
41
- :merchantId=>nil,
42
- :auth=>{ :numAuths=>0, :authAmount=>0 },
43
- :sale=>{ :numSales=>0, :saleAmount=>0 },
44
- :credit=>{ :numCredits=>0, :creditAmount=>0 },
45
- :numTokenRegistrations=>0,
46
- :captureGivenAuth=>{ :numCaptureGivenAuths=>0, :captureGivenAuthAmount=>0 },
47
- :forceCapture=>{ :numForceCaptures=>0, :forceCaptureAmount=>0 },
48
- :authReversal=>{ :numAuthReversals=>0, :authReversalAmount=>0 },
49
- :capture=>{ :numCaptures=>0, :captureAmount=>0 },
50
- :echeckVerification=>{ :numEcheckVerification=>0, :echeckVerificationAmount=>0 },
51
- :echeckCredit=>{ :numEcheckCredit=>0, :echeckCreditAmount=>0 },
52
- :numEcheckRedeposit=>0,
53
- :numEcheckPreNoteSale=>0,
54
- :numEcheckPreNoteCredit=>0,
55
- :echeckSale=>{ :numEcheckSales=>0, :echeckSalesAmount=>0 },
56
- :numUpdateCardValidationNumOnTokens=>0,
57
- :numAccountUpdates=>0,
58
- :total=>0,
59
- :numCancelSubscriptions=>0,
60
- :numUpdateSubscriptions=>0,
61
- :numCreatePlans=>0,
62
- :numUpdatePlans=>0,
63
- :activate=>{:numActivates=>0, :activateAmount=>0},
64
- :numDeactivates=>0,
65
- :load=>{:numLoads=>0, :loadAmount=>0},
66
- :unload=>{:numUnloads=>0, :unloadAmount=>0},
67
- :numBalanceInquirys=>0,
68
- :merchantSdk=>nil
40
+ :merchantId=>nil,
41
+ :auth=>{ :numAuths=>0, :authAmount=>0 },
42
+ :sale=>{ :numSales=>0, :saleAmount=>0 },
43
+ :credit=>{ :numCredits=>0, :creditAmount=>0 },
44
+ :numTokenRegistrations=>0,
45
+ :captureGivenAuth=>{ :numCaptureGivenAuths=>0, :captureGivenAuthAmount=>0 },
46
+ :forceCapture=>{ :numForceCaptures=>0, :forceCaptureAmount=>0 },
47
+ :authReversal=>{ :numAuthReversals=>0, :authReversalAmount=>0 },
48
+ :capture=>{ :numCaptures=>0, :captureAmount=>0 },
49
+ :echeckVerification=>{ :numEcheckVerification=>0, :echeckVerificationAmount=>0 },
50
+ :echeckCredit=>{ :numEcheckCredit=>0, :echeckCreditAmount=>0 },
51
+ :numEcheckRedeposit=>0,
52
+ :numEcheckPreNoteSale=>0,
53
+ :numEcheckPreNoteCredit=>0,
54
+ :payFacCredit=>{ :numPayFacCredit=>0, :payFacCreditAmount=>0 },
55
+ :submerchantCredit=>{ :numSubmerchantCredit=>0, :submerchantCreditAmount=>0 },
56
+ :reserveCredit=>{ :numReserveCredit=>0, :reserveCreditAmount=>0 },
57
+ :vendorCredit=>{ :numVendorCredit=>0, :vendorCreditAmount=>0 },
58
+ :physicalCheckCredit=>{ :numPhysicalCheckCredit=>0, :physicalCheckCreditAmount=>0 },
59
+ :payFacDebit=>{ :numPayFacDebit=>0, :payFacDebitAmount=>0 },
60
+ :submerchantDebit=>{ :numSubmerchantDebit=>0, :submerchantDebitAmount=>0 },
61
+ :reserveDebit=>{ :numReserveDebit=>0, :reserveDebitAmount=>0 },
62
+ :vendorDebit=>{ :numVendorDebit=>0, :vendorDebitAmount=>0 },
63
+ :physicalCheckDebit=>{ :numPhysicalCheckDebit=>0, :physicalCheckDebitAmount=>0 },
64
+ :echeckSale=>{ :numEcheckSales=>0, :echeckSalesAmount=>0 },
65
+ :numUpdateCardValidationNumOnTokens=>0,
66
+ :numAccountUpdates=>0,
67
+ :total=>0,
68
+ :numCancelSubscriptions=>0,
69
+ :numUpdateSubscriptions=>0,
70
+ :numCreatePlans=>0,
71
+ :numUpdatePlans=>0,
72
+ :activate=>{:numActivates=>0, :activateAmount=>0},
73
+ :numDeactivates=>0,
74
+ :load=>{:numLoads=>0, :loadAmount=>0},
75
+ :unload=>{:numUnloads=>0, :unloadAmount=>0},
76
+ :numBalanceInquirys=>0,
77
+ :merchantSdk=>nil
69
78
  }
70
79
  @litle_txn = LitleTransaction.new
71
80
  @path_to_batch = nil
@@ -73,26 +82,30 @@ module LitleOnline
73
82
  @MAX_TXNS_IN_BATCH = 100000
74
83
  @au_batch = nil
75
84
  end
76
-
85
+ #TODO:change this implementation
86
+ def set_merchantId_for_txn_counts(merchantId)
87
+ @txn_counts[:merchantId]=merchantId
88
+ end
89
+
77
90
  def create_new_batch(path)
78
91
  ts = Time::now.to_i.to_s
79
92
  begin
80
93
  ts += Time::now.nsec.to_s
81
94
  rescue NoMethodError # ruby 1.8.7 fix
82
95
  ts += Time::now.usec.to_s
83
- end
96
+ end
84
97
  if(File.file?(path)) then
85
98
  raise ArgumentError, "Entered a file not a path."
86
99
  end
87
-
100
+
88
101
  if(path[-1,1] != '/' && path[-1,1] != '\\') then
89
102
  path = path + File::SEPARATOR
90
103
  end
91
104
  if(!File.directory?(path)) then
92
105
  Dir.mkdir(path)
93
- end
94
-
95
- @path_to_batch = path + 'batch_' + ts
106
+ end
107
+
108
+ @path_to_batch = path + 'batch_' + ts
96
109
  @txn_file = @path_to_batch + '_txns'
97
110
  if(File.file?(@path_to_batch)) then
98
111
  create_new_batch(path)
@@ -105,20 +118,20 @@ module LitleOnline
105
118
  file.write("")
106
119
  end
107
120
  end
108
-
121
+
109
122
  def has_transactions?
110
123
  !@txn_counts[:total].eql?(0)
111
124
  end
112
-
125
+
113
126
  def open_existing_batch(pathToBatchFile)
114
127
  if(!File.file?(pathToBatchFile)) then
115
128
  raise ArgumentError, "No batch file exists at the passed location!"
116
- end
117
-
129
+ end
130
+
118
131
  if((pathToBatchFile =~ /batch_\d+.closed-\d+\z/) != nil) then
119
- raise ArgumentError, "The passed batch file is closed!"
120
- end
121
-
132
+ raise ArgumentError, "The passed batch file is closed!"
133
+ end
134
+
122
135
  @txn_file = pathToBatchFile + '_txns'
123
136
  @path_to_batch = pathToBatchFile
124
137
  temp_counts = File.open(@path_to_batch, "rb") { |f| Marshal.load(f) }
@@ -130,49 +143,48 @@ module LitleOnline
130
143
  create_new_batch(File.dirname(pathToBatchFile))
131
144
  @au_batch = au_batch
132
145
  elsif
133
- @txn_counts = temp_counts
134
- end
146
+ @txn_counts = temp_counts
147
+ end
135
148
  end
136
-
137
-
149
+
138
150
  def au_batch?
139
151
  !@au_batch.nil?
140
152
  end
141
-
153
+
142
154
  def close_batch(txn_location = @txn_file)
143
155
  header = build_batch_header(@txn_counts)
144
156
  File.rename(@path_to_batch, @path_to_batch + '.closed-' + @txn_counts[:total].to_s)
145
157
  @path_to_batch = @path_to_batch + '.closed-' + @txn_counts[:total].to_s
146
158
  File.open(@path_to_batch, 'w') do |fo|
147
- # fo.puts header
148
- put_header = !au_batch? || has_transactions?
149
- fo.puts header if put_header
159
+ # fo.puts header
160
+ put_header = !au_batch? || has_transactions?
161
+ fo.puts header if put_header
150
162
  File.foreach(txn_location) do |li|
151
163
  fo.puts li
152
164
  end
153
- # fo.puts('</batchRequest>')
154
- fo.puts('</batchRequest>') if put_header
165
+ # fo.puts('</batchRequest>')
166
+ fo.puts('</batchRequest>') if put_header
155
167
  end
156
168
  File.delete(txn_location)
157
169
  if(@au_batch != nil) then
158
170
  @au_batch.close_batch
159
- end
160
-
171
+ end
172
+
161
173
  end
162
-
174
+
163
175
  def authorization(options)
164
176
  transaction = @litle_txn.authorization(options)
165
177
  @txn_counts[:auth][:numAuths] += 1
166
178
  @txn_counts[:auth][:authAmount] += options['amount'].to_i
167
-
179
+
168
180
  add_txn_to_batch(transaction, :authorization, options)
169
181
  end
170
-
182
+
171
183
  def sale(options)
172
184
  transaction = @litle_txn.sale(options)
173
185
  @txn_counts[:sale][:numSales] += 1
174
186
  @txn_counts[:sale][:saleAmount] += options['amount'].to_i
175
-
187
+
176
188
  add_txn_to_batch(transaction, :sale, options)
177
189
  end
178
190
 
@@ -180,185 +192,267 @@ module LitleOnline
180
192
  transaction = @litle_txn.credit(options)
181
193
  @txn_counts[:credit][:numCredits] += 1
182
194
  @txn_counts[:credit][:creditAmount] += options['amount'].to_i
183
-
195
+
184
196
  add_txn_to_batch(transaction, :credit, options)
185
197
  end
186
-
198
+
187
199
  def auth_reversal(options)
188
200
  transaction = @litle_txn.auth_reversal(options)
189
- @txn_counts[:authReversal][:numAuthReversals] += 1
201
+ @txn_counts[:authReversal][:numAuthReversals] += 1
190
202
  @txn_counts[:authReversal][:authReversalAmount] += options['amount'].to_i
191
-
203
+
192
204
  add_txn_to_batch(transaction, :authReversal, options)
193
205
  end
194
206
 
195
207
  def cancel_subscription(options)
196
208
  transaction = @litle_txn.cancel_subscription(options)
197
209
  @txn_counts[:numCancelSubscriptions] += 1
198
-
210
+
199
211
  add_txn_to_batch(transaction, :cancelSubscription, options)
200
212
  end
201
213
 
202
214
  def update_subscription(options)
203
215
  transaction = @litle_txn.update_subscription(options)
204
216
  @txn_counts[:numUpdateSubscriptions] += 1
205
-
217
+
206
218
  add_txn_to_batch(transaction, :updateSubscription, options)
207
219
  end
208
220
 
209
221
  def create_plan(options)
210
- transaction = @litle_txn.create_plan(options)
222
+ transaction = @litle_txn.create_plan(options)
211
223
  @txn_counts[:numCreatePlans] += 1
212
-
224
+
213
225
  add_txn_to_batch(transaction, :createPlan, options)
214
226
  end
215
-
227
+
216
228
  def update_plan(options)
217
- transaction = @litle_txn.update_plan(options)
229
+ transaction = @litle_txn.update_plan(options)
218
230
  @txn_counts[:numUpdatePlans] += 1
219
-
231
+
220
232
  add_txn_to_batch(transaction, :updatePlan, options)
221
233
  end
222
234
 
223
235
  def activate(options)
224
- transaction = @litle_txn.activate(options)
236
+ transaction = @litle_txn.activate(options)
225
237
  @txn_counts[:numActivates] += 1
226
-
238
+
227
239
  add_txn_to_batch(transaction, :activate, options)
228
240
  end
229
241
 
230
242
  def deactivate(options)
231
- transaction = @litle_txn.deactivate(options)
243
+ transaction = @litle_txn.deactivate(options)
232
244
  @txn_counts[:numDeactivates] += 1
233
-
245
+
234
246
  add_txn_to_batch(transaction, :deactivate, options)
235
247
  end
236
248
 
237
249
  def load_request(options)
238
- transaction = @litle_txn.load_request(options)
250
+ transaction = @litle_txn.load_request(options)
239
251
  @txn_counts[:numLoads] += 1
240
-
252
+
241
253
  add_txn_to_batch(transaction, :load, options)
242
254
  end
243
255
 
244
256
  def unload_request(options)
245
- transaction = @litle_txn.unload_request(options)
257
+ transaction = @litle_txn.unload_request(options)
246
258
  @txn_counts[:numunLoads] += 1
247
-
259
+
248
260
  add_txn_to_batch(transaction, :unload, options)
249
261
  end
250
262
 
251
263
  def balance_inquiry(options)
252
- transaction = @litle_txn.balance_inquiry(options)
264
+ transaction = @litle_txn.balance_inquiry(options)
253
265
  @txn_counts[:numBalanceInquirys] += 1
254
-
266
+
255
267
  add_txn_to_batch(transaction, :balanceInquirys, options)
256
268
  end
269
+
257
270
  def register_token_request(options)
258
271
  transaction = @litle_txn.register_token_request(options)
259
272
  @txn_counts[:numTokenRegistrations] += 1
260
-
273
+
261
274
  add_txn_to_batch(transaction, :numTokenRegistrations, options)
262
275
  end
263
-
276
+
264
277
  def update_card_validation_num_on_token(options)
265
278
  transaction = @litle_txn.update_card_validation_num_on_token(options)
266
279
  @txn_counts[:numUpdateCardValidationNumOnTokens] += 1
267
-
280
+
268
281
  add_txn_to_batch(transaction, :numUpdateCardValidationNumOnTokens, options)
269
282
  end
270
-
283
+
271
284
  def force_capture(options)
272
285
  transaction = @litle_txn.force_capture(options)
273
286
  @txn_counts[:forceCapture][:numForceCaptures] += 1
274
287
  @txn_counts[:forceCapture][:forceCaptureAmount] += options['amount'].to_i
275
-
288
+
276
289
  add_txn_to_batch(transaction, :forceCapture, options)
277
290
  end
278
-
291
+
279
292
  def capture(options)
280
293
  transaction = @litle_txn.capture(options)
281
294
  @txn_counts[:capture][:numCaptures] += 1
282
295
  @txn_counts[:capture][:captureAmount] += options['amount'].to_i
283
-
296
+
284
297
  add_txn_to_batch(transaction, :capture, options)
285
298
  end
286
-
299
+
287
300
  def capture_given_auth(options)
288
301
  transaction = @litle_txn.capture_given_auth(options)
289
302
  @txn_counts[:captureGivenAuth][:numCaptureGivenAuths] += 1
290
303
  @txn_counts[:captureGivenAuth][:captureGivenAuthAmount] += options['amount'].to_i
291
-
304
+
292
305
  add_txn_to_batch(transaction, :captureGivenAuth, options)
293
306
  end
294
-
307
+
295
308
  def echeck_verification(options)
296
309
  transaction = @litle_txn.echeck_verification(options)
297
310
  @txn_counts[:echeckVerification][:numEcheckVerification] += 1
298
311
  @txn_counts[:echeckVerification][:echeckVerificationAmount] += options['amount'].to_i
299
-
312
+
300
313
  add_txn_to_batch(transaction, :echeckVerification, options)
301
314
  end
302
-
315
+
303
316
  def echeck_credit(options)
304
317
  transaction = @litle_txn.echeck_credit(options)
305
318
  @txn_counts[:echeckCredit][:numEcheckCredit] += 1
306
319
  @txn_counts[:echeckCredit][:echeckCreditAmount] += options['amount'].to_i
307
-
320
+
308
321
  add_txn_to_batch(transaction, :echeckCredit, options)
309
322
  end
310
-
323
+
311
324
  def echeck_redeposit(options)
312
325
  transaction = @litle_txn.echeck_redeposit(options)
313
326
  @txn_counts[:numEcheckRedeposit] += 1
314
-
327
+
315
328
  add_txn_to_batch(transaction, :echeckRedeposit, options)
316
329
  end
317
-
330
+
318
331
  def echeck_pre_note_sale(options)
319
332
  transaction = @litle_txn.echeck_pre_note_sale(options)
320
333
  @txn_counts[:numEcheckPreNoteSale] += 1
321
-
334
+
322
335
  add_txn_to_batch(transaction, :echeckPreNoteSale, options)
323
336
  end
324
-
337
+
325
338
  def echeck_pre_note_credit(options)
326
339
  transaction = @litle_txn.echeck_pre_note_credit(options)
327
340
  @txn_counts[:numEcheckPreNoteCredit] += 1
328
-
341
+
329
342
  add_txn_to_batch(transaction, :echeckPreNoteCredit, options)
330
343
  end
331
-
344
+
345
+ def payFac_credit(options)
346
+ transaction = @litle_txn.payFac_credit(options)
347
+ @txn_counts[:payFacCredit][:numPayFacCredit] += 1
348
+ @txn_counts[:payFacCredit][:payFacCreditAmount] += options['amount'].to_i
349
+
350
+ add_txn_to_batch(transaction, :payFacCredit, options)
351
+ end
352
+
353
+ def submerchant_credit(options)
354
+ transaction = @litle_txn.submerchant_credit(options)
355
+ @txn_counts[:submerchantCredit][:numSubmerchantCredit] += 1
356
+ @txn_counts[:submerchantCredit][:submerchantCreditAmount] += options['amount'].to_i
357
+
358
+ add_txn_to_batch(transaction, :submerchantCredit, options)
359
+ end
360
+
361
+ def reserve_credit(options)
362
+ transaction = @litle_txn.reserve_credit(options)
363
+ @txn_counts[:reserveCredit][:numReserveCredit] += 1
364
+ @txn_counts[:reserveCredit][:reserveCreditAmount] += options['amount'].to_i
365
+
366
+ add_txn_to_batch(transaction, :reserveCredit, options)
367
+ end
368
+
369
+ def vendor_credit(options)
370
+ transaction = @litle_txn.vendor_credit(options)
371
+ @txn_counts[:vendorCredit][:numVendorCredit] += 1
372
+ @txn_counts[:vendorCredit][:vendorCreditAmount] += options['amount'].to_i
373
+
374
+ add_txn_to_batch(transaction, :vendorCredit, options)
375
+ end
376
+
377
+ def physical_check_credit(options)
378
+ transaction = @litle_txn.physical_check_credit(options)
379
+ @txn_counts[:physicalCheckCredit][:numPhysicalCheckCredit] += 1
380
+ @txn_counts[:physicalCheckCredit][:physicalCheckCreditAmount] += options['amount'].to_i
381
+
382
+ add_txn_to_batch(transaction, :physicalCheckCredit, options)
383
+ end
384
+
385
+ def payFac_debit(options)
386
+ transaction = @litle_txn.payFac_debit(options)
387
+ @txn_counts[:payFacDebit][:numPayFacDebit] += 1
388
+ @txn_counts[:payFacDebit][:payFacDebitAmount] += options['amount'].to_i
389
+
390
+ add_txn_to_batch(transaction, :payFacDebit, options)
391
+ end
392
+
393
+ def submerchant_debit(options)
394
+ transaction = @litle_txn.submerchant_debit(options)
395
+ @txn_counts[:submerchantDebit][:numSubmerchantDebit] += 1
396
+ @txn_counts[:submerchantDebit][:submerchantDebitAmount] += options['amount'].to_i
397
+
398
+ add_txn_to_batch(transaction, :submerchantDebit, options)
399
+ end
400
+
401
+ def reserve_debit(options)
402
+ transaction = @litle_txn.reserve_debit(options)
403
+ @txn_counts[:reserveDebit][:numReserveDebit] += 1
404
+ @txn_counts[:reserveDebit][:reserveDebitAmount] += options['amount'].to_i
405
+
406
+ add_txn_to_batch(transaction, :reserveDebit, options)
407
+ end
408
+
409
+ def vendor_debit(options)
410
+ transaction = @litle_txn.vendor_debit(options)
411
+ @txn_counts[:vendorDebit][:numVendorDebit] += 1
412
+ @txn_counts[:vendorDebit][:vendorDebitAmount] += options['amount'].to_i
413
+
414
+ add_txn_to_batch(transaction, :vendorDebit, options)
415
+ end
416
+
417
+ def physical_check_debit(options)
418
+ transaction = @litle_txn.physical_check_debit(options)
419
+ @txn_counts[:physicalCheckDebit][:numPhysicalCheckDebit] += 1
420
+ @txn_counts[:physicalCheckDebit][:physicalCheckDebitAmount] += options['amount'].to_i
421
+
422
+ add_txn_to_batch(transaction, :physicalCheckDebit, options)
423
+ end
424
+
332
425
  def echeck_sale(options)
333
426
  transaction = @litle_txn.echeck_sale(options)
334
427
  @txn_counts[:echeckSale][:numEcheckSales] += 1
335
428
  @txn_counts[:echeckSale][:echeckSalesAmount] += options['amount'].to_i
336
-
429
+
337
430
  add_txn_to_batch(transaction, :echeckSale, options)
338
431
  end
339
-
432
+
340
433
  def account_update(options)
341
-
434
+
342
435
  if(@au_batch == nil) then
343
436
  @au_batch = LitleAUBatch.new
344
437
  @au_batch.create_new_batch(File.dirname(@path_to_batch))
345
- end
438
+ end
346
439
  @au_batch.account_update(options)
347
440
  end
348
-
441
+
349
442
  def get_counts_and_amounts
350
443
  return @txn_counts
351
444
  end
445
+
352
446
  def get_batch_name
353
447
  return @path_to_batch
354
448
  end
449
+
355
450
  def get_au_batch
356
451
  return @au_batch
357
452
  end
358
-
359
-
453
+
360
454
  private
361
-
455
+
362
456
  def add_txn_to_batch(transaction, type, options)
363
457
  @txn_counts[:total] += 1
364
458
  xml = transaction.save_to_xml.to_s
@@ -374,10 +468,10 @@ module LitleOnline
374
468
  create_new_batch(path)
375
469
  end
376
470
  end
377
-
471
+
378
472
  def build_batch_header(options)
379
473
  request = BatchRequest.new
380
-
474
+
381
475
  request.numAuths = @txn_counts[:auth][:numAuths]
382
476
  request.authAmount = @txn_counts[:auth][:authAmount]
383
477
  request.numSales = @txn_counts[:sale][:numSales]
@@ -398,6 +492,29 @@ module LitleOnline
398
492
  request.numEcheckRedeposit = @txn_counts[:numEcheckRedeposit]
399
493
  request.numEcheckPreNoteSale = @txn_counts[:numEcheckPreNoteSale]
400
494
  request.numEcheckPreNoteCredit = @txn_counts[:numEcheckPreNoteCredit]
495
+
496
+ request.numPayFacCredit = @txn_counts[:payFacCredit][:numPayFacCredit]
497
+ request.payFacCreditAmount = @txn_counts[:payFacCredit][:payFacCreditAmount]
498
+ request.numSubmerchantCredit = @txn_counts[:submerchantCredit][:numSubmerchantCredit]
499
+ request.submerchantCreditAmount = @txn_counts[:submerchantCredit][:submerchantCreditAmount]
500
+ request.numReserveCredit = @txn_counts[:reserveCredit][:numReserveCredit]
501
+ request.reserveCreditAmount = @txn_counts[:reserveCredit][:reserveCreditAmount]
502
+ request.numVendorCredit = @txn_counts[:vendorCredit][:numVendorCredit]
503
+ request.vendorCreditAmount = @txn_counts[:vendorCredit][:vendorCreditAmount]
504
+ request.numPhysicalCheckCredit = @txn_counts[:physicalCheckCredit][:numPhysicalCheckCredit]
505
+ request.physicalCheckCreditAmount = @txn_counts[:physicalCheckCredit][:physicalCheckCreditAmount]
506
+
507
+ request.numPayFacDebit = @txn_counts[:payFacDebit][:numPayFacDebit]
508
+ request.payFacDebitAmount = @txn_counts[:payFacDebit][:payFacDebitAmount]
509
+ request.numSubmerchantDebit = @txn_counts[:submerchantDebit][:numSubmerchantDebit]
510
+ request.submerchantDebitAmount = @txn_counts[:submerchantDebit][:submerchantDebitAmount]
511
+ request.numReserveDebit = @txn_counts[:reserveDebit][:numReserveDebit]
512
+ request.reserveDebitAmount = @txn_counts[:reserveDebit][:reserveDebitAmount]
513
+ request.numVendorDebit = @txn_counts[:vendorDebit][:numVendorDebit]
514
+ request.vendorDebitAmount = @txn_counts[:vendorDebit][:vendorDebitAmount]
515
+ request.numPhysicalCheckDebit = @txn_counts[:physicalCheckDebit][:numPhysicalCheckDebit]
516
+ request.physicalCheckDebitAmount = @txn_counts[:physicalCheckDebit][:physicalCheckDebitAmount]
517
+
401
518
  request.numEcheckCredit = @txn_counts[:echeckCredit][:numEcheckCredit]
402
519
  request.echeckCreditAmount = @txn_counts[:echeckCredit][:echeckCreditAmount]
403
520
  request.numEcheckVerification = @txn_counts[:echeckVerification][:numEcheckVerification]
@@ -419,61 +536,61 @@ module LitleOnline
419
536
  request.unloadAmount =@txn_counts[:unload][:unloadAmount]
420
537
  request.numBalanceInquirys =@txn_counts[:numBalanceInquirys]
421
538
  header = request.save_to_xml.to_s
422
- header['/>']= '>'
539
+ header['/>']= '>'
423
540
 
424
541
  return header
425
542
  end
426
-
543
+
427
544
  def get_config(field, options)
428
545
  options[field.to_s] == nil ? @config_hash[field.to_s] : options[field.to_s]
429
546
  end
430
-
547
+
431
548
  def get_merchant_id(options)
432
- options['merchantId'] || @config_hash['currency_merchant_map']['DEFAULT']
549
+ options[:merchantId] || @config_hash['currency_merchant_map']['DEFAULT']
433
550
  end
434
551
  end
435
-
552
+
436
553
  private
437
-
554
+
438
555
  # IF YOU ARE A MERCHANT, DON'T LOOK HERE. IT'S SCARY!
439
-
556
+
440
557
  class LitleAUBatch
441
558
  include XML::Mapping
442
559
  def initialize
443
560
  #load configuration data
444
561
  @config_hash = Configuration.new.config
445
-
562
+
446
563
  @txn_counts = { :id=>nil,
447
- :merchantId=>nil,
448
- :numAccountUpdates=>0,
449
- :total=>0
564
+ :merchantId=>nil,
565
+ :numAccountUpdates=>0,
566
+ :total=>0
450
567
  }
451
568
  @litle_txn = LitleTransaction.new
452
569
  @path_to_batch = nil
453
570
  @txn_file = nil
454
571
  @MAX_TXNS_IN_BATCH = 100000
455
572
  end
456
-
573
+
457
574
  def create_new_batch(path)
458
575
  ts = Time::now.to_i.to_s
459
576
  begin
460
577
  ts += Time::now.nsec.to_s
461
578
  rescue NoMethodError # ruby 1.8.7 fix
462
579
  ts += Time::now.usec.to_s
463
- end
464
-
580
+ end
581
+
465
582
  if(File.file?(path)) then
466
583
  raise ArgumentError, "Entered a file not a path."
467
584
  end
468
-
585
+
469
586
  if(path[-1,1] != '/' && path[-1,1] != '\\') then
470
587
  path = path + File::SEPARATOR
471
588
  end
472
589
  if(!File.directory?(path)) then
473
590
  Dir.mkdir(path)
474
- end
475
-
476
- @path_to_batch = path + 'batch_' + ts
591
+ end
592
+
593
+ @path_to_batch = path + 'batch_' + ts
477
594
  @txn_file = @path_to_batch + '_txns'
478
595
  if(File.file?(@path_to_batch)) then
479
596
  create_new_batch(path)
@@ -486,32 +603,32 @@ module LitleOnline
486
603
  file.write("")
487
604
  end
488
605
  end
489
-
606
+
490
607
  def open_existing_batch(pathToBatchFile)
491
608
  if(!File.file?(pathToBatchFile)) then
492
609
  raise ArgumentError, "No batch file exists at the passed location!"
493
- end
494
-
610
+ end
611
+
495
612
  if((pathToBatchFile =~ /batch_\d+.closed-\d+\z/) != nil) then
496
- raise ArgumentError, "The passed batch file is closed!"
497
- end
498
-
613
+ raise ArgumentError, "The passed batch file is closed!"
614
+ end
615
+
499
616
  @txn_file = pathToBatchFile + '_txns'
500
617
  @path_to_batch = pathToBatchFile
501
618
  temp_counts = File.open(@path_to_batch, "rb") { |f| Marshal.load(f) }
502
619
  if(temp_counts.keys.size > 4) then
503
620
  raise RuntimeException, "Tried to open an AU batch with a non-AU batch file"
504
- end
505
-
621
+ end
622
+
506
623
  @txn_counts[:id] = temp_counts[:id]
507
624
  @txn_counts[:merchantId] = temp_counts[:merchantId]
508
625
  @txn_counts[:numAccountUpdates] = temp_counts[:numAccountUpdates]
509
626
  @txn_counts[:total] = temp_counts[:total]
510
627
  end
511
-
628
+
512
629
  def close_batch(txn_location = @txn_file)
513
630
  header = build_batch_header(@txn_counts)
514
-
631
+
515
632
  File.rename(@path_to_batch, @path_to_batch + '.closed-' + @txn_counts[:total].to_s)
516
633
  @path_to_batch = @path_to_batch + '.closed-' + @txn_counts[:total].to_s
517
634
  File.open(@path_to_batch, 'w') do |fo|
@@ -523,23 +640,24 @@ module LitleOnline
523
640
  end
524
641
  File.delete(txn_location)
525
642
  end
526
-
643
+
527
644
  def account_update(options)
528
645
  transaction = @litle_txn.account_update(options)
529
646
  @txn_counts[:numAccountUpdates] += 1
530
-
647
+
531
648
  add_txn_to_batch(transaction, :authorization, options)
532
649
  end
533
-
650
+
534
651
  def get_counts_and_amounts
535
652
  return @txn_counts
536
653
  end
654
+
537
655
  def get_batch_name
538
656
  return @path_to_batch
539
657
  end
540
-
658
+
541
659
  private
542
-
660
+
543
661
  def add_txn_to_batch(transaction, type, options)
544
662
  @txn_counts[:total] += 1
545
663
  xml = transaction.save_to_xml.to_s
@@ -555,24 +673,24 @@ module LitleOnline
555
673
  create_new_batch(path)
556
674
  end
557
675
  end
558
-
676
+
559
677
  def build_batch_header(options)
560
678
  request = BatchRequest.new
561
-
679
+
562
680
  request.numAccountUpdates = @txn_counts[:numAccountUpdates]
563
681
  request.merchantId = get_merchant_id(options)
564
682
  request.id = @txn_counts[:id]
565
-
683
+
566
684
  header = request.save_to_xml.to_s
567
- header['/>']= '>'
685
+ header['/>']= '>'
568
686
 
569
687
  return header
570
688
  end
571
-
689
+
572
690
  def get_config(field, options)
573
691
  options[field.to_s] == nil ? @config_hash[field.to_s] : options[field.to_s]
574
692
  end
575
-
693
+
576
694
  def get_merchant_id(options)
577
695
  options['merchantId'] || @config_hash['currency_merchant_map']['DEFAULT']
578
696
  end