x402
x402 Developer Quick Start
This guide is for builders who want a first working x402 integration before optimizing the full merchant setup.
Before You Start
Make sure you have:
- a backend where secrets can stay server-side
- merchant onboarding credentials for your x402 environment
- a clear choice of whether you only need gated delivery or callback-enabled settlement
Step 1: Get the Integration Resources
Use the official repository when you want the reference implementation:
If you are integrating through AgentKit, use AgentKit x402 Payments instead of starting from the raw repo.
Step 2: Configure Backend Credentials
GOATX402_API_SECRET must stay on the server. Do not expose it in frontend bundles or public environment variables.
Step 3: Create the First Order
At a minimum, your backend should call the order-creation endpoint and be prepared for HTTP 402 as the normal success path.
Step 4: Decide How the User Pays
- Use DIRECT if the user should pay the merchant address directly and no callback flow is needed.
- Use DELEGATE if settlement should go through delegated infrastructure and may trigger contract logic.
See Payment Modes for the full decision guide.
Step 5: Verify the Order Status and Proof
After payment:
- query the order status until it reaches a terminal state
- retrieve the proof when the settlement flow is complete
- store the proof if you need an auditable delivery record
Fast Validation Checklist
- order creation returns the expected x402 payload
- the client can sign the required authorization data
- payment reaches the correct destination address
- backend status polling reaches a terminal state
- proof retrieval succeeds for completed flows