Skip to content

manuzafar/didactic-funicular

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A2A + Stripe Integration Demo

A demonstration of Agent-to-Agent (A2A) commerce workflows using Google's AP2 (Agent Payments Protocol) integrated with Stripe payment processing.

Overview

This project showcases a complete e-commerce flow where multiple AI agents collaborate to:

  1. Search for products
  2. Create shopping carts
  3. Collect shipping addresses
  4. Process payments via Stripe
  5. Handle payment mandates and compliance

The demo simulates a real-world scenario where a user purchases Nike shoes through an AI-powered shopping experience.

Architecture

User Input → Root Agent → Shopping Agent → Address Collector → Payment Collector → Commerce Rail Agent → Stripe

Key Components

  • Stripe Integration: Real Stripe MCP client with fallback to direct API calls
  • Commerce Rail Agent: Processes AP2 payment mandates through Stripe
  • AP2-Stripe Bridge: Converts AP2 mandates to Stripe payment operations
  • Multi-Agent Workflow: Coordinated shopping experience across specialized agents

Prerequisites

  • Python 3.8+
  • Stripe account with API keys
  • Google Cloud credentials (for AP2 framework)

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd a2a-stripe-demo
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp config/.env.example .env
# Edit .env with your actual API keys
  1. Run the demo:
./run.sh

Configuration

Required Environment Variables

# Stripe Configuration
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Google Cloud Configuration
GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json
PROJECT_ID=your-project-id

# MCP Configuration (optional)
STRIPE_MCP_SERVER_URL=http://localhost:3000

What's Real vs Simulated

Real Components

  • ✅ Stripe payment processing
  • ✅ Payment method validation
  • ✅ Customer creation and management
  • ✅ Payment intent creation
  • ✅ Transaction recording

Simulated Components

  • 🔄 Product catalog (uses mock Nike shoes)
  • 🔄 Inventory management
  • 🔄 Shipping calculations
  • 🔄 Order fulfillment
  • 🔄 PayPal wallet simulation (for address collection)

Demo Flow

  1. User Input: "Nike Shoes, Size 9, Red Sneakers"
  2. Intent Creation: AP2 mandate with refundability
  3. Product Search: Mock catalog search
  4. Cart Creation: Shopping cart with selected items
  5. Address Collection: Simulated PayPal wallet integration
  6. Payment Method: Mastercard selection
  7. Payment Processing: Real Stripe payment via Commerce Rail Agent
  8. Confirmation: Payment success notification

Expected Output

The demo will show:

  • Agent handoffs and communication
  • Payment mandate creation and signing
  • Stripe payment processing
  • Transaction confirmation
  • Audit trail generation

Troubleshooting

Common Issues

  1. Stripe API Errors: Verify your API keys and test mode settings
  2. MCP Connection Issues: Check if Stripe MCP server is running
  3. Agent Communication: Ensure all agents are properly initialized
  4. Payment Failures: Check Stripe dashboard for detailed error logs

Debug Mode

Run with debug logging:

DEBUG=1 ./run.sh

Technical Achievements

  • ✅ First AP2 + Stripe integration
  • ✅ Real payment processing in agent workflows
  • ✅ Payment mandate compliance
  • ✅ Multi-agent coordination
  • ✅ Fallback mechanisms for reliability

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Attribution

This project builds upon Google's AP2 (Agent Payments Protocol) sample code. See ATTRIBUTION.md for full credits.

Support

For issues and questions:

  • Create an issue in this repository
  • Check the troubleshooting section above
  • Review Stripe documentation for payment-related issues

About

AP2 + Stripe V2.0

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors