Building Agentic Commerce #1: Multi-Protocol Checkout with MCP + x402 + ACP in One Flow
One agent, three protocols, one checkout. Here's how MCP, x402 stablecoin payments, and ACP work together to let AI agents buy products, with code examples you can run today.
Executive summary
First post in the 'Building Agentic Commerce' series. A developer guide to multi-protocol checkout: how MCP tools, x402 stablecoin settlement, and ACP discovery work together in a single agent purchasing flow.
Published
2026-04-05
Updated: 2026-09-13
12 min
Author
Trusteed
Published by Trusteed
Written and maintained by the team that builds Trusteed. Technical claims in these articles are backed by the surfaces linked from each piece and by the signed capability registry at /.well-known/trusteed-capabilities.json, which is the arbiter when an article and a status surface disagree.
About TrusteedCategory
Developer Guides
When an AI agent decides to buy a product, it doesn't care which payment protocol the merchant uses. It cares about: can I discover products, add them to a cart, and pay? The complexity of protocol routing, signature verification, and settlement should be invisible. This is the problem we solved with multi-protocol checkout, and in this post we'll show you exactly how it works, with code you can run against our demo store today.
This is Part 1 of the 'Building Agentic Commerce' series. Each post covers one foundational concept with working code examples. Part 2 covers agent discovery via NLWeb and llms.txt. Part 3 covers trust scores.
The Problem: Three Protocols, One Agent
Today's agentic commerce ecosystem has multiple payment protocols, each optimized for different scenarios. MCP (Model Context Protocol) provides the tool interface: search, cart, checkout. x402 enables stablecoin payments on-chain (USDC on Base, Ethereum, Solana). ACP (Agentic Commerce Protocol) defines how agents discover merchant capabilities and negotiate payment methods. An agent shopping across merchants will encounter all three. If each requires a different integration, agent developers end up maintaining three integrations.
The Architecture: Protocol Bridge
Trusteed uses a Protocol Bridge that normalizes every incoming request to a unified AgentPaymentIntent, regardless of which protocol the agent speaks. The bridge detects the protocol from HTTP headers (X-Protocol: X402, X-Protocol: ACP) or request body shape, routes to the appropriate inbound adapter, and returns a protocol-specific response. Merchants configure which protocols they support, so the agent never needs to know the details.
How Protocol Detection Works
The protocol detector middleware runs on every checkout request and assigns a confidence score. X-Protocol header gets 1.0 confidence. Body shape detection (presence of 'cartId' for ACP, 'network' for x402) gets 0.9. If no protocol is detected, the request falls through to standard MCP checkout. This means existing MCP agents work without any changes: protocol awareness is additive, not breaking.
Flow 1: MCP Checkout (The Default Path)
The simplest checkout flow uses MCP tools directly. An agent calls four tools in sequence: search_products to find items, create_cart to build a cart, preview_checkout to see totals and shipping, and complete_checkout to finalize the purchase. Every tool is idempotent, so it is safe to retry on network failures.
MCP Checkout: Step by Step
- 1search_products({ query: 'wireless headphones', limit: 5 }): returns ranked results with trust-weighted scoring. No auth required.
- 2create_cart({ items: [{ product_id: 'prod-123', quantity: 1 }] }): returns cart_id (UUID). Requires OAuth Bearer token.
- 3preview_checkout({ cart_id: '550e8400-...' }): returns total, tax, shipping options. Sets session to READY_FOR_PAYMENT.
- 4complete_checkout({ checkout_session_id: '550e8400-...', idempotency_key: 'req-abc-123' }): finalizes purchase. Returns a status: COMPLETED with order_id and total_cents, or PENDING_EXTERNAL_CONFIRMATION with the link the buyer must open first.
Always generate a unique idempotency_key per payment attempt. If the network drops after complete_checkout succeeds, retrying with the same key returns the existing order instead of creating a duplicate charge.
Flow 2: x402 Stablecoin Checkout (USDC on Base/Ethereum/Solana)
x402 adds a payment layer for agents that hold cryptocurrency. Instead of a credit card token, the agent pays on-chain in USDC and submits proof of payment. The flow starts the same as MCP (search, cart, preview) but diverges at the payment step. When the agent sends X-Protocol: X402, the server responds with HTTP 402 Payment Required, a standard HTTP status code that was designed for this use case decades ago and is finally being used as intended.
x402 Payment: The Three-Step Dance
- 1Step 1: Agent POSTs to /api/v1/agent/checkout with X-Protocol: X402 header. Server responds 402 with payment details: amount in USDC wei, merchant wallet address, network (Base/Ethereum/Solana/Polygon/Arbitrum), and a 5-minute timeout.
- 2Step 2: Agent executes on-chain USDC transfer to the merchant's wallet address. This happens entirely outside Trusteed, as a standard blockchain transaction.
- 3Step 3: Agent POSTs proof of payment to /api/v1/agent/checkout/x402/verify with the transaction signature. Server verifies via the merchant's facilitator, settles with exponential backoff (5 retries, 5s-40s delays), and returns 202 Accepted.
Settlement is asynchronous: the server returns 202 immediately and processes the settlement in the background. Orders that aren't verified within 30 minutes auto-expire. The entire payment verification is BOLA-protected: agents can only settle orders they created.
Flow 3: ACP Discovery + Protocol Negotiation
ACP doesn't replace MCP or x402. It sits above them as a discovery and negotiation layer. An agent fetches GET /.well-known/acp.json (public, no auth, cached 1 hour) and learns what the platform supports: which payment handlers are available (Stripe, x402, PayPal, UCP), which transports work (REST, MCP), and what capabilities the platform offers (cart persistence, agent session resume, display context negotiation).
ACP Discovery Response (What Agents See)
The ACP discovery endpoint returns a JSON contract specifying: spec_version '2026-01-30', supported transports (REST and MCP), four payment handlers (Stripe for USD/EUR, x402 for USDC, PayPal for USD/EUR, UCP for USD/EUR), and capability negotiation options including webview and headless display contexts, cart persistence, and agent session resume. Authentication follows OAuth 2.1 with RFC 9728 protected resource metadata.
With this information, a smart agent can make protocol decisions automatically: use x402 if it holds USDC, fall back to Stripe if it has a card token, or use UCP if the merchant supports Shopify's Universal Commerce Protocol. The agent never needs to hard-code protocol logic: it reads the ACP contract and adapts.
Putting It Together: Multi-Merchant, Multi-Protocol
Multi-merchant orders are where the bridge earns its keep. When a cart contains items from different merchants, the Protocol Bridge splits the order into per-merchant intents and routes each independently via Promise.allSettled(). Merchant A and Merchant B can be routed to different rails in the same checkout — one to Stripe, another to the x402 adapter — because the split is per-merchant. Which of those rails can actually settle is a separate question, and the answer today is only the ones a merchant has a payment processor configured for: the x402 rail returns `x402_not_configured` for every merchant, so this shape is what the bridge supports, not something running in production. One merchant's failure doesn't block others. Each gets its own ProcessedIntent with status, source/target protocol, and policy decision.
Try It: Demo Store Checkout
You can test the MCP checkout flow right now against our demo store. The demo store at trusteed.xyz/demo-store has 18 products across multiple categories. Discovery tools (search_products, get_product_details, browse_categories, get_merchant_profile) work without authentication. Every checkout tool (create_cart, get_shipping_rates, select_shipping_option, apply_discount, preview_checkout, complete_checkout) needs a sandbox key, create_cart included, and the checkout tools that spend or settle need an X-Payment-Mandate header; the other checkout tools create_cart and attach_agent_identity and verify_age_over_n and verify_residence_country and verify_legal_person_authorization and apply_discount and get_shipping_rates and select_shipping_option and create_payment_mandate and update_payment_mandate and cancel_payment_mandate and ucp_create_checkout and ucp_update_checkout and ucp_add_items_to_checkout and ucp_get_checkout and ucp_cancel_checkout and get_checkout_state and quote_checkout and get_trust_receipt and verify_trust_receipt don't need it. The Playground at trusteed.xyz/demo-store/playground provides a built-in MCP client with all of that pre-configured.
Security by Design
- 1UUID validation before any database query (SQL injection guard)
- 2Idempotency keys prevent double-charging on retries
- 3Payment tokens are NEVER logged or included in error messages
- 4x402 facilitator URLs are validated against private IP ranges (SSRF protection)
- 5BOLA protection: agents can only access orders they created (via agentKeyId)
- 6KYAI policy engine evaluates every checkout against merchant rules (ALLOW/FRICTION/REVIEW/BLOCK)
- 7OAuth 2.1 with PKCE for all mutating operations
What's Next in the Series
Trust Score v4.1 combines three weighted dimensions with an optional external-assurance bonus and confidence-tier caps. Each response identifies the engine used; some responses fall back to legacy v2. A legacy v2 component breakdown does not explain an overall score produced by v4.1.
Frequently asked questions
Do I need to implement all three protocols to use Trusteed?
No. MCP is the default and works out of the box. x402 and ACP are additive: merchants enable them in their protocol configuration. Agents that only speak MCP will always work. The Protocol Bridge handles routing automatically based on what each merchant supports.
What happens if an x402 payment fails after the agent sends USDC?
The settlement service retries with exponential backoff (5 attempts over ~75 seconds). If all retries fail, the order status moves to 'failed' and an OrderEvent is logged. The on-chain USDC transfer is separate from order settlement, and refund handling depends on the facilitator configuration. In practice, facilitator verification failures are rare because the blockchain transaction is either valid or not.
Can an agent use different protocols for different items in the same cart?
Not within a single cart, but across merchants yes. The Protocol Bridge splits multi-merchant orders into per-merchant intents, and each merchant intent uses the merchant's configured protocol. So Merchant A can be routed to Stripe and Merchant B to the x402 adapter in the same overall checkout. Routing is not settlement: which rails actually complete a payment depends on what each merchant has configured, and the x402 rail returns `x402_not_configured` for every merchant today.
What USDC networks are supported for x402 payments?
Base, Ethereum, Solana, Polygon, and Arbitrum. Each merchant configures their preferred network and wallet address. The agent sees the network requirement in the HTTP 402 response and submits payment on the correct chain.
Is the ACP spec standardized or proprietary?
ACP (Agentic Commerce Protocol) is an open specification (version 2026-01-30). The spec defines a discovery format, payment handler declarations, and capability negotiation. Trusteed implements the spec fully: the /.well-known/acp.json endpoint is public and follows the standard schema.
Sources and references
- Model Context Protocol Specification
Anthropic
- HTTP 402 Payment Required: x402 Protocol
x402 Protocol
- Agentic Commerce Protocol (ACP)
ACP Working Group
- RFC 9728: OAuth 2.0 Protected Resource Metadata
IETF
- USDC on Base (Circle)
Circle
Related articles
Agentic Commerce
ACP vs AP2 vs x402: Complete Guide to Agentic Payment Protocols
Three protocols are shaping how AI agents handle payments. ACP (Stripe/OpenAI) for fiat, AP2 (Google) for cart mandates, and x402 (Coinbase/Cloudflare) for USDC stablecoins. Here's when to use each.
Agentic Commerce
Zero-Click Commerce: When the Agent Buys Without the User Visiting Your Store
The majority of AI-assisted purchases in 2026 will never produce a click on your website. The agent compares, decides and executes. Your store doesn't need to be visited. It needs to be understood.
Developer Guides
Building Agentic Commerce #3: Reading Trust Score v4.1
Trust Score v4.1: three weighted dimensions, an optional bonus and confidence caps. Read each response's engine; legacy v2 fallback remains possible.