OpenPayments.Types.CreateIncomingPayment (open_payments_elixir v1.0.0)

Copy Markdown View Source

The JSON payload for creating an incoming payment.

Follows create-incoming-payment-request: required absolute-URI wallet_address, optional typed incoming_amount, RFC 3339 expires_at and JSON-object metadata. Omitted optional fields become nil and are omitted on export; explicit JSON nulls and additional top-level fields are invalid. Empty metadata is retained.

URI/timestamp spelling and amount data are preserved. This codec does not resolve payment pointers, fetch a wallet, compare wallet assets, require a positive amount or compare expiry with the current time. Wallet-asset matching and other operation-level checks need context beyond this payload.

Inspection exposes only expiry metadata. Explicit map/JSON exports include the wallet, amount and metadata values. Errors retain safe field paths without rejected data. Validate modified structs with validate/1; to_map/1 converts shape without validating it. This type makes no HTTP requests.

Summary

Functions

Decodes the strict creation payload and its optional typed amount.

Converts to protocol fields, including metadata, without validating.

Revalidates typed payload fields, treating nil optional values as omitted.

Types

t()

@type t() :: %OpenPayments.Types.CreateIncomingPayment{
  expires_at: String.t() | nil,
  incoming_amount: OpenPayments.Types.Amount.t() | nil,
  metadata: %{optional(String.t()) => term()} | nil,
  wallet_address: String.t()
}

Functions

from_map(data)

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

Decodes the strict creation payload and its optional typed amount.

to_map(request)

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

Converts to protocol fields, including metadata, without validating.

validate(request)

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

Revalidates typed payload fields, treating nil optional values as omitted.