This page walks through the complete lifecycle of a SohoPay payment: an order is created, the agent signs, the Policy Service validates and co-signs, and USDC settles on Base in approximately 1 second.

x402 in 60 seconds

HTTP has reserved the status code 402 Payment Required since 1997. The x402 protocol standardizes it for software: when a client requests a paid resource (an API, dataset, or compute job), the server responds with a 402 containing machine-readable payment terms. The client signs and pays, retrying with cryptographic payment proof. SohoPay integrates x402 with USDC on Base and adds crucial institutional infrastructure: revolving credit lines, real-time risk policies, and sanctions screening. Settlement utilizes ERC-3009 TransferWithAuthorization directly on USDC.

The payment lifecycle

Merchants always receive 100% of the order total. The 5% transaction fee is charged directly to the operator’s revolving credit facility.

Step 1: Create an order

The merchant’s backend creates an order when an agent requests a paid resource:

Response (201 Created):

Orders have a strict 10-minute TTL. Submitting a payment against an expired order returns 400 ORDER_EXPIRED. Always generate a fresh order rather than retrying expired ones.

Step 2: Submit the payment

The agent signs the order as EIP-712 typed data and submits the authorization signature. In the staging sandbox, pass "sandbox_auto" to test the loop without local key shares:
For MCP Agent Builders: When using Cursor, Claude Desktop, or Windsurf, this step is handled autonomously behind the scenes by the SohoPay MCP server when calling spend_x402.

Step 3: Policy Service verification

Before co-signing, the Policy Service verifies four mandatory guardrails:
  1. Merchant Allowlist: Validates that the merchant has approved this agent. Fails with 403 AGENT_NOT_ALLOWLISTED.
  2. Agent Operational Status: Validates that the agent is not paused by its operator. Fails with 403 AGENT_PAUSED.
  3. Credit & Velocity: Confirms the amount fits within available_credit and daily_limit. Fails with 402 INSUFFICIENT_CREDIT.
  4. AML Screening: Real-time wallet sanctions screening. Fails with 402 AML_DECLINED.

Step 4: On-chain settlement & verification

Once the Policy Service co-signs, SohoPay broadcasts the ERC-3009 settlement to Base. Confirmation takes ~1 second:
Response
You can view the settlement on Sepolia Basescan and see the updated outstanding balance on the Borrower Portal.

Next steps

Error Handling

Explore idempotency, backoff retries, and decline playbooks.

Testing Guide

Run end-to-end sandbox tests and simulate failure modes.

x402 Protocol

Review the low-level HTTP 402 specifications.