Mercury.Payments (mercury_client v1.0.0)

Copy Markdown View Source

Mercury payment and transfer APIs: internal transfers between accounts in the same org, and send-money requests that require approval.

Summary

Functions

Transfers funds between two Mercury accounts in the same org, returning both the debit and credit legs. POST /transfer

Returns a single send-money approval request by ID. GET /send-money-approval-requests/{id}

Returns one page of send-money approval requests. GET /send-money-approval-requests

Creates a send-money request that requires approval before execution. POST /request-send-money

A lazy, auto-paginating stream of every send-money approval request.

Functions

create_internal_transfer(client, attrs)

@spec create_internal_transfer(
  client :: Mercury.Client.t(),
  attrs :: map() | keyword()
) ::
  {:ok, Mercury.InternalTransferResponse.t()} | {:error, Exception.t()}

Transfers funds between two Mercury accounts in the same org, returning both the debit and credit legs. POST /transfer

Mercury.Payments.create_internal_transfer(client, %{
  from_account_id: checking_id,
  to_account_id: savings_id,
  amount: 1_000.0
})

create_internal_transfer!(client, attrs)

@spec create_internal_transfer!(
  client :: Mercury.Client.t(),
  attrs :: map() | keyword()
) ::
  Mercury.InternalTransferResponse.t()

get_approval_request(client, request_id)

@spec get_approval_request(client :: Mercury.Client.t(), request_id :: String.t()) ::
  {:ok, Mercury.SendMoneyApprovalRequest.t()} | {:error, Exception.t()}

Returns a single send-money approval request by ID. GET /send-money-approval-requests/{id}

get_approval_request!(client, request_id)

@spec get_approval_request!(client :: Mercury.Client.t(), request_id :: String.t()) ::
  Mercury.SendMoneyApprovalRequest.t()

list_approval_requests(client, opts \\ [])

@spec list_approval_requests(client :: Mercury.Client.t(), opts :: keyword()) ::
  {:ok, Mercury.Page.t(Mercury.SendMoneyApprovalRequest.t())}
  | {:error, Exception.t()}

Returns one page of send-money approval requests. GET /send-money-approval-requests

Accepts :account_id and :status filters in addition to the common list options.

list_approval_requests!(client, opts \\ [])

@spec list_approval_requests!(client :: Mercury.Client.t(), opts :: keyword()) ::
  Mercury.Page.t(Mercury.SendMoneyApprovalRequest.t())

request_send_money(client, attrs)

@spec request_send_money(client :: Mercury.Client.t(), attrs :: map() | keyword()) ::
  {:ok, Mercury.SendMoneyApprovalRequest.t()} | {:error, Exception.t()}

Creates a send-money request that requires approval before execution. POST /request-send-money

request_send_money!(client, attrs)

@spec request_send_money!(client :: Mercury.Client.t(), attrs :: map() | keyword()) ::
  Mercury.SendMoneyApprovalRequest.t()

stream_approval_requests(client, opts \\ [])

@spec stream_approval_requests(client :: Mercury.Client.t(), opts :: keyword()) ::
  Enumerable.t()

A lazy, auto-paginating stream of every send-money approval request.