TreasuryPrime.Ach (TreasuryPrime v1.0.0)

Copy Markdown View Source

ACH transfers — electronic transfers between bank accounts at different banks, originated through Treasury Prime (for incoming, externally originated ACH, see TreasuryPrime.IncomingAch).

Creating a transfer

{:ok, ach} =
  TreasuryPrime.Ach.create(client, %{
    account_id: "acct_123456",
    counterparty_id: "cp_098765",
    amount: "100.00",
    direction: "credit",
    sec_code: "ccd"
  }, idempotency_key: TreasuryPrime.Idempotency.generate_key())

direction is from the perspective of account_id: "credit" sends money to the counterparty, "debit" pulls money from the counterparty.

sec_code is one of ccd, ppd, tel, web, cie, arc, boc — see the ACH network rules for which applies to your use case. Some codes require sec_details (e.g. payment_type for web/tel).

service defaults to "standard"; pass "sameday" for same-day ACH (subject to cutoff times and additional fees from your bank).

Summary

Functions

Convenience for update(client, id, %{status: "canceled"}).

Originates an ACH transfer. Required: account_id, counterparty_id, amount, direction, sec_code. Strongly recommended: pass idempotency_key: in opts (see TreasuryPrime.Idempotency).

Fetches a single ACH transfer by id.

Lists ACH transfers.

Updates an ACH transfer. The primary use is cancellation: pass %{status: "canceled"} while the transfer is still "pending".

Types

sec_details()

@type sec_details() :: %{
  optional(:check_serial_number) => String.t(),
  optional(:individual_id_number) => String.t(),
  optional(:individual_name) => String.t(),
  optional(:payment_type) => String.t()
}

t()

@type t() :: %TreasuryPrime.Ach{
  account_id: String.t() | nil,
  addenda: [String.t()] | nil,
  amount: String.t() | nil,
  bank_id: String.t() | nil,
  bankdata: map() | nil,
  batch_key: String.t() | nil,
  counterparty_id: String.t() | nil,
  created_at: String.t() | nil,
  description: String.t() | nil,
  direction: String.t() | nil,
  effective_date: String.t() | nil,
  error: String.t() | nil,
  id: String.t() | nil,
  noc_change_code: String.t() | nil,
  noc_corrected_data: String.t() | nil,
  org_id: String.t() | nil,
  originator_name: String.t() | nil,
  scheduled_settlement: String.t() | nil,
  sec_code: String.t() | nil,
  sec_details: sec_details() | nil,
  service: String.t() | nil,
  status: String.t() | nil,
  trace_number: String.t() | nil,
  trace_suffix: integer() | nil,
  updated_at: String.t() | nil,
  userdata: map() | nil
}

Functions

cancel(client, id)

@spec cancel(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Convenience for update(client, id, %{status: "canceled"}).

create(client, params, opts \\ [])

@spec create(TreasuryPrime.Client.t(), map(), keyword()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Originates an ACH transfer. Required: account_id, counterparty_id, amount, direction, sec_code. Strongly recommended: pass idempotency_key: in opts (see TreasuryPrime.Idempotency).

create!(client, params, opts \\ [])

@spec create!(TreasuryPrime.Client.t(), map(), keyword()) :: t()

get(client, id)

@spec get(TreasuryPrime.Client.t(), String.t()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Fetches a single ACH transfer by id.

get!(client, id)

@spec get!(TreasuryPrime.Client.t(), String.t()) :: t()

list(client, params \\ %{})

@spec list(TreasuryPrime.Client.t(), map()) ::
  {:ok, TreasuryPrime.Page.t()} | {:error, TreasuryPrime.Error.t()}

Lists ACH transfers.

Filterable params

account_id, counterparty_id, direction, effective_date, service, status, trace_number.

list!(client, params \\ %{})

update(client, id, params)

@spec update(TreasuryPrime.Client.t(), String.t(), map()) ::
  {:ok, t()} | {:error, TreasuryPrime.Error.t()}

Updates an ACH transfer. The primary use is cancellation: pass %{status: "canceled"} while the transfer is still "pending".

update!(client, id, params)

@spec update!(TreasuryPrime.Client.t(), String.t(), map()) :: t()