A demonstration of Agent-to-Agent (A2A) commerce workflows using Google's AP2 (Agent Payments Protocol) integrated with Stripe payment processing.
This project showcases a complete e-commerce flow where multiple AI agents collaborate to:
- Search for products
- Create shopping carts
- Collect shipping addresses
- Process payments via Stripe
- Handle payment mandates and compliance
The demo simulates a real-world scenario where a user purchases Nike shoes through an AI-powered shopping experience.
User Input → Root Agent → Shopping Agent → Address Collector → Payment Collector → Commerce Rail Agent → Stripe
- 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
- Python 3.8+
- Stripe account with API keys
- Google Cloud credentials (for AP2 framework)
- Clone the repository:
git clone <your-repo-url>
cd a2a-stripe-demo- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp config/.env.example .env
# Edit .env with your actual API keys- Run the demo:
./run.sh# 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- ✅ Stripe payment processing
- ✅ Payment method validation
- ✅ Customer creation and management
- ✅ Payment intent creation
- ✅ Transaction recording
- 🔄 Product catalog (uses mock Nike shoes)
- 🔄 Inventory management
- 🔄 Shipping calculations
- 🔄 Order fulfillment
- 🔄 PayPal wallet simulation (for address collection)
- User Input: "Nike Shoes, Size 9, Red Sneakers"
- Intent Creation: AP2 mandate with refundability
- Product Search: Mock catalog search
- Cart Creation: Shopping cart with selected items
- Address Collection: Simulated PayPal wallet integration
- Payment Method: Mastercard selection
- Payment Processing: Real Stripe payment via Commerce Rail Agent
- Confirmation: Payment success notification
The demo will show:
- Agent handoffs and communication
- Payment mandate creation and signing
- Stripe payment processing
- Transaction confirmation
- Audit trail generation
- Stripe API Errors: Verify your API keys and test mode settings
- MCP Connection Issues: Check if Stripe MCP server is running
- Agent Communication: Ensure all agents are properly initialized
- Payment Failures: Check Stripe dashboard for detailed error logs
Run with debug logging:
DEBUG=1 ./run.sh- ✅ First AP2 + Stripe integration
- ✅ Real payment processing in agent workflows
- ✅ Payment mandate compliance
- ✅ Multi-agent coordination
- ✅ Fallback mechanisms for reliability
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
This project builds upon Google's AP2 (Agent Payments Protocol) sample code. See ATTRIBUTION.md for full credits.
For issues and questions:
- Create an issue in this repository
- Check the troubleshooting section above
- Review Stripe documentation for payment-related issues