TreasuryPrime.Check (TreasuryPrime v1.0.0)

Copy Markdown View Source

Check issuing — mail a physical paper check from one of your accounts.

Creating a check

{:ok, check} =
  TreasuryPrime.Check.create(client, %{
    account_id: "acct_1234567890",
    amount: "900.00",
    memo: "Refund",
    message: "Thank you for your business.",
    recipient: %{
      name: "George Washington",
      address: %{
        street_line_1: "1600 Pennsylvania Ave.",
        city: "Washington",
        state: "DC",
        postal_code: "20003"
      }
    }
  }, idempotency_key: TreasuryPrime.Idempotency.generate_key())

Status lifecycle

pending -> sent -> (cashed, automatically detected) or expired (180 days after issuance if never cashed). A check can only be canceled within one hour of creation, while still pending; after that, request a stop_payment instead (moves to stop_payment_pending then stop_payment).

Summary

Functions

Cancels a check. Only possible within 1 hour of creation, while still pending.

Issues a check. Required: account_id, amount, recipient.

Fetches a single issued check by id.

Lists issued checks.

Requests a stop payment on a check that's already past the pending status.

Updates a check's status. See the module docs for the allowed lifecycle transitions.

Types

t()

@type t() :: %TreasuryPrime.Check{
  account_id: String.t() | nil,
  amount: String.t() | nil,
  check_number: String.t() | nil,
  created_at: String.t() | nil,
  error: String.t() | nil,
  id: String.t() | nil,
  memo: String.t() | nil,
  message: String.t() | nil,
  org_id: String.t() | nil,
  recipient: map() | nil,
  status: String.t() | 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()}

Cancels a check. Only possible within 1 hour of creation, while still pending.

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

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

Issues a check. Required: account_id, amount, recipient.

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 issued check 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 issued checks.

Filterable params

account_id, status.

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

stop_payment(client, id)

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

Requests a stop payment on a check that's already past the pending status.

update(client, id, params)

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

Updates a check's status. See the module docs for the allowed lifecycle transitions.

update!(client, id, params)

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