Skip to main content

Accept a payment

The core Prudra integration is three middleware functions chained together on any Express route. walletMiddleware identifies which wallet receives payment. payMiddleware handles the 402 challenge and verification. vaultMiddleware creates the vault where your handler stores its output.
Dashboard support for managing paid endpoints is coming soon. Use the SDK or cURL to set up payment-gated routes.

Middleware parameters

walletMiddleware

You can mount walletMiddleware globally (for all routes) or per-route. If mounted globally, it runs once for all routes. If mounted per-route, you can use different wallets for different endpoints.

payMiddleware

vaultMiddleware

No required parameters. The vault is created automatically and attached to req.vault.

What gets set on req

After the middleware chain runs, your handler has access to:

The vault in your handler

The vault attached to req.vault is ready to use immediately. Common operations:

Error handling

Next steps