Installation
Quick Start
How It Works
The middleware plugin:- Checks for payment headers (
X-PaymentorX402-PAYMENT) - Verifies the payment signature and amount
- Stores payment info in the Elysia store
- Proceeds to your handler if valid, or returns 402 if invalid
Configuration
Payment Requirements
Verification Options
Provide your verification backend configuration in middleware options for production deployments.Advanced Mix-and-Match Config (Current API)
requirements:
extensions are fail-open filtered based on facilitator capability; unsupported keys are omitted from challenge headers automatically.
Accessing Payment Info
Payment information is stored in the Elysia store:Type Safety
For full TypeScript support, type your Elysia instance:Response Headers
On successful verification:Error Responses
402 Payment Required
No payment header was provided.400 Invalid Payload
Payment header exists but couldn’t be decoded.400 Version Mismatch
Payment version doesn’t match requirements.402 Verification Failed
Payment signature or amount was invalid.Tips
Elysia’s store is shared across all middleware and routes. Payment info will be available in any route handler after the middleware runs.