Start here instead
Everything below is self-serve at dash.aifinpay.io — no repository, no approval, no contract:- Create an account and a service.
- Give it a payout address (a standard
0x…EVM address; settlement is on Polygon today). - On Site settings, add a gateway: pick a slug and enter your upstream URL.
Your paid endpoint is
https://gateway.aifinpay.io/{your-slug}/…— that is the URL you hand to agents. It starts forwarding once the upstream’s domain is verified: add the TXT record_aifp-verify.<upstream-host>that Site settings shows under Domain verification. Until then it answers403 gateway_unavailable. - Lock your origin so agents cannot bypass the paywall. Read Hosted Gateway before you do — the rule differs for an API and for a site with human readers, and using the API rule on a website will 403 your readers and drop you out of search.
- Verify your domain: set Site URL under Profile & keys, then add the TXT record that the DNS connection queue on the account Dashboard shows for it. Agents using the AiFinPay MCP server do not pay until the domain is verified.
The partner-bridge route (requires us)
The rest of this page covers standing a thin x402 bridge in front of an API and listing it in the AiFinPay provider registry. It needs a pull request to a private repository and a registry entry we add by hand, so it is only relevant if you have already spoken to us about a registry listing. It is not a self-service path and should not be attempted as one.Config-only
Front any JSON HTTP API by editing a
.env file. No bridge code to fork
or maintain — the generic bridge is fully env-driven.Non-custodial & token-free
Per-call revenue settles straight to a wallet you own. No token to buy, no
contract to sign, no KYC, no revenue-share bookkeeping.
What you need
You do not need crypto integration in your existing stack, a wallet for
your end users (your customers are AI agents that bring their own keypair via
the AiFinPay SDK), or a compliance/KYC process — settlement is non-custodial
and happens on-chain in the splitter contract.
Fast path — config only, no code
If your upstream is a normal JSON HTTP API, use the env-driven_generic-x402-bridge and scaffold a config in one command. No bridge code is
written or edited.
1
Scaffold a provider config
Run This writes
scripts/new-provider.mjs with your three knobs and identity flags:examples/mybrand-x402-bridge/.env and
examples/mybrand-x402-bridge/README.md, and prints the services.json
registry entry to paste. The script derives PRICE_WEI (native POL) and
PRICE_USDC_UNITS / PRICE_USDT_UNITS (6-decimal stables) from your
--price-usd.2
Add your upstream API key
Open the generated Optionally set
.env and fill in the one secret the scaffold leaves
blank:BRIDGE_MERCHANT_WALLET to your own payout wallet — by
default the scaffold points it at the AiFinPay treasury Safe.3
Run the generic bridge with your config
The bridge code lives in Put it behind nginx / Caddy / fly.io / Railway / wherever — it’s a plain
HTTP service, no special infra.
_generic-x402-bridge; you point it at your
scaffolded .env:4
Register on the marketplace
Paste the printed registry entry into
oracle-financial-hub-59/backend/services.json. Once your bridge answers
GET /.well-known/x402.json, the provider pinger marks it live and it
becomes auto-selectable via /api/registry/best.A manual fork path exists for upstreams that need custom request shaping, but
the config-only path above is recommended for any standard JSON API.
The three knobs
Everything provider-specific is one of three env vars. The 402 challenge, on-chain verification, replay protection, rate limiting, and splitter integration are identical for every provider.Auth styles
UPSTREAM_AUTH_STYLE selects how UPSTREAM_API_KEY is attached when forwarding:
Optional knobs
The on-chain split
AIFP-1 settles one quoted gross amount through a verified B2BSplitter v1.3 route:payMatic/three-way splitters are legacy and must not be selected.
The services.json registry entry
new-provider.mjs prints the entry to paste into services.json →
"services":
- The on-chain
Paymentevents (the canonical source) - The aggregated
/api/dashboardendpoint - The merchant lookup at
/api/partner/:wallet - Automatic selection via
/api/registry/best
What you get for the 1% fee
Pre-built SDKs
Agents pay you through the Python (
aifinpay-agent), Node
(@aifinpay/agent), and MCP (@aifinpay/mcp) surfaces — no work on your
side.Discovery
Appearance on the
/api/dashboard and aifinpay.io marketplace pages.Trusted identity
Agents carry on-chain
AgentPassport identity you can trust without
running your own KYC.Multi-scheme facilitator
A canonical x402 facilitator translates between AiFinPay-native,
Coinbase-x402, and (future) generic schemes — agents written for any of
these can pay you.
Production checklist
- Set
REDIS_URLto share order/transaction state across instances (empty falls back to in-memory). - Use a hardware-secured wallet or a Safe for
BRIDGE_MERCHANT_WALLET— don’t reuse a CI/CD-rotated EOA. - Move your upstream API key to a secret manager; the
.envfile is for development only. - Rate-limit by Polygon address at the application layer — the bundled
express-rate-limitis per-IP, intended as anti-spam for the 402 challenge step. - Monitor your
Paymentevents (or the dashboard). A merchant wallet missing receipts means an agent paid but the bridge didn’t deliver — that’s a refund case.
github.com/AiFinPay/sdk/issues.