Installation
Quick Start
This page covers Express v5+ with@armory-sh/middleware-express.
For Express v4, use the separate package page: @armory-sh/middleware-express-v4.
How It Works
The middleware intercepts requests and:- Checks for payment headers (
X-PaymentorX402-PAYMENT) - Verifies the payment signature and amount
- Attaches payment info to
req.payment - Calls
next()if valid, or returns 402 if invalid
Configuration
Payment Requirements
Common Token Addresses
Verification Options
See runtime verification configuration in your deployment environment and middleware setup.Advanced Mix-and-Match Config (Current API)
extensions are fail-open filtered per facilitator capability (/supported): unsupported keys are automatically omitted from the challenge header.
Accessing Payment Info
The middleware augments the Express request with payment information:Response Headers
On successful verification, the middleware adds:Error Responses
402 Payment Required
No payment header was provided.400 Invalid Payload
Payment header exists but couldn’t be decoded.402 Verification Failed
Payment signature or amount was invalid.Tips
Express middleware runs in order — place
paymentMiddleware before any routes that require payment.