Stripe ACP Integration: Spec, Webhooks and Code Examples

The Agentic Commerce Protocol lets ChatGPT check out on your store: it calls five endpoints you host, then hands you a Stripe SharedPaymentToken to charge. Here is what each endpoint does, how to charge the token, and how to handle the webhooks, checked against OpenAI's and Stripe's docs in November 2026.

Before you write any code

  • - Approval from OpenAI for in-chat checkout. OpenAI's checkout spec is open to read, but ChatGPT only calls approved merchants.
  • - A Stripe account with a Stripe profile, and the agentic commerce seller preview terms accepted
  • - A Stripe account in a country that supports shared payment tokens (the US, Canada and a list of European countries)
  • - Node.js 18+ for the examples below

How does Stripe ACP work?

The Agentic Commerce Protocol (ACP) is an open spec for an AI agent to check out on your store. You host a small checkout API. The agent (ChatGPT, for example) calls it to create a checkout session, update it as the customer picks a shipping option, and complete it. At completion the agent passes you a Stripe SharedPaymentToken (SPT), a single-use grant to charge the customer's chosen payment method, and you charge it with a normal PaymentIntent.

There is no ACP switch in the Stripe Dashboard and no special option on Stripe Checkout Sessions. The protocol lives in endpoints you build. Stripe's part is the token and the payment.

Building the endpoints does not get you into ChatGPT. Apply to OpenAI first. Until you are approved, ChatGPT shoppers finish their purchase on your own site, and that needs none of this.

Step 1: Implement the five checkout endpoints

OpenAI's spec says merchants "must implement the following five endpoints":

  • POST /checkout_sessions creates a session from the items the customer wants
  • POST /checkout_sessions/{id} updates it (items, address, shipping choice)
  • POST /checkout_sessions/{id}/complete takes payment and places the order
  • POST /checkout_sessions/{id}/cancel cancels it
  • GET /checkout_sessions/{id} returns its current state

Every response returns the whole session: line items, totals, fulfillment options, any messages for the customer, and a status of not_ready_for_payment, ready_for_payment, completed or canceled. Requests arrive with Authorization, Idempotency-Key, API-Version, Timestamp and a Signature header computed over the request body. Check the signature before you trust anything in the request, and replay the stored response when you see an idempotency key twice.

Step 2: Charge the SharedPaymentToken on complete

The complete request carries a payment_data object with a token and a provider. For Stripe the token is an SPT (spt_...). Stripe's SPT docs show the charge: a PaymentIntent with payment_method_data[shared_payment_granted_token] and confirm: true. SPTs use a preview API version, so pin the version Stripe's SPT page shows.

import express from 'express';
import Stripe from 'stripe';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
  apiVersion: '2026-09-30.preview', // the preview version from Stripe's SPT docs
});

const app = express();

// Parse JSON only on the ACP routes, and keep the raw bytes:
// the Signature header is computed over the raw request body.
const acp = express.Router();
acp.use(express.json({ verify: (req, _res, buf) => { req.rawBody = buf; } }));

acp.post('/checkout_sessions/:id/complete', async (req, res) => {
  if (!verifyAcpRequest(req)) {           // your check of Authorization + Signature
    return res.status(401).end();
  }

  const session = await loadCheckoutSession(req.params.id); // your storage
  if (!session) {
    return res.status(404).json(acpError('not_found', 'Unknown checkout session'));
  }

  // A retry of a finished checkout gets the stored answer, never a second order
  if (session.status === 'completed') {
    return res.json(session);
  }
  if (session.status !== 'ready_for_payment') {
    return res.status(409).json(acpError('invalid_state', 'Session is not ready for payment'));
  }

  const { token, provider } = req.body.payment_data;
  if (provider !== 'stripe') {
    return res.status(400).json(acpError('invalid_request', 'Unsupported payment provider'));
  }

  // 1. Charge. Key the request to the checkout session, so a retry gets the
  //    same PaymentIntent back from Stripe instead of a second charge.
  let paymentIntent;
  try {
    paymentIntent = await stripe.paymentIntents.create(
      {
        amount: session.totalInMinorUnits,
        currency: session.currency,
        payment_method_data: { shared_payment_granted_token: token },
        confirm: true,
        metadata: { checkout_session_id: session.id },
      },
      { idempotencyKey: `acp-complete-${session.id}` },
    );
  } catch (err) {
    // Card declines and expired or over-limit tokens land here
    return res.status(400).json(acpError('payment_declined', err.message));
  }

  // 2. Only a succeeded PaymentIntent means you have the money
  if (paymentIntent.status === 'processing') {
    await markPaymentPending(session.id, paymentIntent.id);
    // Answer with the session still open and an info message. The
    // payment_intent.succeeded webhook finishes the order later.
    return res.json(await loadCheckoutSession(session.id));
  }
  if (paymentIntent.status !== 'succeeded') {
    return res.status(400).json(acpError('payment_declined', `Payment ${paymentIntent.status}`));
  }

  // 3. The customer has paid. From here on, never report a decline.
  try {
    // completeOrder must be idempotent per checkout session (for example a
    // unique constraint on session.id), so this route and the webhook can
    // both call it safely. It saves the session as 'completed' with its order.
    const completed = await completeOrder(session.id, paymentIntent.id);
    return res.json(completed);
  } catch (err) {
    // Paid but not recorded yet: ask the agent to retry. The retry gets the
    // same PaymentIntent from Stripe and calls completeOrder again.
    return res.status(500).json(acpError('processing_error', 'Payment received, order not recorded yet. Retry.'));
  }
});

app.use('/acp', acp);

Three rules carry the weight here. Check paymentIntent.status before you place the order, because Stripe's status guide treats only succeeded as paid and processing as still waiting. Once the charge succeeds, never answer with a decline: if your order system fails, return an error the agent will retry, and let the retry finish the job. And answer a retry of a completed checkout with the stored session, without creating a second order.

verifyAcpRequest, loadCheckoutSession, markPaymentPending, completeOrder and acpError are yours to write: they depend on your store and on the exact session, message and error formats in OpenAI's spec. When Stripe confirms the PaymentIntent, it clones the customer's payment method onto it, so refunds and reports treat the payment like any other.

Step 3: Handle Stripe webhooks with a raw body

Stripe signs every webhook, and stripe.webhooks.constructEvent checks that signature against the exact bytes Stripe sent. If any JSON parser runs on the route first, the check fails. Mount express.raw on the webhook route and keep global JSON parsing off it. The two-router setup above does that.

app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
  let event;
  try {
    event = stripe.webhooks.constructEvent(
      req.body,                              // a Buffer, untouched
      req.headers['stripe-signature'],
      process.env.STRIPE_WEBHOOK_SECRET,
    );
  } catch (err) {
    return res.status(400).send(`Webhook Error: ${err.message}`);
  }

  try {
    const sessionId = event.data.object.metadata?.checkout_session_id; // ACP charges only
    switch (event.type) {
      case 'payment_intent.succeeded':
        // Finishes orders whose payment was still processing, and any order
        // the complete route charged but failed to record. Idempotent.
        if (sessionId) await completeOrder(sessionId, event.data.object.id);
        break;
      case 'payment_intent.payment_failed':
        if (sessionId) await markPaymentFailed(sessionId);
        break;
      case 'shared_payment.granted_token.deactivated':
        // The token was used, expired or revoked. It can't be charged again.
        break;
    }
  } catch (err) {
    return res.status(500).end(); // Stripe retries failed deliveries
  }

  res.json({ received: true });
});

shared_payment.granted_token.deactivated is the SPT event in Stripe's docs. The PaymentIntent events are the standard ones. Use Stripe's webhook guide to register the endpoint and get its signing secret.

Step 4: Send order webhooks to OpenAI

Webhooks also run the other way. The spec has you send OpenAI an order_created event when you place the order and order_updated as it moves through confirmed, shipped, fulfilled or canceled. Each event is signed with an HMAC using a key OpenAI gives you. Take the payload shape and signature header from the spec rather than from any blog post, this one included. OpenAI checks webhook delivery when it certifies your integration.

Step 5: Test with a sandbox token

You don't need an agent to test the payment side. In a sandbox, Stripe's test helper grants your account an SPT backed by a test card, with the same kind of limits an agent would set:

curl https://api.stripe.com/v1/test_helpers/shared_payment/granted_tokens \
  -u "sk_test_...:" \
  -H "Stripe-Version: 2026-09-30.preview" \
  -d payment_method=pm_card_visa \
  -d "usage_limits[currency]=usd" \
  -d "usage_limits[max_amount]=1000" \
  -d "usage_limits[expires_at]=1798761600"

# Forward Stripe webhooks to your local server
stripe listen --forward-to localhost:3000/webhooks/stripe

Send the returned spt_... to your complete endpoint as payment_data.token. Then confirm the PaymentIntent succeeds, your webhook handler sees payment_intent.succeeded, and a second complete call returns the stored session without charging or creating another order. Make your order system throw once after a successful charge, too: the retry should finish the order, not report a decline. Try an amount above max_amount as well: it should fail.

What about WooCommerce, BigCommerce and Magento?

This guide covers a custom integration. If your platform or its Stripe plugin ships ACP support, use it and follow that vendor's docs; check the plugin's changelog rather than assuming a setting exists. Otherwise you build the endpoints above next to your store and read prices, stock and shipping rates from it. The platform guides cover the rest of agent readiness: WooCommerce, BigCommerce and Magento.

What does an ACP sale cost?

Stripe charges its normal processing fee on the PaymentIntent. Any fee for checkout inside ChatGPT is set by your agreement with OpenAI. We haven't found a public rate we can confirm, so check the terms you're offered before you build. Purchases that ChatGPT sends to your own site carry no OpenAI fee, according to OpenAI's merchant page.

Is Your Store Ready for ACP?

ACP is one piece of the agentic commerce stack. Our free Agent Ready Score checks your schema markup, product data, policies, and 20+ other factors AI shopping agents look for.

Get Your Free Score →

What changed in AI shopping, every two weeks

Agent Ready HQ on Substack covers ChatGPT Shopping, Google AI Mode, and the UCP and ACP protocols in plain terms for store owners. Each issue ends with one fix you can make to your store that week.

Sign up on Substack

Free. Opens Substack in a new tab.