Payment-aware Req plugin.
Intercepts HTTP 402 responses, selects a challenge through
MPP.Client.SelectionPolicy, pays via MPP.Client.MultiProvider, and retries
with Authorization: Payment. Non-402 responses pass through unchanged.
Req.new()
|> MPP.Client.Req.attach(provider: my_provider)
|> Req.get(url: "https://api.example.com/resource")This is the Elixir counterpart of mpp-rs PaymentExt and mppx Fetch.from().
A 402 that arrives after a redirect changed the request origin is refused
(:cross_origin_redirect) so a payment credential is never attached to a
different host, scheme, or port than the caller asked for (mpp-rs #379).
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
attach | 2 | Attach payment-aware 402 handling to a Req pipeline. | request: value, opts: value |
Summary
Functions
Attach payment-aware 402 handling to a Req pipeline.
Functions
@spec attach( Req.Request.t(), keyword() ) :: Req.Request.t()
Attach payment-aware 402 handling to a Req pipeline.
Options
:provider— required. AnMPP.Client.MultiProvider, a{module, config}tuple, or a provider module:selection—MPP.Client.SelectionPolicy.t(). Defaults to:server_order, or{:accept_payment, entries}when:accept_paymentis set:accept_payment— preference entries advertised on outgoing requests and used as the default ranking policy.qvalues are preserved on the wire:accept_policy—MPP.Client.AcceptPolicy.t()gating header injection (default:always):max_payment_retries— payment attempts after a 402 (default 3)