ach_client 2.0.0 → 3.0.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.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +4 -0
- data/LICENSE +29 -0
- data/README.md +7 -1
- data/ach_client.gemspec +1 -1
- data/lib/ach_client/providers/soap/fake/ach_status_checker.rb +42 -0
- data/lib/ach_client/providers/soap/i_check_gateway/ach_status_checker.rb +63 -18
- data/lib/ach_client/providers/soap/i_check_gateway/response_record_processor.rb +4 -2
- data/lib/ach_client/version.rb +1 -1
- metadata +14 -13
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db2454a8ff3bb7662637a5cee010020ed14a3515d6eb47efe369ccbdc9bc4be4
|
4
|
+
data.tar.gz: 57751a71e4e2b8875da5d045d21f2c75c9261ff909bb20a765b1dc6eeb7faf00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42622b2e2e29a203713131b2f0523110b52ec3e61a3f5c8c2a5166da5787f045daee6886ea1d5fb52a498b0bc9ca771cd3cb475706b5e542e4f037f265ffbea5
|
7
|
+
data.tar.gz: febbaf712c3749e5417d55d9b247a7cde525a55e051be93bd44c0568392a6a5050cf42657971541869855516a66bc606d2ae16daf8da444a9b85b845816d66c2
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @ForwardFinancing/funding-app-smes
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.8
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 2.6.8
|
data/CHANGELOG.md
CHANGED
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
|
|
@@ -197,6 +197,12 @@ information has changed. Check the return code on the response object for
|
|
197
197
|
details on what happened. Check the corrections hash on the response object for
|
198
198
|
the new attributes
|
199
199
|
|
200
|
+
### Testing
|
201
|
+
|
202
|
+
The fake ACH provider namespace provides a status checker `AchClient::Fake::AchStatusChecker` that always returns the
|
203
|
+
same responses. The external_ach_id for each response will be one of
|
204
|
+
`['processing', 'settled', 'returned', 'corrected', 'late_returned']`
|
205
|
+
|
200
206
|
## Logging
|
201
207
|
|
202
208
|
For record keeping purposes, there is a log provider that allows you to hook
|
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'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module AchClient
|
2
|
+
class Fake
|
3
|
+
# Fake ACH polling that always returns the same set of results.
|
4
|
+
class AchStatusChecker < Abstract::AchStatusChecker
|
5
|
+
|
6
|
+
def self.most_recent
|
7
|
+
in_range(start_date: Date.today - 3.days, end_date: Date.today)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.in_range(start_date:, end_date:)
|
11
|
+
{
|
12
|
+
'processing' => [AchClient::ProcessingAchResponse.new(amount: 100.0, date: start_date)],
|
13
|
+
'settled' => [AchClient::SettledAchResponse.new(amount: 100.0, date: start_date)],
|
14
|
+
'returned' => [
|
15
|
+
AchClient::ReturnedAchResponse.new(
|
16
|
+
amount: 100.0,
|
17
|
+
date: start_date,
|
18
|
+
return_code: AchClient::ReturnCodes.find_by(code: 'R01')
|
19
|
+
)
|
20
|
+
],
|
21
|
+
'corrected' => [
|
22
|
+
AchClient::CorrectedAchResponse.new(
|
23
|
+
amount: 100.0,
|
24
|
+
date: start_date,
|
25
|
+
return_code: AchClient::ReturnCodes.find_by(code: 'XZ2'),
|
26
|
+
corrections: '123456789'
|
27
|
+
)
|
28
|
+
],
|
29
|
+
'late_returned' => [
|
30
|
+
AchClient::SettledAchResponse.new(amount: 100.0, date: start_date),
|
31
|
+
AchClient::ReturnedAchResponse.new(
|
32
|
+
amount: 100.0,
|
33
|
+
date: end_date,
|
34
|
+
return_code: AchClient::ReturnCodes.find_by(code: 'R08')
|
35
|
+
)
|
36
|
+
]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -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
|
-
#
|
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: :
|
84
|
+
method: :pull_returned_checks,
|
44
85
|
message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
|
45
|
-
|
46
|
-
endDate: end_date
|
86
|
+
ReturnedDate: date
|
47
87
|
})
|
48
|
-
).split("\n").
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
#
|
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
|
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)
|
data/lib/ach_client/version.rb
CHANGED
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:
|
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:
|
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: '
|
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: '
|
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
|
@@ -314,6 +315,7 @@ files:
|
|
314
315
|
- lib/ach_client/providers/soap/ach_works/response_record_processor.rb
|
315
316
|
- lib/ach_client/providers/soap/ach_works/transaction_type_transformer.rb
|
316
317
|
- lib/ach_client/providers/soap/fake/ach_batch.rb
|
318
|
+
- lib/ach_client/providers/soap/fake/ach_status_checker.rb
|
317
319
|
- lib/ach_client/providers/soap/fake/ach_transaction.rb
|
318
320
|
- lib/ach_client/providers/soap/fake/fake.rb
|
319
321
|
- lib/ach_client/providers/soap/i_check_gateway/account_type_transformer.rb
|
@@ -331,7 +333,7 @@ homepage: https://github.com/ForwardFinancing/ach_client
|
|
331
333
|
licenses:
|
332
334
|
- MIT
|
333
335
|
metadata: {}
|
334
|
-
post_install_message:
|
336
|
+
post_install_message:
|
335
337
|
rdoc_options: []
|
336
338
|
require_paths:
|
337
339
|
- lib
|
@@ -347,9 +349,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
347
349
|
- !ruby/object:Gem::Version
|
348
350
|
version: '0'
|
349
351
|
requirements: []
|
350
|
-
|
351
|
-
|
352
|
-
signing_key:
|
352
|
+
rubygems_version: 3.0.3.1
|
353
|
+
signing_key:
|
353
354
|
specification_version: 4
|
354
355
|
summary: Adapter to interact with various ACH service providers
|
355
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
|