feat: add Stripe checkout, order persistence, and webhook handling

Stripe-hosted Checkout integration with full order lifecycle:
- stripity_stripe ~> 3.2 with sandbox/prod config via env vars
- Order and OrderItem schemas with price snapshots at purchase time
- CheckoutController creates pending order then redirects to Stripe
- StripeWebhookController verifies signatures and confirms payment
- Success page with real-time PubSub updates from webhook
- Shop flash messages for checkout error feedback
- Cart cleared after successful payment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-07 08:30:17 +00:00
parent cff21703f1
commit ff1bc483b9
19 changed files with 931 additions and 69 deletions

View File

@@ -7,19 +7,22 @@
**Working:**
- Theme editor with 8 presets, instant switching, full customization
- Image optimization pipeline (AVIF/WebP/JPEG responsive variants)
- Shop pages (home, collections, products, cart, about, contact)
- Shop pages (home, collections, products, cart, about, contact, error)
- Mobile-first design with bottom navigation
- 100% PageSpeed score
- Variant selector with color swatches and size buttons
- Session-based cart with real variant data (add/remove/quantity, cross-tab sync)
- Cart drawer and cart page with hydrated product info
- Search modal with keyboard shortcut
- Demo content polished and ready for production
**In Progress:**
- Session-based cart
**Next Up:**
- Orders & Fulfillment (Printify submission)
## Next Up
1. **Session-based Cart** - Real cart with actual variants
2. **Stripe Checkout Integration** - Payment processing
3. **Orders & Fulfillment** - Submit orders to Printify
1. **Orders & Fulfillment** - Submit orders to Printify after payment
2. **Email Notifications** - Order confirmation emails
---
@@ -87,19 +90,37 @@ See: [docs/plans/products-context.md](docs/plans/products-context.md) for implem
See: [docs/plans/printify-integration-research.md](docs/plans/printify-integration-research.md) for API research & risk analysis
### Cart & Checkout
**Status:** Planned
**Status:** In Progress
- [ ] Session-based cart module
- [ ] Cart LiveView with real variants
- [ ] Stripe Checkout integration
- [ ] Order creation and persistence
- [x] Cart drawer component with slide-over panel (f244a42)
- [x] Cart page with item list and order summary (f244a42)
- [x] Shared CartHook for cross-page cart events (f244a42)
- [x] CartPersist JS hook for localStorage backup
- [x] Add-to-cart with flash status feedback
- [x] Cart item links to product pages
- [x] Session-based cart with real variants (f244a42)
- Cart stores {variant_id, qty} tuples in session
- Hydrates with real product data via Products context
- Cross-tab sync via PubSub, session persistence via CartController API
- [x] Stripe Checkout integration (stripity_stripe ~> 3.2)
- Stripe-hosted Checkout with redirect flow
- Webhook handler for checkout.session.completed/expired
- Signature verification via CacheRawBody + construct_event
- Shipping address collection during checkout
- [x] Order/OrderItem schemas and context
- Order number format: SS-YYMMDD-XXXX
- Payment status tracking (pending → paid/failed)
- Price snapshots in OrderItem (protects against changes)
- Idempotent webhook processing
- [x] Checkout success page with real-time PubSub updates
- [x] Cart clearing after successful payment
See: [ROADMAP.md](ROADMAP.md) for design notes
### Orders & Fulfillment
**Status:** Planned
- [ ] Orders context with schemas
- [x] Orders context with schemas
- [ ] Order submission to Printify
- [ ] Order status tracking
- [ ] Customer notifications
@@ -119,6 +140,8 @@ See: [docs/plans/page-builder.md](docs/plans/page-builder.md) for design
| Feature | Commit | Notes |
|---------|--------|-------|
| Demo content & link fixes | cff2170 | Broken links, placeholder text, responsive about image |
| Cart UI infrastructure | f244a42 | Cart drawer, cart page, CartHook, CartPersist |
| Variant selector | 880e7a2 | Color swatches, size buttons, price updates |
| Product image download | 1b49b47 | PageSpeed 100% with local images |
| Wire shop to real data | c818d03 | PreviewData uses Products context |