Skip to main content
FTP’s plugins add Canton to the official x402 SDKs for Go and Python. Payments settle through FTP’s facilitator. The payer is charged only after your handler answers 2xx, and each payment is served once.

Before you start

The party you are paid to needs a live TransferPreapproval. Create it with the Node wallet, as on the merchant page:
For a CIP-56 token, also run preapproval --admin <admin> --id <id> once per token you price.

Go

Needs Go 1.26.10 or newer and the official SDK github.com/x402-foundation/x402/go/v2 v2.31.0 or newer. Works with net/http, gin and echo v4.
The module README covers gin and echo, token prices, Redis and shutdown.

Python

Needs Python 3.10 or newer and the official SDK x402 2.28. Works with FastAPI and Starlette (ASGI) and Flask (WSGI).
The package README has the Flask example, the supported servers and Redis.

Money safety

  • A 4xx or 5xx from your handler is not charged. A 3xx becomes 502 and is not charged.
  • A replay of a served payment gets 402 payment_already_redeemed.
  • 503 do NOT pay again; retry the same payment means the payment may have moved. The client resends the same signature and is served once. The retry runs your handler again, so keep paid side effects idempotent.
  • Use Redis in production: Go goredis.NewStore, Python RedisStore.from_url. The default memory store forgets payments on restart.
  • Limit per payer (canton.PayerFrom, payer_from), not only per IP, and let retries through (canton.IsRetry, is_retry).

Deployment

  • Proxies must accept a 32 KiB PAYMENT-SIGNATURE header. nginx: large_client_header_buffers 4 32k;.
  • Set the proxy read timeout and the shutdown grace to at least the plugin’s request budget: Go canton.RequestBudget(cfg), 505 s by default; Python request_budget(config), 465 s.
  • Python: gunicorn --limit-request-field_size 32768 --timeout 470 --graceful-timeout 470, waitress channel_request_lookahead=1, and TLS ended at a proxy.
  • Your handler must finish within the payment’s lifetime, 120 s by default. A slower one lets the payment expire, and nothing is charged.