Route configurations for protected endpoints
Pre-configured t402ResourceServer instance
OptionalpaywallConfig: PaywallConfigOptional configuration for the built-in paywall UI
Optionalpaywall: PaywallProviderOptional custom paywall provider (overrides default)
Whether to sync with the facilitator on startup (defaults to true)
Express middleware handler
import { paymentMiddleware } from "@t402/express";
import { t402ResourceServer } from "@t402/core/server";
import { registerExactEvmScheme } from "@t402/evm/exact/server";
const server = new t402ResourceServer(myFacilitatorClient);
registerExactEvmScheme(server, { signer: myServerSigner });
app.use(paymentMiddleware(routes, server, paywallConfig));
Express payment middleware for t402 protocol (direct server instance).
Use this when you want to pass a pre-configured t402ResourceServer instance. This provides more flexibility for testing, custom configuration, and reusing server instances across multiple middlewares.