Sumup.Transactions (Sumup v1.0.0)

Copy Markdown View Source

Transactions: read-heavy history and lookup endpoints (API version v2.1), plus refunds (API version v1.0).

Summary

Functions

Retrieves a single transaction. Exactly one lookup key must be given: :id, :transaction_code, :foreign_transaction_id, or :client_transaction_id.

Lists a single page of transaction history.

Lazily streams every transaction matching the given filters, following the response's next hypermedia link page by page. See Sumup.Pagination.

Refunds a transaction, fully or partially. Pass amount: for a partial refund; omit it for a full refund. Returns :ok on success (the API responds 204 No Content).

Functions

get(config, merchant_code, lookup)

@spec get(Sumup.Config.t(), String.t(), keyword()) ::
  {:ok, Sumup.Transaction.t()} | {:error, Sumup.Error.t()}

Retrieves a single transaction. Exactly one lookup key must be given: :id, :transaction_code, :foreign_transaction_id, or :client_transaction_id.

Sumup.Transactions.get(config, merchant_code, id: "tx_123")
Sumup.Transactions.get(config, merchant_code, client_transaction_id: "ctx_abc")

list(config, merchant_code, opts \\ [])

@spec list(Sumup.Config.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Sumup.Error.t()}

Lists a single page of transaction history.

  • :transaction_code (String.t/0) - Filter to a single transaction code.

  • :order - Sort direction (default "ascending").

  • :limit (pos_integer/0) - Page size.

  • :users (list of String.t/0) - Filter by one or more registered-user emails.

  • :statuses (list of String.t/0) - Filter by one or more of SUCCESSFUL, CANCELLED, FAILED, PENDING, REFUNDED.

  • :payment_types (list of String.t/0) - Filter by one or more payment types (CASH, POS, ECOM, ...).

  • :entry_modes (list of String.t/0) - Filter by one or more entry modes (CHIP, CONTACTLESS, ...).

  • :types (list of String.t/0) - Filter by one or more of PAYMENT, REFUND, CHARGE_BACK.

  • :changes_since (String.t/0) - ISO 8601 timestamp: only transactions changed since this time.

  • :oldest_time (String.t/0) - ISO 8601 lower bound (superseded by oldest_ref for pagination).

  • :newest_time (String.t/0) - ISO 8601 upper bound (superseded by newest_ref for pagination).

  • :oldest_ref (String.t/0) - Opaque cursor: fetch the page immediately older than this ref.

  • :newest_ref (String.t/0) - Opaque cursor: fetch the page immediately newer than this ref.

list_all(config, merchant_code, opts \\ [])

@spec list_all(Sumup.Config.t(), String.t(), keyword()) :: Enumerable.t()

Lazily streams every transaction matching the given filters, following the response's next hypermedia link page by page. See Sumup.Pagination.

Sumup.Transactions.list_all(config, merchant_code, statuses: ["SUCCESSFUL"])
|> Stream.map(& &1.amount)
|> Enum.to_list()

refund(config, merchant_code, transaction_id, params \\ [])

@spec refund(Sumup.Config.t(), String.t(), String.t(), keyword() | map()) ::
  :ok | {:error, Sumup.Error.t()}

Refunds a transaction, fully or partially. Pass amount: for a partial refund; omit it for a full refund. Returns :ok on success (the API responds 204 No Content).