OpenPayments.Types.OutgoingPaymentWithSpentAmounts (open_payments_elixir v1.0.0)

Copy Markdown View Source

An outgoing-payment creation response with optional grant spent amounts.

Shares all declared detail fields and their validation with OutgoingPayment. Fields remain flat, and grant_spent_debit_amount and grant_spent_receive_amount become typed Amount structs when present. Either, both or neither may be supplied. Omission becomes nil and is omitted on export; explicit null is invalid. This differs from the separate grant-spent endpoint's nullable fields.

The pinned creation-response schema permits additional JSON fields, retained in extensions. The read/list OutgoingPayment schema instead forbids extras. Unknown fields are not interpreted, including any updatedAt extension. Shared fields preserve URI/timestamp/decimal spelling, false failed and empty metadata without inserting defaults. All typed children are revalidated.

No grant limit, asset, value, failure-state or time comparison is performed by this codec. Grant amounts need not match this payment's amounts: they describe spending under the current grant. Operation-level payment consistency checks are separate. This type makes no requests, tracks no grant state and makes no payments.

Inspection exposes only id, failed and created_at. Explicit map/JSON exports include wallet, receiver, quote, all amounts, metadata and extensions. Errors retain safe field paths without rejected data or unknown field names. Validate modified structs with validate/1; to_map/1 converts without validating.

Summary

Functions

Decodes flat payment details, optional typed spent amounts and JSON extensions.

Exports all protocol amounts, metadata and extensions without validating.

Revalidates shared details, all typed amounts and reserved-field-safe extensions.

Types

t()

@type t() :: %OpenPayments.Types.OutgoingPaymentWithSpentAmounts{
  created_at: String.t(),
  debit_amount: OpenPayments.Types.Amount.t(),
  extensions: %{optional(String.t()) => term()},
  failed: boolean() | nil,
  grant_spent_debit_amount: OpenPayments.Types.Amount.t() | nil,
  grant_spent_receive_amount: OpenPayments.Types.Amount.t() | nil,
  id: String.t(),
  metadata: %{optional(String.t()) => term()} | nil,
  quote_id: String.t() | nil,
  receive_amount: OpenPayments.Types.Amount.t(),
  receiver: String.t(),
  sent_amount: OpenPayments.Types.Amount.t(),
  wallet_address: String.t()
}

Functions

from_map(data)

@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}

Decodes flat payment details, optional typed spent amounts and JSON extensions.

to_map(payment)

@spec to_map(t()) :: map()

Exports all protocol amounts, metadata and extensions without validating.

validate(payment)

@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}

Revalidates shared details, all typed amounts and reserved-field-safe extensions.