ach_client 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e40c40c7ee42a6264c64f512772b254fac48b70cb7bb323ba238594c3d2d50c
4
- data.tar.gz: a6d925e6f0a9682e085de0f1d12240c827cf769d521ee66fabe7001ade43fd64
3
+ metadata.gz: db2454a8ff3bb7662637a5cee010020ed14a3515d6eb47efe369ccbdc9bc4be4
4
+ data.tar.gz: 57751a71e4e2b8875da5d045d21f2c75c9261ff909bb20a765b1dc6eeb7faf00
5
5
  SHA512:
6
- metadata.gz: 86303a731c6e1c4de5f4a82fa8a12f2f9f955e3ef70601c423d907282b50e2e5992a762f4736223bab87672b28a86b566fa112c55c0e9a0f7fd2c9c819dbc6c3
7
- data.tar.gz: 71299fac7355cd6b0a48e0245e8aa19e01f809f4acdcc00f97afda028c0f18dc0bb8792fabd5b242c6e590317f83385cef7e434fac395d3ad3ac8371897a1cc4
6
+ metadata.gz: 42622b2e2e29a203713131b2f0523110b52ec3e61a3f5c8c2a5166da5787f045daee6886ea1d5fb52a498b0bc9ca771cd3cb475706b5e542e4f037f265ffbea5
7
+ data.tar.gz: febbaf712c3749e5417d55d9b247a7cde525a55e051be93bd44c0568392a6a5050cf42657971541869855516a66bc606d2ae16daf8da444a9b85b845816d66c2
@@ -0,0 +1 @@
1
+ * @ForwardFinancing/funding-app-smes
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.6.8
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.5.0
1
+ ruby 2.6.8
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, ForwardFinancing
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  ## Overview
12
12
 
13
13
  The AchClient gem provides a common interface for working with a variety of
14
- ACH providers.
14
+ ACH providers. This is an **OPEN SOURCE PROJECT, PUBLICLY ACCESSIBLE**, and licensed under the BSD 3-Clause license
15
15
 
16
16
  Supported features include:
17
17
 
data/ach_client.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'ach', '~> 0'
33
33
 
34
34
  # Handy ruby behavior from rails
35
- spec.add_dependency 'activesupport'
35
+ spec.add_dependency 'activesupport', '< 6' # Need to rename .parent to .module_parent before upgrade
36
36
 
37
37
  # SFTP client (for Bank providers)
38
38
  spec.add_dependency 'net-sftp'
@@ -14,6 +14,8 @@ module AchClient
14
14
  "ACCESS DENIED"
15
15
  ]
16
16
 
17
+ EMPTY_RETURNS_RESPONSE = 'NO RETURNS REPORTED'.freeze
18
+
17
19
  ##
18
20
  # ICheckGateway does not support this
19
21
  def self.most_recent
@@ -34,31 +36,74 @@ module AchClient
34
36
  end
35
37
  end
36
38
 
37
- # Wrapper for the range response endpoint
38
- # @return [Hash{String => [AchClient::AchResponse]}] Hash with
39
+ # @return Hash{String => [AchClient::AchResponse]} Hash with
39
40
  # confirmation number as the key, lists of AchResponse objects as values
40
41
  def self.in_range(start_date:, end_date:)
41
42
  Helpers::Utils.hashlist_merge(
43
+ check_for_late_returns(start_date: start_date, end_date: end_date) +
44
+ pull_transaction_report(start_date: start_date, end_date: end_date)
45
+ )
46
+ end
47
+
48
+ # @return [Hash{String => [AchClient::AchResponse]}] List of hashes with
49
+ # confirmation number as the key, lists of AchResponse objects as values
50
+ private_class_method def self.pull_transaction_report(start_date:, end_date:)
51
+ AchClient::ICheckGateway.wrap_request(
52
+ method: :pull_transaction_report,
53
+ message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
54
+ startDate: start_date,
55
+ endDate: end_date
56
+ })
57
+ ).split("\n").select do |record|
58
+ check_for_errors(record)
59
+ # Only the records that start with ICHECK are ACH transactions.
60
+ # Everything else is other types of transactions such as credit card swipes which are outside
61
+ # the scope of this library
62
+ record.start_with?('ICHECK')
63
+ end.map do |record|
64
+ # The 4th column is the external_ach_id which becomes the hash key
65
+ {
66
+ record.split('|')[3] =>
67
+ [
68
+ AchClient::ICheckGateway::ResponseRecordProcessor
69
+ .process_response_record(record)
70
+ ]
71
+ }
72
+ end
73
+ end
74
+
75
+ # The pull_transaction_report method returns ACHs by effective entry date, which won't necessarily include
76
+ # any late returns that were returned outside the window of pending ACHs.
77
+ # This uses a separate endpoint which gives back returned ACHs by the return date, which will include late
78
+ # returns
79
+ # @return [Hash{String => [AchClient::AchResponse]}] List of hashes with
80
+ # confirmation number as the key, lists of AchResponse objects as values
81
+ private_class_method def self.check_for_late_returns(start_date:, end_date:)
82
+ (start_date..end_date).map do |date|
42
83
  AchClient::ICheckGateway.wrap_request(
43
- method: :pull_transaction_report,
84
+ method: :pull_returned_checks,
44
85
  message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
45
- startDate: start_date,
46
- endDate: end_date
86
+ ReturnedDate: date
47
87
  })
48
- ).split("\n").select do |record|
49
- check_for_errors(record)
50
- # Ignore credit card swipes if there are any
51
- record.start_with?('ICHECK')
52
- end.map do |record|
53
- {
54
- record.split('|')[3] =>
55
- [
56
- AchClient::ICheckGateway::ResponseRecordProcessor
57
- .process_response_record(record)
58
- ]
59
- }
88
+ ).split("\n").map do |record|
89
+ if record.include?("|")
90
+ # Each record returned by the API is a pipe separated list with 2 columns:
91
+ # Example: external_ach_id|R01\r\n
92
+ external_ach_id, return_code = record.split('|')
93
+ {external_ach_id => [AchClient::ReturnedAchResponse.new(
94
+ amount: nil, # response does not include amount
95
+ date: date,
96
+ return_code: AchClient::ReturnCodes.find_by(code: return_code)
97
+ )]}
98
+ elsif record.include?(EMPTY_RETURNS_RESPONSE)
99
+ # Server returns an error message instead of an empty list, so we catch the error message and return our
100
+ # own empty response
101
+ {}
102
+ else
103
+ raise "Couldnt process ICheckGateway Late Returns Response: #{record}"
104
+ end
60
105
  end
61
- )
106
+ end.reduce(&:+)
62
107
  end
63
108
  end
64
109
  end
@@ -10,11 +10,13 @@ module AchClient
10
10
  AMOUNT_COLUMN = 15
11
11
  # The column index with the record submission date
12
12
  DATE_COLUMN = 17
13
- # THe string index range within the record status with the return code
13
+ # The string index range within the record status with the return code
14
14
  RETURN_CODE_INDEX = 3..5
15
15
 
16
16
  ## Transforms ICheckGateway transaction report response records into
17
- # AchClient::Response objects
17
+ # AchClient::Response object
18
+ # Here is an example record:
19
+ # ICHECK|N||external_ach_id|abc||||||||BC|012345678|********1234|250.00|D|9/12/2016|05:03:04|C1234-1234||AutoCheck|||abcde|CCD|||\r\ns
18
20
  # @param record [String] the | separated record string from ICheckGateway
19
21
  # @return [AchClient::AchResponse] our representation of the response
20
22
  def self.process_response_record(record)
@@ -1,4 +1,4 @@
1
1
  module AchClient
2
2
  # Increment this when changes are published
3
- VERSION = '2.1.0'
3
+ VERSION = '3.0.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ach_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Cotter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ach
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "<"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-sftp
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -248,7 +248,7 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
- description:
251
+ description:
252
252
  email:
253
253
  - zach@zachcotter.com
254
254
  executables: []
@@ -256,14 +256,15 @@ extensions: []
256
256
  extra_rdoc_files: []
257
257
  files:
258
258
  - ".codeclimate.yml"
259
+ - ".github/CODEOWNERS"
259
260
  - ".gitignore"
260
261
  - ".rubocop.yml"
261
262
  - ".ruby-version"
262
263
  - ".tool-versions"
263
264
  - ".tool-versions-e"
264
- - ".travis.yml"
265
265
  - CHANGELOG.md
266
266
  - Gemfile
267
+ - LICENSE
267
268
  - README.md
268
269
  - Rakefile
269
270
  - ach_client.gemspec
@@ -332,7 +333,7 @@ homepage: https://github.com/ForwardFinancing/ach_client
332
333
  licenses:
333
334
  - MIT
334
335
  metadata: {}
335
- post_install_message:
336
+ post_install_message:
336
337
  rdoc_options: []
337
338
  require_paths:
338
339
  - lib
@@ -348,9 +349,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
349
  - !ruby/object:Gem::Version
349
350
  version: '0'
350
351
  requirements: []
351
- rubyforge_project:
352
- rubygems_version: 2.7.3
353
- signing_key:
352
+ rubygems_version: 3.0.3.1
353
+ signing_key:
354
354
  specification_version: 4
355
355
  summary: Adapter to interact with various ACH service providers
356
356
  test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- before_install:
3
- - export TZ=US/Eastern
4
- - export CODECLIMATE_REPO_TOKEN=1fc324a28beed303e632765cca14487904a23023d85b9127a288f04cc007d28d
5
- - export CC_TEST_REPORTER_ID=1fc324a28beed303e632765cca14487904a23023d85b9127a288f04cc007d28d
6
- - date
7
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
- - chmod +x ./cc-test-reporter
9
- - ./cc-test-reporter before-build
10
- script:
11
- - bundle exec rake test
12
- after_script:
13
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
14
- notifications:
15
- email: false