Documentation Index
Fetch the complete documentation index at: https://docs.x402x.ai/llms.txt
Use this file to discover all available pages before exploring further.
process()
type ProcessResult =
| { success: true; status: 200; data: { payer: string; txHash: string } }
| { success: false; status: 402; errorStage: "parse" | "verify"; response: Response402 }
| { success: false; status: 500; errorStage: "settle"; response: Response402; error: string };
Steps
- parse: parsing failed → 402
- verify: verification failed → 402
- settle: settlement failed → 500 (typically chain/network issues)
Other return types
// parse()
type ParseResult =
| { success: true; data: ParsedPayment }
| { success: false; response402: Response402 };
// verify()
type VerifyResult =
| { success: true; payer: string }
| { success: false; error: string };
// settle()
type SettleResult =
| { success: true; txHash: string; network: string }
| { success: false; error: string };
// initialize()
type InitResult =
| { success: true; detected?: number; total?: number }
| { success: false; error: string };
Example: unified handling
const result = await server.process(header, requirements);
if (result.success) {
res.json({ payer: result.data.payer, txHash: result.data.txHash });
} else {
res.status(result.status).json(result.response);
}