Start here: need to register a service and create a plan first? Follow the
5-minute setup.
paymentMiddleware handles verification and settlement automatically.
x402 Payment Flow
Installation
Quick Start: One-Line Payment Protection
ThepaymentMiddleware from @nevermined-io/payments/express handles the entire x402 flow:
- Returns
402withpayment-requiredheader when no token is provided - Verifies the x402 token via the Nevermined facilitator
- Burns credits after request completion
- Returns
payment-responseheader with settlement receipt
x402 Headers
The middleware follows the x402 HTTP transport spec:| Header | Direction | Description |
|---|---|---|
payment-signature | Client → Server | Base64-encoded x402 access token |
payment-required | Server → Client (402) | Base64-encoded payment requirements |
payment-response | Server → Client (200) | Base64-encoded settlement receipt |