Behaviour for payment protocol implementations.
Each protocol handles a specific 402 payment flow. The auto-pay plugin
tries each configured protocol's detect?/2 to find one that matches
the server's 402 response, then delegates signing to that protocol.
Implementations
Raxol.Payments.Protocols.X402-- Coinbase x402 (ERC-3009)Raxol.Payments.Protocols.MPP-- Stripe/Tempo Machine Payments ProtocolRaxol.Payments.Protocols.Xochi-- cross-chain private payments (agent-facing)Raxol.Payments.Protocols.Permit2-- Permit2PermitWitnessTransferFromsigning for Riddler's/orderRaxol.Payments.Protocols.Riddler-- cross-chain intents (deprecated, delegates to Xochi)
Summary
Callbacks
Extract the payment amount from a parsed challenge.
Build authorization headers for the payment.
Check if this protocol can handle the given 402 response.
Human-readable protocol name.
Parse the 402 response headers into a challenge map.
Parse the payment receipt from a successful response.
Functions
Resolve a protocol atom to its implementation module.
Types
Callbacks
Extract the payment amount from a parsed challenge.
Returns the amount in human-decimal units (e.g. 1.00 means
$1.00 USDC, not 1_000_000 atomic units). Implementations are
expected to normalize via Raxol.Payments.Assets.to_human/2 using
the challenge's asset metadata. The SpendingPolicy caps are
written in the same units.
@callback build_payment(challenge :: challenge(), wallet :: module()) :: {:ok, headers()} | {:error, term()}
Build authorization headers for the payment.
Signs the challenge using the provided wallet module and returns headers to attach to the retry request.
Check if this protocol can handle the given 402 response.
Inspects the response status and headers to determine if this protocol's payment flow applies.
@callback name() :: String.t()
Human-readable protocol name.
Parse the 402 response headers into a challenge map.
Extracts payment requirements (price, currency, recipient, network) from the protocol-specific headers.
Parse the payment receipt from a successful response.
Extracts confirmation details (tx hash, amount settled, etc.) from the response headers after a successful paid request.