Class: AchClient::AchWorks::AchBatch

Inherits:
AchClient::Abstract::AchBatch show all
Defined in:
lib/ach_client/providers/soap/ach_works/ach_batch.rb

Overview

AchWorks implementation for AchBatch

Instance Method Summary collapse

Methods inherited from AchClient::Abstract::AchBatch

#initialize, #send_batch

Constructor Details

This class inherits a constructor from AchClient::Abstract::AchBatch

Instance Method Details

#do_send_batchArray<String>

Sends the batch to AchWorks using their SendACHTransBatch SOAP action If the action is successful, will return the filename that AchWorks gives us. We can use that to track the batch processing later on. If it fails, an exception will be thrown.

Returns:

  • (Array<String>)

    the external_ach_id’s for each transaction



13
14
15
16
17
18
19
20
# File 'lib/ach_client/providers/soap/ach_works/ach_batch.rb', line 13

def do_send_batch
  AchClient::AchWorks.wrap_request(
    method: :send_ach_trans_batch,
    message: self.to_hash,
    path: [:send_ach_trans_batch_response, :send_ach_trans_batch_result]
  )[:file_name]
  external_ach_ids
end

#to_hashHash

Converts this batch to a hash which can be sent to ACHWorks via Savon

Returns:

  • (Hash)

    hash to send to AchWorks



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ach_client/providers/soap/ach_works/ach_batch.rb', line 24

def to_hash
  CompanyInfo.build.to_hash.merge(
    {
      InpACHFile:{
        SSS: AchClient::AchWorks.s_s_s,
        LocID: AchClient::AchWorks.loc_i_d,
        ACHFileName: nil, # Docs say to leave this blank...
        TotalNumRecords: total_number_records,
        TotalDebitRecords: total_debit_records,
        TotalDebitAmount: total_debit_amount,
        TotalCreditRecords: total_credit_records,
        TotalCreditAmount: total_credit_amount,
        ACHRecords: {
          ACHTransRecord: @ach_transactions.map(&:to_hash)
        }
      }
    }
  )
end