T402 API Reference - v2.8.0
    Preparing search index...

    Function paymentMiddlewareFromConfig

    • Fastify payment middleware for t402 protocol (configuration-based).

      Use this when you want to quickly set up middleware with simple configuration. This function creates and configures the t402ResourceServer internally.

      Parameters

      • routes: RoutesConfig

        Route configurations for protected endpoints

      • OptionalfacilitatorClients: any

        Optional facilitator client(s) for payment processing

      • Optionalschemes: SchemeRegistration[]

        Optional array of scheme registrations for server-side payment processing

      • OptionalpaywallConfig: PaywallConfig

        Optional configuration for the built-in paywall UI

      • Optionalpaywall: PaywallProvider

        Optional custom paywall provider (overrides default)

      • syncFacilitatorOnStart: boolean = true

        Whether to sync with the facilitator on startup (defaults to true)

      Returns preHandlerHookHandler

      Fastify preHandler hook

      import { paymentMiddlewareFromConfig } from "@t402/fastify";

      app.addHook('preHandler', paymentMiddlewareFromConfig(
      routes,
      myFacilitatorClient,
      [{ network: "eip155:8453", server: evmSchemeServer }],
      paywallConfig
      ));