Prerequisites
- A developer account / credentials for x402 (you must obtain these from the x402 provider).
- A wallet for client-side signing (Phantom, WalletConnect, etc.).
- Node.js for the backend example or the matching engine (Unity/Unreal) for platform examples.
Our examples use placeholder keys and config. Replace those with your x402 credentials and keep them server-side.
Quick flow (5 steps — same for all platforms)
- Create payment session — client calls your backend (
POST /create-payment). Backend builds payload and (optionally) calls x402 create API. - Return signable payload — backend returns
paymentId+payloadto the client. - User signs — client prompts wallet (WalletConnect / MetaMask / mobile wallet) to sign the
payload. - Confirm — client sends
signature+paymentIdto your backend (POST /confirm-payment). Backend verifies signature then calls x402 confirm/finalize. - Finalize + webhook — x402 or your backend sends final status (webhook); update UI, grant item, log txHash.
Note: this is the common x402 flow — Gx402 adds deterministic payload shapes, engine-native patterns, and middleware examples (idempotency, webhook verification, relayer support).
Express server middleware (concept + example)
This is the core middleware pattern we include in templates. ReplaceX402_* placeholders with credentials from your x402 provider.