x402 becomes reliable when you implement one strict loop: call, detect 402, pay, retry same request. This guide keeps that loop deterministic and safe for production runtimes.
1) Read pricing from runtime
Query GET https://api.delx.ai/api/v1/tools at startup.
Use `price_cents` and `x402_required` as the source of truth.
Do not hardcode tool prices in prompts or static configs.
2) Implement the 402 loop
Send MCP or A2A call without payment.
If status is 402, parse `accepts[0]`.
Validate network/asset/payTo against your policy.
Generate payment proof and retry exact same request with `X-PAYMENT` header.
3) Add guardrails before paying
Per-run budget cap (hard stop).
Daily spend cap.
Allowlist of paid methods/tools.
Idempotency key in your controller to avoid duplicate paid retries.
4) Monitor success in telemetry
GET https://api.delx.ai/api/v1/admin/x402-errors?hours=24 -> `payment_verified` should increase.
GET https://api.delx.ai/api/v1/admin/x402-audit?days=30 -> track adoption and paid transactions.