Skip to Content
🚀Agentic Commerce Protocol is now live! Instant Checkout is available in ChatGPT. Learn more →
DocumentationSet Up Your StoreStripe Agent Toolkit

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 stripe

Quick 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

ActionDescription
products.listList available products
products.readGet product details
prices.listList product prices
prices.readGet price details
paymentLinks.createCreate checkout links
customers.createCreate 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

  1. Use Test Mode First: Develop with sk_test_ keys
  2. Secure Secrets: Store API keys in environment variables
  3. Enable Logging: Monitor agent interactions
  4. Set Rate Limits: Protect against abuse

Resources

Specification maintained by OpenAI and Stripe

AboutPrivacyTermsRSS

Apache 2.0 · Open Source