# Checkout Flow

## User Journey
1. User lands on `shop.html` or a PDP.
2. User opens PDP and clicks buy (`add_to_cart`).
3. User reviews cart in `cart.html` and starts checkout (`begin_checkout`).
4. Payment handled by Stripe Checkout session (demo payment in this prototype).
5. Successful payment creates order record and triggers `purchase`.
6. User is redirected to `thank-you.html`.
7. User enters upsell sequence.
8. User reaches `download.html` with all entitled assets.

## Payment Integration Point
- Current prototype action: `Pay Now (Demo)` button.
- Production replacement:
  - Create Stripe Checkout session on server.
  - Redirect to Stripe-hosted checkout.
  - Confirm payment via webhook (`checkout.session.completed`).
  - Issue download entitlement records.

## Post-Payment Email Structure
1. Receipt email: transaction summary and legal details.
2. Delivery email: secure links + quickstart docs.
3. Cross-sell email (4-24 hours): related products or membership bridge.

## Edge Cases
- Failed payment:
  - Keep cart intact.
  - Show retry CTA and alternate payment method prompt.
- Duplicate purchase attempt:
  - Check existing entitlement by user email + SKU.
  - Route to already-owned state or offer team license delta.
- Expired download link:
  - Tokenized link refresh endpoint.
  - Audit log for abuse prevention.
