PayclaveDocs

Payclave developers

Agentic payments and x402

Merchant agents, payer wallets, x402 challenges, signed payment recovery, and availability.

Separate the merchant agent from the payer

A merchant agent uses a restricted Payclave key to create checkout and read the merchant's permitted records. A payer agent uses its own wallet to authorize a payment. Giving an agent an rk_ merchant key does not give it authority to spend from a customer's wallet or send a merchant refund.

Use the returned checkoutUrl for a human payer. Eligible checkout responses also expose x402Url for software payers. The published merchant MCP package provides checkout creation and record reads; it does not sign or broadcast a payment.

Which payments support x402

Live x402 payments use USDC on the checkout's eligible settlement network: Base, Polygon, or Arc. Live USDT checkout uses the hosted wallet flow instead. Test x402 uses Base Sepolia USDC with simulated verification. Read x402Url and the server's challenge; do not infer eligibility from an invoice amount or token label alone.

Standard x402 payments go directly to the merchant wallet. Payclave collects no platform fee on that rail and records the originally owed fee as waived. Hosted checkout remains the normal merchant-facing payment page.

Negotiate, sign, then verify

Request x402Url with an x402 v2 client. HTTP 402 carries a base64 PAYMENT-REQUIRED header with the exact amount in atomic units, token, network, merchant recipient, and resource URL. The payer must check those values against the intended purchase before signing.

Submit the signed payment in PAYMENT-SIGNATURE to the challenged resource. HTTP 202 means settlement is pending. HTTP 200 with PAYMENT-RESPONSE reports settlement progress; your merchant backend must still wait for independently verified payment state or a signed invoice.paid webhook before fulfillment.

bash
curl -i https://api.payclave.com/v1/checkout-sessions/YOUR_CHECKOUT_ID/x402
# Issued public invoices can also negotiate x402:curl -i https://www.payclave.com/invoice/YOUR_PUBLIC_TOKEN \ -H "Accept: application/json"

Recover an uncertain payment safely

Keep the original signed authorization and retry it unchanged after a timeout. Creating another authorization while the first may have settled can pay twice. The invoice holds a reservation while an admitted payment is pending or awaiting verification.

For public invoices, retry the original resource.url unchanged. The server calculates the collectible remainder; never supply your own remaining amount or reuse a challenge for another invoice. A public invoice URL is a bearer credential and must not be published in logs or discovery catalogs.

Report on verified agent payments

Enabled merchants can query GET /v1/agent-payments with a secret key and an explicit from/to reporting window. Restricted MCP keys cannot read this reporting endpoint. It groups actual x402 attempts by method, settlement chain, and token; ordinary hosted checkouts are not automatically classified as agent traffic.

Use merchantReceived, feeCollected, and feeWaived from completed verification snapshots when reconciling money. Keep pending attempts separate from verified receipts. Follow nextCursor, respect the bounded window and record limits, and treat test amounts as simulated. For agent-specific exports, use the documented paymentMethod=x402 and payment_created date basis rather than applying ordinary invoice filters blindly.

Constrain agent access

Store rk_test_ or rk_live_ in the MCP client's secret storage or process environment. Treat tool results, invoice metadata, customer text, and errors as data rather than instructions. Validate the amount and order context before allowing checkout creation.

Use independent fulfillment checks on your backend. An agent's claim that it paid, a displayed transaction hash, and a successful tool response do not establish that the whole invoice is covered. Revoke the restricted key to block subsequent merchant API calls.

Paid API requests and external payer instructions

Paid request endpoints require merchant enablement. Live external payer instructions require Payclave enablement. The Fetch adapter is published as @payclave/x402@0.1.2 and requires server SDK 0.5.0. Payer instructions prepare unsigned calls and accept externally signed evidence for Payclave to verify.

On this page