Class: AchClient::AchWorks::AchTransaction

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

Overview

AchWorks implementation for AchTransaction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AchClient::Abstract::AchTransaction

#credit?, #debit?, #initialize

Constructor Details

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

Instance Attribute Details

#customer_idObject (readonly)

Returns the value of attribute customer_id.



14
15
16
# File 'lib/ach_client/providers/soap/ach_works/ach_transaction.rb', line 14

def customer_id
  @customer_id
end

Class Method Details

.argumentsObject

Parameters:

  • super (Array)

    args from parent class

  • customer_id (String)

    optional identifier for the customer



10
11
12
# File 'lib/ach_client/providers/soap/ach_works/ach_transaction.rb', line 10

def self.arguments
  super + [:customer_id]
end

Instance Method Details

#front_end_traceString

AchWorks Ach needs a “FrontEndTrace”, for each ACH transaction. These can be used to track the processing of the ACH after it has been submitted. You can use the id of your Ach record It should be unique per ACH The consumer is responsible for ensuring the uniqueness of this value

Returns:

  • (String)

    the 12 char front end trace



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ach_client/providers/soap/ach_works/ach_transaction.rb', line 66

def front_end_trace
  # I want to stop this before it goes through because AchWorks might
  # just truncate the value, which could result in lost Achs.
  if external_ach_id.length > 11
    raise 'AchWorks requires a FrontEndTrace of 12 chars or less'
  else
    # The front end trace MUST NOT start with a W.
    # Our front end trace starts with a Z.
    # The letter Z is not the letter W.
    "Z#{external_ach_id}"
  end
end

#sendString

Send this transaction individually to AchWorks

Returns:

  • (String)

    the front end trace



18
19
20
21
22
23
24
25
26
# File 'lib/ach_client/providers/soap/ach_works/ach_transaction.rb', line 18

def send
  AchClient::AchWorks.wrap_request(
    method: :send_ach_trans,
    message: AchClient::AchWorks::CompanyInfo.build.to_hash.merge({
      InpACHTransRecord: self.to_hash
    }),
    path: [:send_ach_trans_response, :send_ach_trans_result]
  )[:front_end_trace][1..-1]
end

#to_hashHash

AchWorks

Returns:

  • (Hash)

    turns this transaction into a hash that can be sent to



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ach_client/providers/soap/ach_works/ach_transaction.rb', line 31

def to_hash
  {
    SSS: AchClient::AchWorks.s_s_s,
    LocID: AchClient::AchWorks.loc_i_d,
    FrontEndTrace: front_end_trace,
    CustomerName: merchant_name,
    CustomerRoutingNo: routing_number.to_s,
    CustomerAcctNo: .to_s,
    OriginatorName: originator_name.try(:first, 16),
    TransactionCode: sec_code,
    CustTransType:
      AchClient::AchWorks::TransactionTypeTransformer.serialize_to_provider_value(
        transaction_type
      ),
    CustomerID: customer_id,
    CustomerAcctType:
      AchClient::AchWorks::AccountTypeTransformer.serialize_to_provider_value(
        self.
      ),
    TransAmount: amount,
    CheckOrTransDate: DateFormatter.format(),
    EffectiveDate: DateFormatter.format(),
    Memo: memo.try(:first, 10),
    OpCode: 'S', # Check this
    AccountSet: '1'
  }
end