Skip to content

Agentic Payments Protocol Demo - Interactive comparison of ACP, AP2, x402, and MCP payment protocols for AI agents

Notifications You must be signed in to change notification settings

aetherllama/agentic-payments-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agentic Payments Demo

An interactive demonstration of four leading agentic payment protocols that enable AI agents to conduct commerce autonomously or with user authorization.

Quick Start

cd agentic-payments-demo
npm install
npm start

Then open http://localhost:3000 in your browser.


What This Demo Shows

This demo illustrates the fundamental problem of agentic payments: How can AI agents make purchases on behalf of users securely, transparently, and at scale?

Each protocol takes a radically different approach to solving this problem:

Protocol Core Philosophy
ACP "Keep humans in the loop with seamless UX"
AP2 "Trust through cryptographic proof"
x402 "Make payments as simple as HTTP requests"
MCP "Standardize tools so any AI can pay"

Demo Scenarios Explained

Demo 1: ACP - In-Chat Checkout

What it demonstrates: The ACP demo shows how a user can complete a purchase without ever leaving their chat interface. When you click "Create Checkout Session," you're simulating what happens when a user says "Buy me a wireless mouse" to ChatGPT.

What to observe:

  • The presentationData field - this is structured data the AI uses to display the checkout to users
  • The agentContext tells the AI what actions are allowed
  • The session has an expiration time for security
  • Confirmation happens in a second step, simulating user approval

Real-world example:

User: "Order me the cheapest AirPods from Amazon" ChatGPT: Shows inline checkout card with price, image, delivery estimate User: Clicks "Confirm" button in chat Payment processed via Stripe without leaving the conversation


Demo 2: AP2 - Autonomous Purchase with Mandates

What it demonstrates: The AP2 demo shows how a user can give an AI agent permission to spend money autonomously within defined constraints. This is the most sophisticated protocol for truly autonomous agents.

What to observe:

  • Intent Mandate: Pre-authorization with limits (max $100, only electronics, expires in 24h)
  • Cart Mandate: Explicit approval for a specific cart (cryptographically signed)
  • Payment Mandate: Created automatically to signal AI involvement to payment networks
  • Each mandate has a cryptographic signature for non-repudiation
  • The auditTrail in payment responses provides full accountability

The key insight: AP2 solves the "who authorized this?" problem. If an AI agent buys something wrong, the audit trail proves:

  1. What constraints the user set (Intent Mandate)
  2. Whether the purchase was within constraints
  3. That the AI was involved (disclosed to payment network)

Real-world example:

User: "You can spend up to $50/day on office supplies without asking me" [Agent creates Intent Mandate with constraints] Later, agent notices printer ink is low, finds ink for $35 Agent purchases autonomously using the mandate User receives notification with full audit trail


Demo 3: x402 - Pay-Per-API-Request

What it demonstrates: The x402 demo shows a fundamentally different model: machine-to-machine payments without any prior relationship. No API keys, no subscriptions, no accounts—just pay and access.

What to observe:

  • First request returns HTTP 402 Payment Required with payment details
  • The paymentRequirements array lists accepted payment methods (USDC on Base network)
  • Agent wallet has a balance that decreases with each payment
  • Payment signature is sent as an HTTP header on retry
  • Resource is returned only after valid payment

The key insight: x402 enables a new economic model where:

  • APIs can monetize without user management overhead
  • AI agents can access any x402-enabled resource autonomously
  • Payments happen in real-time with stablecoins (no chargebacks, instant settlement)
  • Micropayments are practical ($0.001 per request)

Real-world example:

AI Agent needs premium weather data for user's travel planning Agent has a USDC wallet with $10 balance Agent requests weather API → gets 402 Agent signs 0.001 USDC payment → gets weather data No API key needed, no rate limits, just pay-per-use


Demo 4: MCP - Tool-Based Payments

What it demonstrates: The MCP demo shows how payments can be exposed as standardized tools that any AI can discover and use. This is the most "AI-native" approach—payments become just another tool in the AI's toolkit.

What to observe:

  • listTools() returns a schema-defined list of payment capabilities
  • Each tool has inputSchema describing required parameters
  • Tool responses include context with next suggested actions
  • The AI can chain tools together (create intent → list methods → confirm)
  • Multiple providers (Adyen, Worldpay) use the same interface

The key insight: MCP treats payments like any other AI capability. Just as an AI can use a "search the web" tool or "read a file" tool, it can use "create_payment_intent" or "refund_payment" tools. This standardization means:

  • Any MCP-compatible AI can make payments
  • Payment providers compete on implementation, not interface
  • AI can reason about payment options using structured schemas

Real-world example:

User: "Refund the customer's order from yesterday" AI calls get_payment_status to find the payment AI calls refund_payment with the payment ID AI reports: "Refund of $49.99 processed, confirmation #RF123"


How the Protocols Differ

Fundamental Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                        AGENTIC PAYMENTS SPECTRUM                        │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│  Human-in-Loop ◄─────────────────────────────────────────► Autonomous  │
│                                                                         │
│       ACP                    MCP            AP2              x402       │
│        │                      │              │                │         │
│   User confirms          User may or     User sets        No user      │
│   every purchase         may not be      constraints,     involved     │
│                          involved        agent acts                     │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

Payment Infrastructure

┌────────────────┬────────────────┬────────────────┬────────────────┐
│      ACP       │      AP2       │      x402      │      MCP       │
├────────────────┼────────────────┼────────────────┼────────────────┤
│                │                │                │                │
│   ┌───────┐    │   ┌───────┐    │   ┌───────┐    │   ┌───────┐    │
│   │Stripe │    │   │ Any   │    │   │Crypto │    │   │Adyen/ │    │
│   │  API  │    │   │Network│    │   │Wallet │    │   │Worldpay    │
│   └───┬───┘    │   └───┬───┘    │   └───┬───┘    │   └───┬───┘    │
│       │        │       │        │       │        │       │        │
│   Traditional  │   Agnostic     │   Blockchain   │   Traditional  │
│   Card Rails   │   (card/crypto)│   (USDC)       │   Card Rails   │
│                │                │                │                │
└────────────────┴────────────────┴────────────────┴────────────────┘

Trust Model Comparison

Aspect ACP AP2 x402 MCP
Who authorizes? User (per-transaction) User (via mandates) Agent wallet holder Depends on implementation
Proof of authorization Session confirmation Cryptographic VDC signature Blockchain transaction Application logs
Dispute resolution Stripe/card network Audit trail + VDCs On-chain history Provider-specific
Fraud liability Merchant/Stripe Defined by mandate Wallet holder Provider-specific

Technical Integration Comparison

Aspect ACP AP2 x402 MCP
Integration effort Low (Stripe SDK) Medium (VDC handling) Low (HTTP headers) Medium (MCP server)
Prerequisites Stripe account VDC infrastructure Crypto wallet MCP-compatible AI
Latency ~2-3 seconds ~1-2 seconds ~400ms (Solana) ~2-3 seconds
Transaction cost 2.9% + $0.30 Network fees ~$0.0003 (Base) Provider fees
Minimum practical amount ~$1 ~$1 $0.0001 ~$1

When to Use Each Protocol

Choose ACP when:

  • Building consumer-facing chat commerce (ChatGPT plugins, customer service bots)
  • You want proven infrastructure (Stripe's reliability)
  • Users should confirm every purchase
  • Traditional payment methods (cards) are required
  • You need chargebacks and consumer protection

Choose AP2 when:

  • Building truly autonomous agents that shop on behalf of users
  • Regulatory compliance and audit trails are critical
  • You need cryptographic proof of user intent
  • Working with enterprise clients who need accountability
  • Supporting multiple payment networks (cards + crypto)

Choose x402 when:

  • Monetizing APIs without user management
  • Enabling AI-to-AI commerce (agents paying agents)
  • Micropayments are needed ($0.001 - $1 range)
  • Instant, irreversible settlement is acceptable
  • You want to avoid subscription/API key management

Choose MCP when:

  • Building AI systems that need flexible payment capabilities
  • Working with multiple payment providers
  • Want AI to reason about payment options
  • Need payments integrated into larger tool ecosystems
  • Building internal enterprise AI with existing payment providers

Protocol Deep Dive

ACP: The User Experience Protocol

ACP's philosophy is that checkout should feel native to wherever the user is. Instead of redirecting users to a checkout page, ACP brings the checkout into the chat.

Key design decisions:

  • presentationData provides structured display info so any AI can render checkout consistently
  • agentContext tells the AI what UX patterns are allowed
  • Sessions expire quickly (30 min) to prevent stale carts
  • Two-step flow (create → confirm) ensures user approval
// ACP returns data optimized for AI presentation
{
  presentationData: {
    title: "Purchase from Demo Store",
    summary: "1 item(s) • USD 29.99",
    callToAction: "Confirm Purchase"
  }
}

AP2: The Trust Protocol

AP2's philosophy is that autonomous agents need cryptographic accountability. The protocol answers three critical questions:

  1. Authorization: How do we know the user allowed this?
  2. Authenticity: How do we know this reflects user intent?
  3. Accountability: Who is liable if something goes wrong?

Key design decisions:

  • Verifiable Digital Credentials (VDCs) are tamper-evident and cryptographically signed
  • Intent Mandates separate "permission to spend" from "specific purchase"
  • Payment Mandates explicitly disclose AI involvement to payment networks
  • All signatures create an immutable audit trail
// AP2 creates cryptographic proof chain
{
  credentials: {
    userMandate: "vdc:abc123...",      // User's authorization
    paymentMandate: "vdc:def456...",   // AI involvement disclosure
    signatures: ["sig_...", "sig_..."] // Cryptographic proof
  }
}

x402: The Simplicity Protocol

x402's philosophy is that payments should be as simple as HTTP. The 402 status code has existed since HTTP/1.0 but was never standardized. x402 finally defines how it should work.

Key design decisions:

  • Uses existing HTTP infrastructure (no new protocols)
  • Payment requirements returned as structured headers
  • Stablecoins enable instant, irreversible micropayments
  • No accounts, API keys, or prior relationship needed
// x402 is just HTTP with payment headers
// Request without payment:
GET /api/premium/weather  402 Payment Required

// Request with payment:
GET /api/premium/weather
Header: PAYMENT-SIGNATURE: <base64_signed_payment>
 200 OK + data

MCP: The Standardization Protocol

MCP's philosophy is that AI capabilities should be discoverable and standardized. Payments become tools that any AI can find, understand, and use through a common interface.

Key design decisions:

  • Tools are self-describing with JSON schemas
  • Responses include context for AI reasoning
  • Provider-agnostic (Adyen and Worldpay expose same interface)
  • Composable (chain tools together for complex workflows)
// MCP tools are self-describing
{
  name: "create_payment_intent",
  description: "Create a new payment intent",
  inputSchema: {
    type: "object",
    properties: {
      amount: { type: "number" },
      currency: { type: "string" }
    },
    required: ["amount", "currency"]
  }
}

The Future: Protocol Convergence

These protocols are not mutually exclusive. We're already seeing convergence:

  • AP2 + x402: Google's "A2A x402 extension" combines AP2's VDCs with x402's crypto payments
  • MCP + x402: Vercel's "x402-mcp" exposes x402 payments as MCP tools
  • AP2 + ACP: Could combine Stripe's UX with AP2's audit trails

The likely future is a layered stack:

┌────────────────────────────────────────┐
│   Application Layer (Chat UX, etc.)    │  ← ACP-style presentation
├────────────────────────────────────────┤
│   Authorization Layer (Mandates)       │  ← AP2-style credentials
├────────────────────────────────────────┤
│   Tool Layer (Standardized APIs)       │  ← MCP-style tools
├────────────────────────────────────────┤
│   Settlement Layer (Payment Rails)     │  ← x402/traditional
└────────────────────────────────────────┘

Protocols Overview

1. ACP - Agentic Commerce Protocol (Stripe + OpenAI)

What it is: A protocol enabling seamless checkout within AI chat interfaces like ChatGPT.

Key Features:

  • User stays within the chat experience
  • Leverages Stripe's existing payment infrastructure
  • Structured presentation data for AI to display to users

Flow:

User → "Buy me a wireless mouse"
   ↓
AI Agent → Creates ACP checkout session
   ↓
Chat UI → Shows inline checkout with item details
   ↓
User → Confirms purchase in chat
   ↓
Stripe → Processes payment
   ↓
AI Agent → Returns confirmation + receipt

API Endpoints:

  • POST /api/acp/checkout - Create checkout session
  • POST /api/acp/confirm/:sessionId - Confirm payment

2. AP2 - Agent Payment Protocol (Google)

What it is: An open protocol using Verifiable Digital Credentials (VDCs) to establish trust in AI agent transactions. Released under Apache 2.0 with 60+ industry partners.

Key Concepts:

Mandate Type Use Case User Presence
Intent Mandate Pre-authorized autonomous purchases Human NOT present
Cart Mandate Explicit approval for specific cart Human present
Payment Mandate Signals AI involvement to networks Sent to payment network

Flow (Autonomous with Intent Mandate):

User → Creates Intent Mandate
       "Allow agent to spend up to $50 on electronics"
   ↓
AI Agent → Finds headphones for $35
   ↓
AI Agent → Validates against mandate constraints
   ↓
AP2 → Creates Payment Mandate (for audit trail)
   ↓
Payment Network → Processes with AI disclosure
   ↓
Full audit trail with cryptographic signatures

API Endpoints:

  • POST /api/ap2/mandate/intent - Create autonomous spending mandate
  • POST /api/ap2/mandate/cart - Create explicit cart authorization
  • POST /api/ap2/pay - Initiate payment with mandate

3. x402 - HTTP 402 Protocol (Coinbase)

What it is: A protocol leveraging the HTTP 402 "Payment Required" status code for machine-to-machine payments. No API keys or subscriptions needed—just pay per request.

Key Features:

  • Built into HTTP - no additional protocols
  • Real-time stablecoin payments (USDC)
  • Ideal for AI agents accessing paid APIs autonomously
  • 35M+ transactions processed

Flow:

AI Agent → GET /api/premium/weather
   ↓
Server → 402 Payment Required
         {
           "amount": 0.001,
           "asset": "USDC",
           "network": "base",
           "recipient": "0x..."
         }
   ↓
Agent Wallet → Signs USDC payment
   ↓
AI Agent → GET /api/premium/weather
           Header: PAYMENT-SIGNATURE: <signed_payment>
   ↓
Server → Verifies payment on-chain
   ↓
Server → 200 OK + Weather Data

API Endpoints:

  • GET /api/x402/resources - List paid resources
  • GET /api/x402/resource/* - Access resource (returns 402 if unpaid)
  • POST /api/x402/create-payment - Create payment signature
  • POST /api/x402/access - Access with payment

4. MCP - Model Context Protocol Payments (Anthropic + Partners)

What it is: Payment integrations built on Anthropic's Model Context Protocol, with implementations from Adyen, Worldpay, J.P. Morgan, and others.

Key Features:

  • Standardized tool interface for payment operations
  • Context-aware payments tied to conversation flow
  • Multi-provider support
  • Structured responses for AI reasoning

Available Tools:

Tool Description
create_payment_intent Create a new payment intent
confirm_payment Confirm and process payment
get_payment_status Check payment status
list_payment_methods List customer's saved methods
create_checkout_session Create hosted checkout
refund_payment Process refund

Flow:

AI Agent → execute("create_payment_intent", {
             amount: 49.99,
             currency: "USD"
           })
   ↓
MCP Server → Returns paymentIntentId + context
   ↓
AI Agent → execute("list_payment_methods", {
             customerId: "cust_123"
           })
   ↓
AI Agent → execute("confirm_payment", {
             paymentIntentId: "pi_...",
             paymentMethodId: "pm_visa_4242"
           })
   ↓
MCP Server → Returns receipt + next actions

API Endpoints:

  • GET /api/mcp/tools - List available tools
  • POST /api/mcp/execute - Execute a tool
  • POST /api/mcp/process-payment - High-level payment flow

Summary Comparison Table

Feature ACP AP2 x402 MCP
Developer Stripe/OpenAI Google Coinbase Anthropic + Partners
Primary Use In-chat checkout Autonomous agents Pay-per-API Tool-based payments
Payment Type Traditional cards Any (agnostic) Stablecoins (USDC) Traditional cards
User Presence Required Optional Not required Flexible
Audit Trail Standard Cryptographic VDCs Blockchain Logging
Micropayments No Limited Yes ($0.0001+) No
Autonomy Level Low High Highest Medium
Integration Complexity Low Medium-High Low Medium
License Proprietary Apache 2.0 Open standard Open protocol

Project Structure

agentic-payments-demo/
├── src/
│   ├── server.js              # Express server with all endpoints
│   └── protocols/
│       ├── acp.js             # Agentic Commerce Protocol
│       ├── ap2.js             # Agent Payment Protocol
│       ├── x402.js            # HTTP 402 Protocol
│       └── mcp-payments.js    # MCP Payments
├── public/
│   └── index.html             # Interactive demo UI
├── package.json
└── README.md

Learn More

About

Agentic Payments Protocol Demo - Interactive comparison of ACP, AP2, x402, and MCP payment protocols for AI agents

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published