examples/storefront Public
title: Checking out a cartdescription: >- The shopper checks out an open cart. storefront-api takes the stock and creates the order in one D1 batch, then asks Stripe for a PaymentIntent and hands its client secret to the browser, which confirms the payment with the Payment Element. Stripe reports the result to stripe-webhook, which marks the order paid through OrdersService.actors: [shopper]steps: - { from: shopper, to: storefront-api, label: "POST /carts/:id/checkout, email and address" } - { from: storefront-api, to: db, label: read the cart and check the stock } - { from: storefront-api, to: db, label: "one batch: insert the order, take the stock, close the cart" } - { from: storefront-api, to: stripe, label: create a PaymentIntent for the order total } - { from: storefront-api, to: db, label: save the PaymentIntent id on the order } - { from: storefront-api, to: shopper, label: the order and the client secret } - { from: shopper, to: stripe, label: confirm the payment with the Payment Element } - { from: stripe, to: stripe-webhook, label: "payment_intent.succeeded, signed" } - { from: stripe-webhook, to: storefront-api, label: "OrdersService.markPaid(order, intent)" } - { from: storefront-api, to: db, label: mark the order paid if it is still pending } - { from: shopper, to: storefront-api, label: "GET /orders/:id until it is paid" }