Class: AchClient::Abstract::AchTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/ach_client/providers/abstract/ach_transaction.rb

Overview

Generic representation of a single Ach transaction

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arguments) ⇒ AchTransaction

provider to use with your transaction

Parameters:

  • account_number (String)

    Merchant’s account number

  • account_type (AchClient::AccountTypes::AccountType)

    Merchant’s account type (debit or credit), must be an instance of AchClient::AccountTypes::AccountType

  • amount (BigDecimal)

    Amount of the ACH transaction

  • effective_entry_date (Date)

    The date the transaction should be enacted

  • external_ach_id (String)

    Tracking string you would like the

  • memo (String)

    Ach memo thing

  • merchant_name (String)

    Name associated with merchantaccount we are ACHing with

  • originator_name (String)

    String identifying you, will appear on merchants bank statement

  • routing_number (String)

    Routing number of the merchant’s account

  • sec_code (String)
  • transaction_type (AchClient::TransactionTypes::TransactionType)

    debit or



45
46
47
48
49
50
51
52
53
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 45

def initialize(*arguments)
  args = arguments.extract_options!
  self.class.arguments.each do |param|
    self.instance_variable_set(
      "@#{param}".to_sym,
      args[param]
    )
  end
end

Class Method Details

.argumentsArray

instance attributes

Returns:

  • (Array)

    A list of arguments to use in the initializer, and as



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 10

def self.arguments
  [
    :account_number,
    :account_type,
    :amount,
    :effective_entry_date,
    :external_ach_id,
    :memo,
    :merchant_name,
    :originator_name,
    :routing_number,
    :sec_code,
    :transaction_type
  ]
end

Instance Method Details

#credit?Boolean

Returns true if transaction is a credit.

Returns:

  • (Boolean)

    true if transaction is a credit



61
62
63
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 61

def credit?
  transaction_type == AchClient::TransactionTypes::Credit
end

#debit?Boolean

Returns true if transaction is a debit.

Returns:

  • (Boolean)

    true if transaction is a debit



56
57
58
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 56

def debit?
  transaction_type == AchClient::TransactionTypes::Debit
end

#do_sendObject

The implementation of sending the transaction, as implemented by the

subclass


77
78
79
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 77

def do_send
  raise AbstractMethodError
end

#sendObject

Check if the transaction is sendable, and if so, send it according

to the subclass implementation


67
68
69
70
71
72
73
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 67

def send
  if sendable?
    do_send
  else
    raise InvalidAchTransactionError
  end
end

#sendable?Boolean

Prevent sending of invalid transactions, such as those where the

effective entry date is in the past

Returns:

  • (Boolean)


83
84
85
# File 'lib/ach_client/providers/abstract/ach_transaction.rb', line 83

def sendable?
  &.future? || &.today?
end