# `OpenPayments.Types.OutgoingPaymentWithSpentAmounts`
[🔗](https://github.com/interledger/open-payments-elixir/blob/v1.0.0/lib/open_payments/types/outgoing_payment_with_spent_amounts.ex#L1)

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.

# `t`

```elixir
@type t() :: %OpenPayments.Types.OutgoingPaymentWithSpentAmounts{
  created_at: String.t(),
  debit_amount: OpenPayments.Types.Amount.t(),
  extensions: %{optional(String.t()) =&gt; 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()) =&gt; 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()
}
```

# `from_map`

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

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

# `to_map`

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

Exports all protocol amounts, metadata and extensions without validating.

# `validate`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
