The Checkout Flow
1
Cart
The customer builds the cart. Each change goes through
POST /cart/quote.2
Contact and address
Collect the name, email, phone and shipping address. Quote with the address as
destination.3
Shipping
Show
shippingOptions, quote with the chosen method, and collect a pickup point when the option needs one (quote
again with the point’s postal code as destination).4
Codes, gifts and store credit
Apply codes, run the email verification when a code asks for it, let the customer pick gifts, check a store
credit.
5
Review
Show the final quote. Keep its
totals.total as expectedTotal, and create a fresh idempotency key for this
attempt.6
Place the order
POST /orders. On 409 TOTAL_CHANGED, quote again and show the new total before you try again.7
Pay
POST /orders/:publicId/payment and redirect the browser to the Stripe URL, unless due is 0.8
Confirm
Stripe sends the customer back to your success page. Read
GET /orders/:publicId/status there.Create an Order
POST /orders
Session: checkout. Header: Idempotency-Key (required). Rate limit: order.create.
Addresses
Text fields are up to 255 characters.
Request
Response 201
publicId is the order’s public id (a UUID). Use it in every later call and URL. reference is the number the customer sees. After a new order, Strapi empties the cart (the email, destination and locale stay).
Idempotency Keys
An idempotency key is a unique string you attach to a request so that sending it twice does the work only once. Create one key per checkout attempt (a UUID fromcrypto.randomUUID() fits the format) and reuse it when you retry the same attempt after a timeout or a 5xx:
- The same key on the same session returns the same order (
201again, no second charge, no second stock or promotion use). - The same key from another session creates that session’s own order.
- A retry after the guest session expired gets
401 SESSION_INVALID. The order still exists. - Create a new key whenever the customer changes something in the checkout.
Order Errors
Strapi checks everything before it writes anything. A refused order uses no stock, no promotion and no store credit.Place the Order and Pay
src/app/(store)/checkout/actions.ts