Complete, working implementation of Google's Agent Payments Protocol (AP2) with real A2A message exchange, cryptographic JWT signatures, AI agents, and actual payment processing.
ap2-nextjs-stripe is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 3 GitHub stars and 0 forks.
Full demonstration of Agent Payments Protocol (AP2) with full Agent-to-Agent (A2A) communication
This project showcases a complete, working implementation of Google's Agent Payments Protocol (AP2) with real A2A message exchange, cryptographic JWT signatures, AI agents, and actual payment processing. Experience the future of agentic commerce!
Agent Payments Protocol (AP2) is an open protocol for the emerging Agent Economy, designed to enable secure, reliable, and interoperable agent commerce. It uses Verifiable Digital Credentials (VDCs) to engineer trust in AI-driven transactions.
This is a implementation features:
npm install
# or
yarn install
Copy the example environment file and fill in your API keys:
# Copy the template (or rename env.example to .env.local)
cp env.example .env.local
Then edit .env.local with your actual API keys:
# OpenRouter API Key (get from https://openrouter.ai/keys)
OPENROUTER_API_KEY=your_openrouter_api_key_here
# Stripe Keys (get from https://dashboard.stripe.com/test/apikeys)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
# JWT Secret (generate with: openssl rand -base64 32)
JWT_SECRET=your_jwt_secret_here_min_32_chars
Start the development server:
npm run dev
# or
yarn dev
Chat with AI Shopping Agent: Type your vacation preferences naturally
Watch A2A Messages: See the Shopping Agent communicate with the Merchant Agent
View Signed Cart Mandates: Browse vacation packages with cryptographic signatures
Select Your Package: Choose your preferred vacation
Payment Method Selection:
Payment Mandate Creation:
Stripe Payment: Complete real payment using Stripe test cards
4242 4242 4242 42424000 0000 0000 0002A2A Message Log: Watch the complete agent communication flow in the sidebar
Confirmation: Receive your booking confirmation with all mandate details!
Shopping Agent (/api/shopping-agent)
Merchant Agent (/api/agents/merchant)
Credentials Provider Agent (/api/agents/credentials-provider)
IntentMandate - User's purchase intent with expiryCartMandate - Merchant-signed cart with JWT authorizationPaymentMandate - User-signed payment with JWT authorizationThis demo showcases AP2's trust mechanisms:
This is a demo implementation. For production, upgrade JWT from HS256 to RS256 with proper RSA key pairs.
This project is MIT licensed. The AP2 reference implementation is Apache 2.0 licensed.
Lucid Agents Commerce SDK. Bootstrap AI agents in 60 seconds that can pay, sell, and participate in agentic commerce supply chains. Our protocol agnostic SDK provides CLI-generated templates and drop-in adapters for Hono, Express, Next.js, and TanStack, giving you instant access to crypto/fiat payment rails (AP2, A2A, x402, ERC8004).
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Skills & plugins for agentic commerce : UCP, ACP, AP2, A2A, WebMCP, Magento 2, BigCommerce, WooCommerce
Trust infrastructure for million-agent economies on Solana - identity, reputation, and validation designed for continuous feedback at scale.
A chain-agnostic AI-native payment infrastructure, authz layer for x402