Prerequisites
Confirm you have everything in place before writing any code:- Checkout API endpoints you control, or the ability to build them
- Payment method handling — Stripe is recommended; Razorpay for India
- A product catalog API
- Idempotency key handling (cache or storage layer for deduplication)
The ACP checkout state machine
Your backend must enforce the transitions below. Do not allow a session to move to any state not shown in this diagram.created→pending_confirmationautomatically on successful cart creationpending_confirmation→confirmedwhen payment succeedspending_confirmation→failedon payment failure (retryable)pending_confirmation→expiredwhenexpires_atpassesconfirmedandexpiredare terminal — no further transitions are allowed
Implementation steps
Implement tool definitions
Define the three ACP tools (
search_products, initiate_checkout, confirm_purchase) as JSON schema objects. These register with ChatGPT through the OpenAI function calling API.See Implement ACP: ChatGPT Instant Checkout for the full tool definitions and endpoint code.Build checkout endpoints
Implement
POST /acp/checkout/create, PATCH /acp/checkout/:id/update, and POST /acp/checkout/:id/complete.Key requirements for each endpoint:- Sessions must expire — use a 15-minute default
- Apply idempotency keys on create and complete
- Re-validate inventory at completion time, not just at creation
Add payment processing
Integrate your PSP on the Catch
/complete endpoint. For Stripe, pass the idempotency key through to the payment intent so retries do not create duplicate charges:CardError and return a payment_declined response so the agent can relay a clear message to the user.Implement error responses
Every failure case must return a structured JSON error object with a machine-readable
code and a human-readable message. The agent surfaces your message text directly in the conversation.See ACP instant checkout UX patterns for the full error taxonomy and response shapes.Add consent and confirmation logic
Before calling
confirm_purchase, the agent must show the user a purchase summary and receive an explicit affirmative response. Your backend cannot enforce this — it is the agent’s responsibility. However, your UI must not trigger payment without a clear user confirmation signal.Test all states
Test the full state machine including edge cases: expired sessions, out-of-stock at confirmation time, declined payments, and duplicate requests with idempotency keys.Run automated endpoint validation with the ACP Validator.
Validation checklist
Use this checklist before enabling ACP in production.| Check | Requirement |
|---|---|
| Endpoint availability | All three endpoints respond with correct schemas |
| State transitions | State machine transitions are deterministic |
| Idempotency | Duplicate requests with the same key return the same response |
| Session expiry | Sessions expire after expires_at; expired sessions return 410 |
| Error shapes | All errors include code and message |
| Payment integration | PSP is integrated; test tokens work in staging |
| Latency | Create < 3 s, Update < 1 s, Complete < 5 s |
| Consent | Purchase summary is surfaced to the user before confirmation |
Test commands
Run thesecurl commands against your staging environment to verify each endpoint.
The idempotency test (third command above) should return an identical response to the first request — same
checkout_id, same status. If it creates a new session, your idempotency layer is not working correctly.Related
ACP checkout: webhooks and going live
Webhooks, idempotency middleware, and production go-live checklist.
ACP vs UCP
When to implement each protocol.