IntegrationUpdated 2026-11-20
Agent payments for Fastify
paygate has a Fastify plugin. Register it once with your merchant id. Then set the price of a route in the route config or in the handler.
Register the plugin
You can use both styles in one app.
server.ts
import Fastify from "fastify"; import paygate from "paygate/fastify"; const app = Fastify(); await app.register(paygate, { merchantId: process.env.PAYGATE_MERCHANT_ID }); // Price in the route config. app.get("/api/data", { config: { paygate: { priceCents: 10 } } }, async () => ({ data: "premium", })); // Or in the handler. app.get("/api/premium", async (req, reply) => { const { paid } = await req.paygatePay({ priceCents: 25 }); if (!paid) return reply; return { data: "…" }; }); await app.listen({ port: 3000 });
What the plugin does on each request
A request without a payment gets HTTP 402 with the price. The agent asks Arispay to authorize the payment and repeats the request. Arispay settles the payment before your handler runs. The response carries an X-Paygate-Receipt header.
On the buyer side, an AI agent pays your endpoint with `npx payagent pay <url>` or the payagent SDK. The agent pays from an Arispay wallet that a person topped up by card.
Scaffold a new seller
One command
npx paygate init --framework fastify --merchant-id <your-merchant-id> --price 10 --yes
Pricing guidance
- Prices are integer cents. The minimum is 1 cent. Use a `priceCents` function to price by payload size or by depth.
- The route-config style keeps the price next to the route definition.
FAQ
- Can I run paygate on only some routes?
- Yes. A route that has no `paygate` config and no `paygatePay` call is not changed.
Is your service agent-ready?
Run the free readiness scan — it inspects your live endpoint's discoverability, machine-readable contracts, and payment support, then tells you the highest-impact fix.
