OpenPayments.Quote (open_payments_elixir v1.0.0)

Copy Markdown View Source

Authenticated quote operations on an Open Payments resource server.

Reads sign a GET to a complete quote URL using the client's key and a per-call access token. Resource paths and queries are opaque; no provider path, wallet lookup or receiver lookup is inferred. HTTPS is required unless HTTP was explicitly enabled on the client. Redirects and automatic retries are disabled. Creation signs a POST to the resource server's quotes collection and returns the same typed quote data, with all amount inference left to the server.

Summary

Functions

Creates a quote using a signed POST with a typed or string-keyed request payload.

Fetches a quote using a signed GET and the required per-call access_token option.

Functions

create(client, base_url, payload, opts)

Creates a quote using a signed POST with a typed or string-keyed request payload.

Supply the resource-server base URL, a CreateQuote struct or protocol map, and the required per-call access_token option accepted by get/3. The SDK appends /quotes, preserving tenant paths and reusing a trailing slash. Base queries, including an empty marker, are rejected. Request URL/token rules apply.

Both typed and map payloads are validated before HTTP. Supply debit_amount, receive_amount, or neither when the receiver provides the amount; both are invalid. The server checks receiver amount availability, relevant assets, permissions and key binding. No wallet/receiver lookup or amount default occurs.

HTTP 201 returns typed quote data. Invalid success responses return decoding/invalid_response with status 201 and safe field paths; errors carry :create_quote. Following Node's quote operation, no response/request equality, FX, fee, value-order, positivity or local expiry rule is added.

This call does not send an outgoing payment, follow redirects, retry, refresh tokens, cache or automatically read back the quote. A timeout may occur after the server creates it; the caller decides how to reconcile that outcome.

get(client, url, opts)

@spec get(OpenPayments.Client.t(), String.t(), [
  {:access_token, String.t() | OpenPayments.Types.AccessToken.t()}
]) :: {:ok, OpenPayments.Types.Quote.t()} | {:error, OpenPayments.Error.t()}

Fetches a quote using a signed GET and the required per-call access_token option.

Supply an authenticated client and the full resource URL; no path is appended. Nondefault HTTPS ports and queries are supported. The token may be an opaque string or typed AccessToken, revalidated before using its value. Unsupported or duplicate options and typed continuation credentials are rejected. Request URL/token68 rules apply; server checks permissions, expiry and key binding.

HTTP 200 returns OpenPayments.Types.Quote with typed debit/receive amounts. Invalid schemas return decoding/invalid_response with status 200 and safe field paths; all errors carry :get_quote. The schema's optional expires_at remains string data, without local clock checks. Cross-asset amounts are valid.

Following Node's quote read, no FX/fee/value-order/positivity rule, requested URL/response identity equality, wallet match or receiver comparison is added. This call makes no payment and does not cache, refresh tokens or fetch related resources. Inspection omits wallet/receiver/amount/expiry data; explicit exports include them. Quote creation is available separately through create/4.