OpenPayments.Types.OutgoingPayment (open_payments_elixir v1.0.0)

Copy Markdown View Source

Detailed outgoing-payment response data used by reads and listing.

Follows the pinned outgoing-payment schema: required absolute-URI id and wallet_address, HTTP(S) incoming-payment receiver, typed receive_amount, debit_amount and sent_amount, and RFC 3339 created_at. Optional quote_id is an absolute URI, failed is a boolean and metadata is a JSON object. Omission becomes nil and is omitted on export; explicit null is invalid. The schema's failed default does not insert a value: false remains distinct from omission.

Additional top-level fields are forbidden, including updatedAt and grant spent amounts. Creation responses with spent amounts use a separate schema. Permitted nested amount extensions, metadata, URI spelling, timestamp precision and decimal spelling are preserved. An inconsistent standalone example omits receiveAmount and has an invalid receiver; it is rejected without repair.

This codec does not compare assets or values, interpret failed as completion, enforce positivity, infer fees or exchange rates, fetch related resources or make payments. Node's operation-level payment consistency checks are separate from this data model.

Inspection exposes only id, failed and created_at. Explicit map/JSON exports include wallet, receiver, quote, amounts and metadata. Errors contain 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 strict outgoing-payment data and its three required typed amounts.

Exports protocol fields, including metadata and amounts, without validating.

Revalidates fields and typed amounts, treating nil optional fields as omitted.

Types

t()

@type t() :: %OpenPayments.Types.OutgoingPayment{
  created_at: String.t(),
  debit_amount: OpenPayments.Types.Amount.t(),
  failed: boolean() | 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 strict outgoing-payment data and its three required typed amounts.

to_map(payment)

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

Exports protocol fields, including metadata and amounts, without validating.

validate(payment)

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

Revalidates fields and typed amounts, treating nil optional fields as omitted.