CnpOnline 8.31.1 → 9.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +29 -12
  3. data/DESCRIPTION +2 -2
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +4 -4
  7. data/Rakefile~ +5 -5
  8. data/SETUP.md +3 -3
  9. data/bin/Setup.rb +9 -8
  10. data/bin/sample_batch_driver.rb +1 -1
  11. data/bin/sample_driver.rb +1 -1
  12. data/lib/Communications.rb +1 -1
  13. data/lib/Configuration.rb +16 -16
  14. data/lib/EnvironmentVariables.rb +1 -2
  15. data/lib/LitleBatchRequest.rb +283 -147
  16. data/lib/LitleListeners.rb +132 -33
  17. data/lib/LitleOnline.rb +5 -4
  18. data/lib/LitleOnlineRequest.rb +69 -59
  19. data/lib/LitleRequest.rb +178 -141
  20. data/lib/LitleTransaction.rb +279 -122
  21. data/lib/LitleXmlMapper.rb +9 -4
  22. data/lib/XMLFields.rb +345 -26
  23. data/test/certification/certTest1_base.rb +74 -73
  24. data/test/certification/certTest2_authenhanced.rb +1 -1
  25. data/test/certification/certTest3_authreversal.rb +1 -1
  26. data/test/certification/certTest4_echeck.rb +4 -1
  27. data/test/certification/certTest5_token.rb +4 -4
  28. data/test/certification/certTest_batchAll.rb +296 -55
  29. data/test/certification/ts_all.rb +1 -1
  30. data/test/functional/test_activate.rb +7 -3
  31. data/test/functional/test_activateReversal.rb +7 -3
  32. data/test/functional/test_auth.rb +119 -16
  33. data/test/functional/test_authReversal.rb +5 -3
  34. data/test/functional/test_balanceInquiry.rb +5 -3
  35. data/test/functional/test_batch.rb +3 -3
  36. data/test/functional/test_batchStream.rb +14 -4
  37. data/test/functional/test_cancelSubscription.rb +5 -3
  38. data/test/functional/test_capture.rb +34 -3
  39. data/test/functional/test_captureGivenAuth.rb +55 -4
  40. data/test/functional/test_configuration.rb +2 -2
  41. data/test/functional/test_createPlan.rb +5 -3
  42. data/test/functional/test_credit.rb +45 -16
  43. data/test/functional/test_deactivate.rb +5 -3
  44. data/test/functional/test_deactivateReversal.rb +5 -3
  45. data/test/functional/test_depositReversal.rb +5 -3
  46. data/test/functional/test_echeckCredit.rb +26 -9
  47. data/test/functional/test_echeckRedeposit.rb +5 -3
  48. data/test/functional/test_echeckSale.rb +49 -28
  49. data/test/functional/test_echeckVerification.rb +20 -12
  50. data/test/functional/test_echeckVoid.rb +1 -1
  51. data/test/functional/test_forceCapture.rb +44 -22
  52. data/test/functional/test_fraudCheck.rb +77 -0
  53. data/test/functional/test_litle_requests.rb +24 -24
  54. data/test/functional/test_load.rb +5 -3
  55. data/test/functional/test_loadReversal.rb +5 -3
  56. data/test/functional/test_refundReversal.rb +5 -3
  57. data/test/functional/test_sale.rb +214 -29
  58. data/test/functional/test_token.rb +19 -3
  59. data/test/functional/test_unload.rb +5 -3
  60. data/test/functional/test_unloadReversal.rb +6 -4
  61. data/test/functional/test_updateCardValidationNumOnToken.rb +1 -1
  62. data/test/functional/test_updatePlan.rb +5 -3
  63. data/test/functional/test_updateSubscription.rb +5 -3
  64. data/test/functional/test_utf8.rb +44 -0
  65. data/test/functional/test_xmlfields.rb +10 -6
  66. data/test/functional/ts_all.rb +2 -1
  67. data/test/unit/test_LitleAUBatch.rb +29 -1
  68. data/test/unit/test_LitleBatchRequest.rb +247 -113
  69. data/test/unit/test_LitleOnlineRequest.rb +37 -54
  70. data/test/unit/test_LitleRequest.rb +3 -3
  71. data/test/unit/test_LitleTransaction.rb +5 -5
  72. data/test/unit/test_LitleXmlMapper.rb +136 -0
  73. data/test/unit/test_activate.rb +1 -21
  74. data/test/unit/test_activateReversal.rb +1 -1
  75. data/test/unit/test_auth.rb +54 -14
  76. data/test/unit/test_authReversal.rb +1 -1
  77. data/test/unit/test_balanceInquiry.rb +1 -1
  78. data/test/unit/test_cancelSubscription.rb +1 -1
  79. data/test/unit/test_capture.rb +27 -1
  80. data/test/unit/test_captureGivenAuth.rb +44 -18
  81. data/test/unit/test_createPlan.rb +1 -1
  82. data/test/unit/test_credit.rb +16 -3
  83. data/test/unit/test_deactivate.rb +1 -1
  84. data/test/unit/test_deactivateReversal.rb +1 -1
  85. data/test/unit/test_depositReversal.rb +1 -1
  86. data/test/unit/test_echeckCredit.rb +15 -2
  87. data/test/unit/test_echeckRedeposit.rb +1 -1
  88. data/test/unit/test_echeckSale.rb +18 -1
  89. data/test/unit/test_echeckVerification.rb +1 -1
  90. data/test/unit/test_echeckVoid.rb +1 -1
  91. data/test/unit/test_forceCapture.rb +20 -2
  92. data/test/unit/test_fraudCheck.rb +45 -0
  93. data/test/unit/test_load.rb +1 -1
  94. data/test/unit/test_loadReversal.rb +1 -1
  95. data/test/unit/test_refundReversal.rb +1 -1
  96. data/test/unit/test_sale.rb +73 -7
  97. data/test/unit/test_token.rb +15 -4
  98. data/test/unit/test_unload.rb +1 -1
  99. data/test/unit/test_unloadReversal.rb +1 -1
  100. data/test/unit/test_updateCardValidationNumOnToken.rb +1 -1
  101. data/test/unit/test_updatePlan.rb +1 -1
  102. data/test/unit/test_updateSubscription.rb +1 -1
  103. data/test/unit/test_xmlfields.rb +1 -1
  104. data/test/unit/ts_unit.rb +2 -1
  105. metadata +10 -7
  106. data/CHANGELOG~ +0 -142
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aa39b17bbff2336ad86a31f4a613323c717afb2657afb2f7a2b4c95149a18fe
4
- data.tar.gz: 1c3d17a08885c32a1604431a191027dece06d4457c265605712abd872d5d9913
3
+ metadata.gz: e28fa5a2df7b0a8309b102abd5bd9fd4bd5874959be9461d07b895f056d588fd
4
+ data.tar.gz: 9f45274bc91b59db75c4103231857f39232ea168da1ad1e64f84740b09b8d976
5
5
  SHA512:
6
- metadata.gz: adcab4d9952751adf0287ce40ef9b9d211dec07005ac3f57d08e9ac8305460e97c06283b95e6edb1ad5c8ced7b8c9e73e6fda0dcd28ebcb79bb6c2e3d7ef33e6
7
- data.tar.gz: 5c1f0e1aa13ee725699001b3609ca2f026114ce3286a614228343fe1ddba397f8a23db2624f40954cca89f4f8168c630713dbd13054c78449c667aaa285842d8
6
+ metadata.gz: deec6fa2301e4b984234534f0833d72351f8ef7772df1c5242f1307c2aa00858722ebc4e19709859047dfead257eab37e492af61156e38d74caf3bfacae612cc
7
+ data.tar.gz: 80761e4501d6730f2b499d9c0d01336426e7a92b0b09d58a7e1c42bde552fb524bff8af19a5ea276289053f8c59fc64287cd8b626d261d6dcf2d2f566ec5fc25
data/CHANGELOG CHANGED
@@ -1,22 +1,39 @@
1
1
  = LitleOnline CHANGELOG
2
2
 
3
- ==Version 8.31.1 (April 24, 2018)
4
- * BugFix: Set content-type to text/xml; charset=UTF-8
3
+ ==Version 9.14.0 (March 29, 2018)
4
+ *Feature: add Girotype and SofortType support
5
5
 
6
- == version 8.31.0(March 29, 2018)
7
- * Feature : Processingtype elements added to sale, authorization, and forcecapture
6
+ ==Version 9.12.0
7
+ *Feature: updated to use XML v9.12
8
+ *Feature: added SEPA Direct Debit transaction support
9
+ *Feature: added iDeal (Direct Debit) transaction support
8
10
 
9
- ==version 8.29.2
10
- HTTP timeout set to 500ms
11
+ ==Version 9.10.0
12
+ * Feature: add androidpay
13
+ * Feature: add network enhancements for original txn Id and original amount
14
+ * Feature: add processingType
15
+ * Feature: add cardSuffix on responses
16
+ * Feature: add Card Pin Support
17
+ * Feature: add Wallet support
11
18
 
12
- == version 8.29.1(March 11, 2015)
13
- * BugFix: fixed a XML field bug in Account Update Token
19
+ ==Version 9.3.3
20
+ * add fraudCheck transaction type
14
21
 
15
- == version 8.29.0(January 28, 2015)
16
- * Feature : Added support for Applepay and Secondary Amount
17
- * BugFix: fix an incorrect mapping in fraud check option fields for Sale transaction
22
+ ==Version 9.3.2
23
+ * HTTP timeout set to 500ms
18
24
 
19
- == version 8.27.0(August 27, 2014)
25
+ ==Version 9.3.1 (March 9, 2015)
26
+ *Feature: PFIF instruction transaction support was added
27
+
28
+ == Version 9.3.0
29
+ * Feature: Applepay support was added
30
+ * Feature: Secondary amount support was added
31
+ * Feature: Add support for new Batch transaction in version 9.3 schema
32
+
33
+ == Version 9.0.0 (August 27,2014)
34
+ * Feature: Add support for new element in version 9 schema
35
+
36
+ == Version 8.27.0 (August 27,2014)
20
37
  * Feature : Added samples for all kinds of transactions
21
38
 
22
39
  == version 8.25.1(July 18,2014)
@@ -1,5 +1,5 @@
1
- Litle Online Ruby SDK created for version 8.18 of Litle XML format, see the XSD schema for specific fields that are supported by this format.
1
+ Vantiv eCommerce Ruby SDK created for version 9.10 of Vantiv eCommerce XML format, see the XSD schema for specific fields that are supported by this format.
2
2
 
3
- This gem contains an application interface in the Ruby programming language created by Litle & Co.
3
+ This gem contains an application interface in the Ruby programming language created by Vantiv eCommerce.
4
4
 
5
5
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Litle & Co.
1
+ Copyright (c) 2017 Vantiv eCommerce
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -62,7 +62,7 @@ puts "Message: "+ response.message
62
62
  puts "Litle Transaction ID: "+ response.saleResponse.litleTxnId
63
63
  ```
64
64
 
65
- 3) Next run this file using ruby. You should see the following result provided you have connectivity to the Litle certification environment. You will see an HTTP error if you don't have access to the Litle URL
65
+ 3) Next run this file using ruby. You should see the following result provided you have connectivity to the Vantiv eCommerce certification environment. You will see an HTTP error if you don't have access to the Vantiv eCommerce URL
66
66
 
67
67
  Message: Valid Format
68
68
  Litle Transaction ID: <your-numeric-litle-txn-id>
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2011 Litle & Co.
1
+ # Copyright (c) 2017 Vantiv eCommerce
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person
4
4
  # obtaining a copy of this software and associated documentation
@@ -28,16 +28,16 @@ require 'rake/clean'
28
28
  spec = Gem::Specification.new do |s|
29
29
  FileUtils.rm_rf('pkg')
30
30
  s.name = 'CnpOnline'
31
- s.summary = 'Ruby SDK produced by Vantiv eCommerce for transaction processing using Vantiv eCommerce XML format v8.31'
31
+ s.summary = 'Ruby SDK produced by Vantiv eCommerce for transaction processing using Vantiv eCommerce XML format v9.12'
32
32
  s.description = File.read(File.join(File.dirname(__FILE__), 'DESCRIPTION'))
33
33
  s.requirements =
34
34
  ['Contact sdksupport@vantiv.com for more information']
35
- s.version = '8.31.1'
35
+ s.version = '9.14.0'
36
36
  s.author = 'Vantiv eCommerce'
37
37
  s.email = 'sdksupport@vantiv.com'
38
38
  s.homepage = 'http://www.vantiv.com/developers'
39
39
  s.platform = Gem::Platform::RUBY
40
- s.required_ruby_version = '>=1.8.7'
40
+ s.required_ruby_version = '>=2.2.0'
41
41
  s.files = Dir['**/**']
42
42
  s.executables = ['sample_driver.rb', 'Setup.rb']
43
43
  s.test_files = Dir['test/unit/ts_unit.rb']
data/Rakefile~ CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2011 Litle & Co.
1
+ # Copyright (c) 2017 Vantiv eCommerce
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person
4
4
  # obtaining a copy of this software and associated documentation
@@ -27,17 +27,17 @@ require 'rake/clean'
27
27
 
28
28
  spec = Gem::Specification.new do |s|
29
29
  FileUtils.rm_rf('pkg')
30
- s.name = 'CnpOnline'
31
- s.summary = 'Ruby SDK produced by Vantiv eCommerce for transaction processing using Vantiv eCommerce XML format v8.31'
30
+ s.name = 'LitleOnline'
31
+ s.summary = 'Ruby SDK produced by Vantiv eCommerce for transaction processing using Vantiv eCommerce XML format v9.12'
32
32
  s.description = File.read(File.join(File.dirname(__FILE__), 'DESCRIPTION'))
33
33
  s.requirements =
34
34
  ['Contact sdksupport@vantiv.com for more information']
35
- s.version = '8.31.0'
35
+ s.version = '9.14.0'
36
36
  s.author = 'Vantiv eCommerce'
37
37
  s.email = 'sdksupport@vantiv.com'
38
38
  s.homepage = 'http://www.vantiv.com/developers'
39
39
  s.platform = Gem::Platform::RUBY
40
- s.required_ruby_version = '>=1.8.7'
40
+ s.required_ruby_version = '>=2.2.0'
41
41
  s.files = Dir['**/**']
42
42
  s.executables = ['sample_driver.rb', 'Setup.rb']
43
43
  s.test_files = Dir['test/unit/ts_unit.rb']
data/SETUP.md CHANGED
@@ -1,4 +1,4 @@
1
- Setting up and Configuring the Litle SDK
1
+ Setting up and Configuring the Vantiv eCommerce SDK
2
2
  =========================================
3
3
 
4
4
  Running the built in configuration file generator
@@ -9,7 +9,7 @@ This program runs as follows:
9
9
 
10
10
  ```
11
11
  >Setup.rb
12
- Welcome to Litle Ruby_SDK
12
+ Welcome to Vantiv eCommerce Ruby_SDK
13
13
  please input your user name:
14
14
  test_user
15
15
  please input your password:
@@ -31,7 +31,7 @@ Modifying your configuration
31
31
  ----------------------------
32
32
  You may change the configuration values at anytime by running Setup.rb again, or simpy opening the configuration file directly in the editor of your choice and changing the appropriate fields.
33
33
 
34
- Changing the location of the Litle configuration file:
34
+ Changing the location of the Vantiv eCommerce configuration file:
35
35
  ------------------------------------------------------
36
36
  NOTICE you can set the environment variable $LITLE_CONFIG_DIR to locate your configuration file in a location other than the $HOME Directory, the the file will reside in $LITLE_CONFIG_DIR/.litle_SDK_config.yml
37
37
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright (c) 2011 Litle & Co.
3
+ # Copyright (c) 2017 Vantiv eCommerce
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person
6
6
  # obtaining a copy of this software and associated documentation
@@ -17,7 +17,7 @@
17
17
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
18
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
19
  # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- # NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
21
  # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
22
  # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
23
  # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
@@ -33,7 +33,7 @@ class Setup
33
33
  def initialize(filename)
34
34
  @handle = File.new(filename, File::CREAT | File::TRUNC | File::RDWR, 0o600)
35
35
  File.open(filename, 'w') do |f|
36
- puts 'Welcome to Litle Ruby_SDK'
36
+ puts 'Welcome to Vantiv eCommerce Ruby_SDK'
37
37
  puts 'Please input your user name:'
38
38
  f.puts 'user: ' + gets
39
39
  puts 'Please input your password:'
@@ -44,7 +44,8 @@ class Setup
44
44
  f.puts ' DEFAULT: ' + gets
45
45
  f.puts "default_report_group: 'Default Report Group'"
46
46
 
47
- puts "Please choose Litle url from the following list (example: 'prelive') or directly input another URL:
47
+ puts "Please choose Vantiv eCommerce url from the following list
48
+ (example: 'prelive') or directly input another URL:
48
49
  sandbox => https://www.testvantivcnp.com/sandbox/communicator/online
49
50
  prelive => https://payments.vantivprelive.com/vap/communicator/online
50
51
  postlive => https://payments.vantivpostlive.com/vap/communicator/online
@@ -81,7 +82,7 @@ transact_production => https://transact.vantivcnp.com/vap/communicator/online"
81
82
  def self.choice(litle_env)
82
83
  litle_online_ctx = 'vap/communicator/online'
83
84
  if litle_env == "sandbox\n"
84
- return 'https://www.testvantivcnp.com/sandbox/communicator/online'
85
+ return 'https://www.testvantivcnp.com/sandbox/new/sandbox/communicator/online'
85
86
  elsif litle_env == "prelive\n"
86
87
  return 'https://payments.vantivprelive.com/' + litle_online_ctx
87
88
  elsif litle_env == "postlive\n"
@@ -89,9 +90,9 @@ transact_production => https://transact.vantivcnp.com/vap/communicator/online"
89
90
  elsif litle_env == "production\n"
90
91
  return 'https://payments.vantivcnp.com/' + litle_online_ctx
91
92
  elsif litle_env == "transact_production\n"
92
- return 'https://transact.vantivcnp.com/' + litle_online_ctx
93
+ return 'https://transact.litle.com/' + litle_online_ctx
93
94
  elsif litle_env == "transact_prelive\n"
94
- return 'https://transact.vantivprelive.com/' + litle_online_ctx
95
+ return 'https://transact.vantivcnp.com/' + litle_online_ctx
95
96
  elsif litle_env == "transact_postlive\n"
96
97
  return 'https://transact.vantivpostlive.com/' + litle_online_ctx
97
98
  else
@@ -120,5 +121,5 @@ f = Setup.new(config_file)
120
121
 
121
122
  # return the path of the config file and the path file
122
123
  @path = File.expand_path(config_file)
123
- puts 'The Litle configuration file has been generated, the file is located at: ' + @path
124
+ puts 'The Vantiv eCommerce configuration file has been generated, the file is located at: ' + @path
124
125
  f.finished
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin
3
- Copyright (c) 2011 Litle & Co.
3
+ Copyright (c) 2017 Vantiv eCommerce
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person
6
6
  obtaining a copy of this software and associated documentation
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  =begin
4
- Copyright (c) 2011 Litle & Co.
4
+ Copyright (c) 2017 Vantiv eCommerce
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person
7
7
  obtaining a copy of this software and associated documentation
@@ -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'
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2011 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -37,31 +37,31 @@ module LitleOnline
37
37
  def config
38
38
  begin
39
39
  if !(ENV['LITLE_CONFIG_DIR'].nil?)
40
- config_file = ENV['LITLE_CONFIG_DIR'] + "/.litle_SDK_config.yml"
40
+ config_file = ENV['LITLE_CONFIG_DIR'] + '/.litle_SDK_config.yml'
41
41
  else
42
- config_file = ENV['HOME'] + "/.litle_SDK_config.yml"
42
+ config_file = ENV['HOME'] + '/.litle_SDK_config.yml'
43
43
  end
44
- #if Env variable exist, then just override the data from config file
45
- if (File.exists?(config_file))
46
- datas=YAML.load_file(config_file)
47
- else
48
- environments = EnvironmentVariables.new
44
+ # if Env variable exist, then just override the data from config file
45
+ if File.exists?(config_file)
46
+ datas=YAML.load_file(config_file)
47
+ else
48
+ environments = EnvironmentVariables.new
49
49
  datas={}
50
- environments.instance_variables.each {|var| datas[var.to_s.delete("@")] = environments.instance_variable_get(var) }
51
- end
52
- datas.each {|key,value| setENV(key,datas)}
50
+ environments.instance_variables.each {|var| datas[var.to_s.delete("@")] = environments.instance_variable_get(var)}
51
+ end
52
+ datas.each {|key, value| setENV(key, datas)}
53
53
  return datas
54
- rescue
54
+ rescue
55
55
  return {}
56
56
  end
57
-
57
+
58
58
  end
59
- def setENV(key,datas)
59
+
60
+ def setENV(key, datas)
60
61
  if !(ENV['litle_'+key].nil?)
61
- datas[key]=ENV['litle_'+key]
62
+ datas[key]=ENV['litle_'+key]
62
63
  end
63
64
  end
64
-
65
65
  end
66
66
 
67
67
  end
@@ -1,7 +1,7 @@
1
1
  module LitleOnline
2
2
  class EnvironmentVariables
3
3
  def initialize
4
- #load configuration data
4
+ # load configuration data
5
5
  @user = ''
6
6
  @password = ''
7
7
  @currency_merchant_map = ''
@@ -17,6 +17,5 @@ module LitleOnline
17
17
  @printxml = false
18
18
  @timeout = 65
19
19
  end
20
-
21
20
  end
22
21
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2011 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -25,45 +25,56 @@ OTHER DEALINGS IN THE SOFTWARE.
25
25
  require_relative 'Configuration'
26
26
 
27
27
  #
28
- # This class creates a new batch to which Litle XML transactions are added.
28
+ # This class creates a new batch to which Vantiv eCommerce XML transactions are added.
29
29
  # The batch is stored in the local file system until it is ready to be sent
30
- # to Litle.
30
+ # to Vantiv eCommerce.
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
- :echeckSale=>{ :numEcheckSales=>0, :echeckSalesAmount=>0 },
54
- :numUpdateCardValidationNumOnTokens=>0,
55
- :numAccountUpdates=>0,
56
- :total=>0,
57
- :numCancelSubscriptions=>0,
58
- :numUpdateSubscriptions=>0,
59
- :numCreatePlans=>0,
60
- :numUpdatePlans=>0,
61
- :activate=>{:numActivates=>0, :activateAmount=>0},
62
- :numDeactivates=>0,
63
- :load=>{:numLoads=>0, :loadAmount=>0},
64
- :unload=>{:numUnloads=>0, :unloadAmount=>0},
65
- :numBalanceInquirys=>0,
66
- :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
67
78
  }
68
79
  @litle_txn = LitleTransaction.new
69
80
  @path_to_batch = nil
@@ -71,26 +82,30 @@ module LitleOnline
71
82
  @MAX_TXNS_IN_BATCH = 100000
72
83
  @au_batch = nil
73
84
  end
74
-
85
+ #TODO:change this implementation
86
+ def set_merchantId_for_txn_counts(merchantId)
87
+ @txn_counts[:merchantId]=merchantId
88
+ end
89
+
75
90
  def create_new_batch(path)
76
91
  ts = Time::now.to_i.to_s
77
92
  begin
78
93
  ts += Time::now.nsec.to_s
79
94
  rescue NoMethodError # ruby 1.8.7 fix
80
95
  ts += Time::now.usec.to_s
81
- end
96
+ end
82
97
  if(File.file?(path)) then
83
98
  raise ArgumentError, "Entered a file not a path."
84
99
  end
85
-
100
+
86
101
  if(path[-1,1] != '/' && path[-1,1] != '\\') then
87
102
  path = path + File::SEPARATOR
88
103
  end
89
104
  if(!File.directory?(path)) then
90
105
  Dir.mkdir(path)
91
- end
92
-
93
- @path_to_batch = path + 'batch_' + ts
106
+ end
107
+
108
+ @path_to_batch = path + 'batch_' + ts
94
109
  @txn_file = @path_to_batch + '_txns'
95
110
  if(File.file?(@path_to_batch)) then
96
111
  create_new_batch(path)
@@ -103,20 +118,20 @@ module LitleOnline
103
118
  file.write("")
104
119
  end
105
120
  end
106
-
121
+
107
122
  def has_transactions?
108
123
  !@txn_counts[:total].eql?(0)
109
124
  end
110
-
125
+
111
126
  def open_existing_batch(pathToBatchFile)
112
127
  if(!File.file?(pathToBatchFile)) then
113
128
  raise ArgumentError, "No batch file exists at the passed location!"
114
- end
115
-
129
+ end
130
+
116
131
  if((pathToBatchFile =~ /batch_\d+.closed-\d+\z/) != nil) then
117
- raise ArgumentError, "The passed batch file is closed!"
118
- end
119
-
132
+ raise ArgumentError, "The passed batch file is closed!"
133
+ end
134
+
120
135
  @txn_file = pathToBatchFile + '_txns'
121
136
  @path_to_batch = pathToBatchFile
122
137
  temp_counts = File.open(@path_to_batch, "rb") { |f| Marshal.load(f) }
@@ -128,49 +143,48 @@ module LitleOnline
128
143
  create_new_batch(File.dirname(pathToBatchFile))
129
144
  @au_batch = au_batch
130
145
  elsif
131
- @txn_counts = temp_counts
132
- end
146
+ @txn_counts = temp_counts
147
+ end
133
148
  end
134
-
135
-
149
+
136
150
  def au_batch?
137
151
  !@au_batch.nil?
138
152
  end
139
-
153
+
140
154
  def close_batch(txn_location = @txn_file)
141
155
  header = build_batch_header(@txn_counts)
142
156
  File.rename(@path_to_batch, @path_to_batch + '.closed-' + @txn_counts[:total].to_s)
143
157
  @path_to_batch = @path_to_batch + '.closed-' + @txn_counts[:total].to_s
144
158
  File.open(@path_to_batch, 'w') do |fo|
145
- # fo.puts header
146
- put_header = !au_batch? || has_transactions?
147
- fo.puts header if put_header
159
+ # fo.puts header
160
+ put_header = !au_batch? || has_transactions?
161
+ fo.puts header if put_header
148
162
  File.foreach(txn_location) do |li|
149
163
  fo.puts li
150
164
  end
151
- # fo.puts('</batchRequest>')
152
- fo.puts('</batchRequest>') if put_header
165
+ # fo.puts('</batchRequest>')
166
+ fo.puts('</batchRequest>') if put_header
153
167
  end
154
168
  File.delete(txn_location)
155
169
  if(@au_batch != nil) then
156
170
  @au_batch.close_batch
157
- end
158
-
171
+ end
172
+
159
173
  end
160
-
174
+
161
175
  def authorization(options)
162
176
  transaction = @litle_txn.authorization(options)
163
177
  @txn_counts[:auth][:numAuths] += 1
164
178
  @txn_counts[:auth][:authAmount] += options['amount'].to_i
165
-
179
+
166
180
  add_txn_to_batch(transaction, :authorization, options)
167
181
  end
168
-
182
+
169
183
  def sale(options)
170
184
  transaction = @litle_txn.sale(options)
171
185
  @txn_counts[:sale][:numSales] += 1
172
186
  @txn_counts[:sale][:saleAmount] += options['amount'].to_i
173
-
187
+
174
188
  add_txn_to_batch(transaction, :sale, options)
175
189
  end
176
190
 
@@ -178,171 +192,267 @@ module LitleOnline
178
192
  transaction = @litle_txn.credit(options)
179
193
  @txn_counts[:credit][:numCredits] += 1
180
194
  @txn_counts[:credit][:creditAmount] += options['amount'].to_i
181
-
195
+
182
196
  add_txn_to_batch(transaction, :credit, options)
183
197
  end
184
-
198
+
185
199
  def auth_reversal(options)
186
200
  transaction = @litle_txn.auth_reversal(options)
187
- @txn_counts[:authReversal][:numAuthReversals] += 1
201
+ @txn_counts[:authReversal][:numAuthReversals] += 1
188
202
  @txn_counts[:authReversal][:authReversalAmount] += options['amount'].to_i
189
-
203
+
190
204
  add_txn_to_batch(transaction, :authReversal, options)
191
205
  end
192
206
 
193
207
  def cancel_subscription(options)
194
208
  transaction = @litle_txn.cancel_subscription(options)
195
209
  @txn_counts[:numCancelSubscriptions] += 1
196
-
210
+
197
211
  add_txn_to_batch(transaction, :cancelSubscription, options)
198
212
  end
199
213
 
200
214
  def update_subscription(options)
201
215
  transaction = @litle_txn.update_subscription(options)
202
216
  @txn_counts[:numUpdateSubscriptions] += 1
203
-
217
+
204
218
  add_txn_to_batch(transaction, :updateSubscription, options)
205
219
  end
206
220
 
207
221
  def create_plan(options)
208
- transaction = @litle_txn.create_plan(options)
222
+ transaction = @litle_txn.create_plan(options)
209
223
  @txn_counts[:numCreatePlans] += 1
210
-
224
+
211
225
  add_txn_to_batch(transaction, :createPlan, options)
212
226
  end
213
-
227
+
214
228
  def update_plan(options)
215
- transaction = @litle_txn.update_plan(options)
229
+ transaction = @litle_txn.update_plan(options)
216
230
  @txn_counts[:numUpdatePlans] += 1
217
-
231
+
218
232
  add_txn_to_batch(transaction, :updatePlan, options)
219
233
  end
220
234
 
221
235
  def activate(options)
222
- transaction = @litle_txn.activate(options)
236
+ transaction = @litle_txn.activate(options)
223
237
  @txn_counts[:numActivates] += 1
224
-
238
+
225
239
  add_txn_to_batch(transaction, :activate, options)
226
240
  end
227
241
 
228
242
  def deactivate(options)
229
- transaction = @litle_txn.deactivate(options)
243
+ transaction = @litle_txn.deactivate(options)
230
244
  @txn_counts[:numDeactivates] += 1
231
-
245
+
232
246
  add_txn_to_batch(transaction, :deactivate, options)
233
247
  end
234
248
 
235
249
  def load_request(options)
236
- transaction = @litle_txn.load_request(options)
250
+ transaction = @litle_txn.load_request(options)
237
251
  @txn_counts[:numLoads] += 1
238
-
252
+
239
253
  add_txn_to_batch(transaction, :load, options)
240
254
  end
241
255
 
242
256
  def unload_request(options)
243
- transaction = @litle_txn.unload_request(options)
257
+ transaction = @litle_txn.unload_request(options)
244
258
  @txn_counts[:numunLoads] += 1
245
-
259
+
246
260
  add_txn_to_batch(transaction, :unload, options)
247
261
  end
248
262
 
249
263
  def balance_inquiry(options)
250
- transaction = @litle_txn.balance_inquiry(options)
264
+ transaction = @litle_txn.balance_inquiry(options)
251
265
  @txn_counts[:numBalanceInquirys] += 1
252
-
266
+
253
267
  add_txn_to_batch(transaction, :balanceInquirys, options)
254
268
  end
269
+
255
270
  def register_token_request(options)
256
271
  transaction = @litle_txn.register_token_request(options)
257
272
  @txn_counts[:numTokenRegistrations] += 1
258
-
273
+
259
274
  add_txn_to_batch(transaction, :numTokenRegistrations, options)
260
275
  end
261
-
276
+
262
277
  def update_card_validation_num_on_token(options)
263
278
  transaction = @litle_txn.update_card_validation_num_on_token(options)
264
279
  @txn_counts[:numUpdateCardValidationNumOnTokens] += 1
265
-
280
+
266
281
  add_txn_to_batch(transaction, :numUpdateCardValidationNumOnTokens, options)
267
282
  end
268
-
283
+
269
284
  def force_capture(options)
270
285
  transaction = @litle_txn.force_capture(options)
271
286
  @txn_counts[:forceCapture][:numForceCaptures] += 1
272
287
  @txn_counts[:forceCapture][:forceCaptureAmount] += options['amount'].to_i
273
-
288
+
274
289
  add_txn_to_batch(transaction, :forceCapture, options)
275
290
  end
276
-
291
+
277
292
  def capture(options)
278
293
  transaction = @litle_txn.capture(options)
279
294
  @txn_counts[:capture][:numCaptures] += 1
280
295
  @txn_counts[:capture][:captureAmount] += options['amount'].to_i
281
-
296
+
282
297
  add_txn_to_batch(transaction, :capture, options)
283
298
  end
284
-
299
+
285
300
  def capture_given_auth(options)
286
301
  transaction = @litle_txn.capture_given_auth(options)
287
302
  @txn_counts[:captureGivenAuth][:numCaptureGivenAuths] += 1
288
303
  @txn_counts[:captureGivenAuth][:captureGivenAuthAmount] += options['amount'].to_i
289
-
304
+
290
305
  add_txn_to_batch(transaction, :captureGivenAuth, options)
291
306
  end
292
-
307
+
293
308
  def echeck_verification(options)
294
309
  transaction = @litle_txn.echeck_verification(options)
295
310
  @txn_counts[:echeckVerification][:numEcheckVerification] += 1
296
311
  @txn_counts[:echeckVerification][:echeckVerificationAmount] += options['amount'].to_i
297
-
312
+
298
313
  add_txn_to_batch(transaction, :echeckVerification, options)
299
314
  end
300
-
315
+
301
316
  def echeck_credit(options)
302
317
  transaction = @litle_txn.echeck_credit(options)
303
318
  @txn_counts[:echeckCredit][:numEcheckCredit] += 1
304
319
  @txn_counts[:echeckCredit][:echeckCreditAmount] += options['amount'].to_i
305
-
320
+
306
321
  add_txn_to_batch(transaction, :echeckCredit, options)
307
322
  end
308
-
323
+
309
324
  def echeck_redeposit(options)
310
325
  transaction = @litle_txn.echeck_redeposit(options)
311
326
  @txn_counts[:numEcheckRedeposit] += 1
312
-
327
+
313
328
  add_txn_to_batch(transaction, :echeckRedeposit, options)
314
329
  end
315
-
330
+
331
+ def echeck_pre_note_sale(options)
332
+ transaction = @litle_txn.echeck_pre_note_sale(options)
333
+ @txn_counts[:numEcheckPreNoteSale] += 1
334
+
335
+ add_txn_to_batch(transaction, :echeckPreNoteSale, options)
336
+ end
337
+
338
+ def echeck_pre_note_credit(options)
339
+ transaction = @litle_txn.echeck_pre_note_credit(options)
340
+ @txn_counts[:numEcheckPreNoteCredit] += 1
341
+
342
+ add_txn_to_batch(transaction, :echeckPreNoteCredit, options)
343
+ end
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
+
316
425
  def echeck_sale(options)
317
426
  transaction = @litle_txn.echeck_sale(options)
318
427
  @txn_counts[:echeckSale][:numEcheckSales] += 1
319
428
  @txn_counts[:echeckSale][:echeckSalesAmount] += options['amount'].to_i
320
-
429
+
321
430
  add_txn_to_batch(transaction, :echeckSale, options)
322
431
  end
323
-
432
+
324
433
  def account_update(options)
325
-
434
+
326
435
  if(@au_batch == nil) then
327
436
  @au_batch = LitleAUBatch.new
328
437
  @au_batch.create_new_batch(File.dirname(@path_to_batch))
329
- end
438
+ end
330
439
  @au_batch.account_update(options)
331
440
  end
332
-
441
+
333
442
  def get_counts_and_amounts
334
443
  return @txn_counts
335
444
  end
445
+
336
446
  def get_batch_name
337
447
  return @path_to_batch
338
448
  end
449
+
339
450
  def get_au_batch
340
451
  return @au_batch
341
452
  end
342
-
343
-
453
+
344
454
  private
345
-
455
+
346
456
  def add_txn_to_batch(transaction, type, options)
347
457
  @txn_counts[:total] += 1
348
458
  xml = transaction.save_to_xml.to_s
@@ -358,10 +468,10 @@ module LitleOnline
358
468
  create_new_batch(path)
359
469
  end
360
470
  end
361
-
471
+
362
472
  def build_batch_header(options)
363
473
  request = BatchRequest.new
364
-
474
+
365
475
  request.numAuths = @txn_counts[:auth][:numAuths]
366
476
  request.authAmount = @txn_counts[:auth][:authAmount]
367
477
  request.numSales = @txn_counts[:sale][:numSales]
@@ -380,6 +490,31 @@ module LitleOnline
380
490
  request.numEcheckSales = @txn_counts[:echeckSale][:numEcheckSales]
381
491
  request.echeckSalesAmount = @txn_counts[:echeckSale][:echeckSalesAmount]
382
492
  request.numEcheckRedeposit = @txn_counts[:numEcheckRedeposit]
493
+ request.numEcheckPreNoteSale = @txn_counts[:numEcheckPreNoteSale]
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
+
383
518
  request.numEcheckCredit = @txn_counts[:echeckCredit][:numEcheckCredit]
384
519
  request.echeckCreditAmount = @txn_counts[:echeckCredit][:echeckCreditAmount]
385
520
  request.numEcheckVerification = @txn_counts[:echeckVerification][:numEcheckVerification]
@@ -401,61 +536,61 @@ module LitleOnline
401
536
  request.unloadAmount =@txn_counts[:unload][:unloadAmount]
402
537
  request.numBalanceInquirys =@txn_counts[:numBalanceInquirys]
403
538
  header = request.save_to_xml.to_s
404
- header['/>']= '>'
539
+ header['/>']= '>'
405
540
 
406
541
  return header
407
542
  end
408
-
543
+
409
544
  def get_config(field, options)
410
545
  options[field.to_s] == nil ? @config_hash[field.to_s] : options[field.to_s]
411
546
  end
412
-
547
+
413
548
  def get_merchant_id(options)
414
- options['merchantId'] || @config_hash['currency_merchant_map']['DEFAULT']
549
+ options[:merchantId] || @config_hash['currency_merchant_map']['DEFAULT']
415
550
  end
416
551
  end
417
-
552
+
418
553
  private
419
-
554
+
420
555
  # IF YOU ARE A MERCHANT, DON'T LOOK HERE. IT'S SCARY!
421
-
556
+
422
557
  class LitleAUBatch
423
558
  include XML::Mapping
424
559
  def initialize
425
560
  #load configuration data
426
561
  @config_hash = Configuration.new.config
427
-
562
+
428
563
  @txn_counts = { :id=>nil,
429
- :merchantId=>nil,
430
- :numAccountUpdates=>0,
431
- :total=>0
564
+ :merchantId=>nil,
565
+ :numAccountUpdates=>0,
566
+ :total=>0
432
567
  }
433
568
  @litle_txn = LitleTransaction.new
434
569
  @path_to_batch = nil
435
570
  @txn_file = nil
436
571
  @MAX_TXNS_IN_BATCH = 100000
437
572
  end
438
-
573
+
439
574
  def create_new_batch(path)
440
575
  ts = Time::now.to_i.to_s
441
576
  begin
442
577
  ts += Time::now.nsec.to_s
443
578
  rescue NoMethodError # ruby 1.8.7 fix
444
579
  ts += Time::now.usec.to_s
445
- end
446
-
580
+ end
581
+
447
582
  if(File.file?(path)) then
448
583
  raise ArgumentError, "Entered a file not a path."
449
584
  end
450
-
585
+
451
586
  if(path[-1,1] != '/' && path[-1,1] != '\\') then
452
587
  path = path + File::SEPARATOR
453
588
  end
454
589
  if(!File.directory?(path)) then
455
590
  Dir.mkdir(path)
456
- end
457
-
458
- @path_to_batch = path + 'batch_' + ts
591
+ end
592
+
593
+ @path_to_batch = path + 'batch_' + ts
459
594
  @txn_file = @path_to_batch + '_txns'
460
595
  if(File.file?(@path_to_batch)) then
461
596
  create_new_batch(path)
@@ -468,32 +603,32 @@ module LitleOnline
468
603
  file.write("")
469
604
  end
470
605
  end
471
-
606
+
472
607
  def open_existing_batch(pathToBatchFile)
473
608
  if(!File.file?(pathToBatchFile)) then
474
609
  raise ArgumentError, "No batch file exists at the passed location!"
475
- end
476
-
610
+ end
611
+
477
612
  if((pathToBatchFile =~ /batch_\d+.closed-\d+\z/) != nil) then
478
- raise ArgumentError, "The passed batch file is closed!"
479
- end
480
-
613
+ raise ArgumentError, "The passed batch file is closed!"
614
+ end
615
+
481
616
  @txn_file = pathToBatchFile + '_txns'
482
617
  @path_to_batch = pathToBatchFile
483
618
  temp_counts = File.open(@path_to_batch, "rb") { |f| Marshal.load(f) }
484
619
  if(temp_counts.keys.size > 4) then
485
620
  raise RuntimeException, "Tried to open an AU batch with a non-AU batch file"
486
- end
487
-
621
+ end
622
+
488
623
  @txn_counts[:id] = temp_counts[:id]
489
624
  @txn_counts[:merchantId] = temp_counts[:merchantId]
490
625
  @txn_counts[:numAccountUpdates] = temp_counts[:numAccountUpdates]
491
626
  @txn_counts[:total] = temp_counts[:total]
492
627
  end
493
-
628
+
494
629
  def close_batch(txn_location = @txn_file)
495
630
  header = build_batch_header(@txn_counts)
496
-
631
+
497
632
  File.rename(@path_to_batch, @path_to_batch + '.closed-' + @txn_counts[:total].to_s)
498
633
  @path_to_batch = @path_to_batch + '.closed-' + @txn_counts[:total].to_s
499
634
  File.open(@path_to_batch, 'w') do |fo|
@@ -505,23 +640,24 @@ module LitleOnline
505
640
  end
506
641
  File.delete(txn_location)
507
642
  end
508
-
643
+
509
644
  def account_update(options)
510
645
  transaction = @litle_txn.account_update(options)
511
646
  @txn_counts[:numAccountUpdates] += 1
512
-
647
+
513
648
  add_txn_to_batch(transaction, :authorization, options)
514
649
  end
515
-
650
+
516
651
  def get_counts_and_amounts
517
652
  return @txn_counts
518
653
  end
654
+
519
655
  def get_batch_name
520
656
  return @path_to_batch
521
657
  end
522
-
658
+
523
659
  private
524
-
660
+
525
661
  def add_txn_to_batch(transaction, type, options)
526
662
  @txn_counts[:total] += 1
527
663
  xml = transaction.save_to_xml.to_s
@@ -537,24 +673,24 @@ module LitleOnline
537
673
  create_new_batch(path)
538
674
  end
539
675
  end
540
-
676
+
541
677
  def build_batch_header(options)
542
678
  request = BatchRequest.new
543
-
679
+
544
680
  request.numAccountUpdates = @txn_counts[:numAccountUpdates]
545
681
  request.merchantId = get_merchant_id(options)
546
682
  request.id = @txn_counts[:id]
547
-
683
+
548
684
  header = request.save_to_xml.to_s
549
- header['/>']= '>'
685
+ header['/>']= '>'
550
686
 
551
687
  return header
552
688
  end
553
-
689
+
554
690
  def get_config(field, options)
555
691
  options[field.to_s] == nil ? @config_hash[field.to_s] : options[field.to_s]
556
692
  end
557
-
693
+
558
694
  def get_merchant_id(options)
559
695
  options['merchantId'] || @config_hash['currency_merchant_map']['DEFAULT']
560
696
  end