Unit.API.Payments (Unit v1.0.0)

Copy Markdown View Source

API module for all Unit payment types.

Supported rails

  • ACH (credit/debit, standard/same-day, SEC codes)
  • Wire (domestic Fedwire — final and irrevocable)
  • Book (internal, instant, free)
  • Push to Card (Visa/Mastercard fast disbursement)
  • Bulk (multi-rail batch)
  • Received ACH (incoming, with advance and return support)

Summary

Functions

Advance a received ACH payment (early fund availability).

Cancel a Pending payment.

Create an ACH payment.

Create a book payment (instant, free, internal transfer).

Create a bulk payment batch (ACH, Wire, and/or Book in one call).

Create a Push to Card payment (fast funds to a Visa/Mastercard debit card).

Create a wire (Fedwire) payment.

Get a payment by ID.

Get a bulk payment batch by ID.

Get a received ACH payment by ID.

List payments.

List received ACH payments.

Update a payment's tags.

Functions

advance_received_ach(id, opts \\ [])

@spec advance_received_ach(
  String.t(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Advance a received ACH payment (early fund availability).

cancel(id, opts \\ [])

@spec cancel(
  String.t(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Cancel a Pending payment.

create_ach(params, opts \\ [])

@spec create_ach(
  map(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Create an ACH payment.

Required params

  • :account_id, :amount, :direction ("Credit" or "Debit"), :description
  • :counterparty_id OR :counterparty (inline map)

Optional

  • :same_day, :addenda, :sec_code, :tags, :idempotency_key

create_book(params, opts \\ [])

@spec create_book(
  map(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Create a book payment (instant, free, internal transfer).

Required params

  • :account_id, :counterparty_account_id, :amount, :description

create_bulk(idempotency_key, requests, opts \\ [])

@spec create_bulk(String.t(), [map()], keyword()) :: {:ok, map()} | {:error, term()}

Create a bulk payment batch (ACH, Wire, and/or Book in one call).

The bulkPayments.finished webhook fires when all payments are processed.

create_push_to_card(params, opts \\ [])

@spec create_push_to_card(
  map(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Create a Push to Card payment (fast funds to a Visa/Mastercard debit card).

Required params

  • :account_id, :amount, :description
  • :card_number, :expiry_month, :expiry_year, :name, :network

create_wire(params, opts \\ [])

@spec create_wire(
  map(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Create a wire (Fedwire) payment.

Wire payments are final and irrevocable once sent.

Required params

  • :account_id, :amount, :description
  • :counterparty%{routing_number:, account_number:, account_type:, name:, address:}

Optional

  • :tags, :idempotency_key

get(id, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Get a payment by ID.

get_bulk(id, opts \\ [])

@spec get_bulk(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Get a bulk payment batch by ID.

get_received_ach(id, opts \\ [])

@spec get_received_ach(
  String.t(),
  keyword()
) :: {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Get a received ACH payment by ID.

list(opts \\ [])

@spec list(keyword()) :: {:ok, [Unit.Resource.Payment.t()], map()} | {:error, term()}

List payments.

Filter options

  • :account_id, :customer_id, :status, :type, :direction
  • :since, :until, :tags

list_received_ach(opts \\ [])

@spec list_received_ach(keyword()) ::
  {:ok, [Unit.Resource.Payment.t()], map()} | {:error, term()}

List received ACH payments.

return_received_ach(id, return_reason_code, opts \\ [])

@spec return_received_ach(String.t(), String.t(), keyword()) ::
  {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Return a received ACH payment.

update(id, params, opts \\ [])

@spec update(String.t(), map(), keyword()) ::
  {:ok, Unit.Resource.Payment.t()} | {:error, term()}

Update a payment's tags.