OpenPayments.PaymentPointer (open_payments_elixir v1.0.0)

Copy Markdown View Source

Converts payment-pointer shorthand into an HTTPS discovery URL.

Payment pointers use $host[/path] syntax. A missing or root path resolves to /.well-known/pay. Other paths, including their percent encoding and trailing slashes, are preserved. User-info, explicit ports, queries, and fragments are forbidden, including empty query and fragment components.

This is a pure syntax conversion. Whether the resulting endpoint supports Open Payments must be checked during discovery. Apply it to user input rather than to wallet-address response fields.

See the payment-pointer specification.

Examples

iex> OpenPayments.PaymentPointer.to_url("$wallet.example.com")
{:ok, "https://wallet.example.com/.well-known/pay"}

iex> OpenPayments.PaymentPointer.to_url("$wallet.example.com/")
{:ok, "https://wallet.example.com/.well-known/pay"}

iex> OpenPayments.PaymentPointer.to_url("$wallet.example.com/alice")
{:ok, "https://wallet.example.com/alice"}

Summary

Functions

Converts a valid payment pointer to a full HTTPS URL without making a request.

Functions

to_url(arg1)

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

Converts a valid payment pointer to a full HTTPS URL without making a request.