Stripe Agent Toolkit
The Stripe Agent Toolkit provides the fastest path to ACP integration.
🚀
Go from zero to production in hours, not weeks.
Overview
The Agent Toolkit handles:
- Checkout session management
- Payment token validation
- Request signature verification
- Order webhook delivery
Installation
npm install @stripe/agent-toolkit stripeQuick Setup
Configure Stripe
import Stripe from 'stripe';
import { AgentToolkit } from '@stripe/agent-toolkit';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2024-12-18.acacia',
});Initialize Toolkit
const toolkit = new AgentToolkit({
stripe,
configuration: {
actions: {
paymentLinks: { create: true },
products: { list: true, read: true },
prices: { list: true, read: true },
}
}
});Mount Routes
import express from 'express';
const app = express();
app.use('/acp', toolkit.expressMiddleware());
app.listen(3000);Configuration Options
const toolkit = new AgentToolkit({
stripe,
configuration: {
// Enable specific actions
actions: {
paymentLinks: { create: true },
products: { list: true, read: true },
prices: { list: true, read: true },
customers: { create: true, read: true },
},
// Custom context
context: 'You are a helpful shopping assistant...',
}
});Available Actions
| Action | Description |
|---|---|
products.list | List available products |
products.read | Get product details |
prices.list | List product prices |
prices.read | Get price details |
paymentLinks.create | Create checkout links |
customers.create | Create customer records |
Framework Integration
Express
app.use('/acp', toolkit.expressMiddleware());Next.js API Routes
// pages/api/acp/[...path].ts
import { toolkit } from '@/lib/stripe';
export default function handler(req, res) {
return toolkit.nextApiHandler(req, res);
}Vercel AI SDK
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
const result = await generateText({
model: openai('gpt-4o'),
tools: toolkit.getTools(),
prompt: 'Help me buy a new laptop',
});Product Catalog Sync
The toolkit can sync with your Stripe product catalog:
// Products created in Stripe Dashboard
// are automatically available to agents
const products = await stripe.products.list({
active: true,
limit: 100,
});Handling Webhooks
// Webhook endpoint for order notifications
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
const sig = req.headers['stripe-signature'];
const event = stripe.webhooks.constructEvent(
req.body,
sig,
process.env.WEBHOOK_SECRET!
);
switch (event.type) {
case 'checkout.session.completed':
await handleOrder(event.data.object);
break;
}
res.json({ received: true });
});Best Practices
- Use Test Mode First: Develop with
sk_test_keys - Secure Secrets: Store API keys in environment variables
- Enable Logging: Monitor agent interactions
- Set Rate Limits: Protect against abuse