MPP.X402.Facilitator (mpp v0.19.0)

Copy Markdown View Source

Configurable x402 facilitator client (POST /verify and POST /settle).

A facilitator is either an HTTP base URL or an in-process map of functions. Requests disable retries so observed error bodies are not swallowed.

Summary

Functions

Build an HTTP facilitator client from a base URL.

Resolve a URL, function map, or existing client into a facilitator client.

Settle a verified payment payload.

Verify a payment payload against requirements.

Types

t()

@type t() :: %{
  verify: (map(), map() -> {:ok, map()} | {:error, term()}),
  settle: (map(), map() -> {:ok, map()} | {:error, term()})
}

Functions

http(url, opts \\ [])

@spec http(String.t(), keyword()) :: t()

Build an HTTP facilitator client from a base URL.

resolve(facilitator, opts \\ [])

@spec resolve(String.t() | t(), keyword()) :: t()

Resolve a URL, function map, or existing client into a facilitator client.

settle(map, payload, requirements)

@spec settle(t(), map(), map()) :: {:ok, map()} | {:error, term()}

Settle a verified payment payload.

verify(map, payload, requirements)

@spec verify(t(), map(), map()) :: {:ok, map()} | {:error, term()}

Verify a payment payload against requirements.