Changes
Comparing empty → 160dc49.
| @@ -1,0 +1,58 @@ | ||
| 1 | +--- | |
| 2 | +title: A test checkout, end to end | |
| 3 | +sort: 3 | |
| 4 | +--- | |
| 5 | + | |
| 6 | +# A test checkout, end to end | |
| 7 | + | |
| 8 | +In test mode, no money moves and no order email is sent. The flow walks the same code paths as | |
| 9 | +production, including tax calculation and webhook delivery. | |
| 10 | + | |
| 11 | +## 1. Create a cart | |
| 12 | + | |
| 13 | +```bash | |
| 14 | +zephyr carts create --line-item prod_01HXY4M9C0AVE0M1QGPS9XK7T2:2 | |
| 15 | +# โ cart_01HXY4QH6QMEN0SEN1GHX7YK9C | |
| 16 | +``` | |
| 17 | + | |
| 18 | +## 2. Attach a customer | |
| 19 | + | |
| 20 | +```bash | |
| 21 | +zephyr carts attach-customer cart_01HXY4QH6QMEN0SEN1GHX7YK9C \ | |
| 22 | + --email "linnea.ek@example.com" \ | |
| 23 | + --shipping-address-de | |
| 24 | +``` | |
| 25 | + | |
| 26 | +The `--shipping-address-de` flag uses a built-in test address for Germany โ good enough to make | |
| 27 | +the tax engine happy. | |
| 28 | + | |
| 29 | +## 3. Create a checkout session | |
| 30 | + | |
| 31 | +```bash | |
| 32 | +zephyr checkouts create --cart cart_01HXY4QH6QMEN0SEN1GHX7YK9C | |
| 33 | +``` | |
| 34 | + | |
| 35 | +The response includes a `checkout_url`. In test mode that URL renders a sandbox payment form. | |
| 36 | + | |
| 37 | +## 4. Complete with a test card | |
| 38 | + | |
| 39 | +Open the `checkout_url`, enter card `4242 4242 4242 4242`, any future expiry, any CVC, any postal | |
| 40 | +code. The session completes within ~2 seconds and emits two webhooks: | |
| 41 | + | |
| 42 | +- `checkout.session.completed` | |
| 43 | +- `order.created` | |
| 44 | + | |
| 45 | +See those land: | |
| 46 | + | |
| 47 | +```bash | |
| 48 | +zephyr webhooks tail --event 'order.created' | |
| 49 | +``` | |
| 50 | + | |
| 51 | +## What just happened | |
| 52 | + | |
| 53 | +A new order resource exists at `GET /v1/orders/{order_id}`. In test mode it's flagged | |
| 54 | +`livemode=false` and is invisible to the production dashboard. Test orders are pruned after 30 | |
| 55 | +days; keep the order id somewhere if you want to refer to it later. | |
| 56 | + | |
| 57 | +You're done. Read [How a request flows](../architecture/request-lifecycle.md) next for the | |
| 58 | +mental model behind the API. | |