feat: add Printify order submission and fulfilment tracking

Submit paid orders to Printify via provider API with idempotent
guards, Stripe address mapping, and error handling. Track fulfilment
status through submitted → processing → shipped → delivered via
webhook-driven updates (primary) and Oban Cron polling fallback.

- 9 fulfilment fields on orders (status, provider IDs, tracking, timestamps)
- OrderSubmissionWorker with retry logic, auto-enqueued after Stripe payment
- FulfilmentStatusWorker polls every 30 mins for missed webhook events
- Printify order webhook handlers (sent-to-production, shipment, delivered)
- Admin UI: fulfilment column in table, fulfilment card with tracking info,
  submit/retry and refresh buttons on order detail
- Mox provider mocking for test isolation (Provider.for_type configurable)
- 33 new tests (555 total), verified against real Printify API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-08 09:51:51 +00:00
parent 02cdc810f2
commit 3e19887499
22 changed files with 1318 additions and 54 deletions

View File

@@ -19,14 +19,14 @@
- Search modal with keyboard shortcut
- Demo content polished and ready for production
**Next up:** Order management and fulfilment (Tier 1)
**Next up:** Transactional emails — order confirmation and shipping notifications (Tier 1, Roadmap #3)
## Roadmap
### Tier 1 — MVP (can take real orders and fulfil them)
1. **Order management admin** — Admin UI to view orders, filter by status, see order details and line items. The orders context and schemas exist, this is purely the admin LiveView.
2. **Orders & fulfilment** Submit paid orders to Printify via their API. Track fulfilment status (submitted → in production → shipped → delivered). Handle shipping notifications and tracking numbers.
1. ~~**Order management admin**~~ — ✅ Complete (02cdc81). Admin UI at `/admin/orders` with status filter tabs, streamed order table, and detail view showing items, totals, and shipping address.
2. ~~**Orders & fulfilment**~~ — ✅ Complete. Submit paid orders to Printify, track fulfilment status (submitted → processing → shipped → delivered), webhook-driven status updates with polling fallback, admin UI with submit/refresh actions.
3. **Transactional emails** — Order confirmation email on payment. Shipping notification with tracking link. Use Swoosh (already configured) with a simple HTML template.
4. **Default content pages** — Static pages for terms of service, delivery & refunds policy, and privacy policy. Needed for legal compliance before taking real orders. Can be simple markdown-rendered pages initially, upgraded to editable via page editor later.
@@ -117,7 +117,7 @@ See: [docs/plans/image-optimization.md](docs/plans/image-optimization.md) for im
- [ ] OAuth platform integration (appear in Printify's "Publish to" UI)
#### Technical Debt
- [ ] Add HTTP mocking (Mox/Bypass) for Printify API tests
- [x] Mox provider mocking for fulfilment tests (Provider.for_type configurable via app env)
See: [docs/plans/products-context.md](docs/plans/products-context.md) for implementation details
See: [docs/plans/printify-integration-research.md](docs/plans/printify-integration-research.md) for API research & risk analysis
@@ -172,13 +172,25 @@ See: [ROADMAP.md](ROADMAP.md) for design notes
- CSSCache test startup crash fixed (handle_continue pattern)
### Orders & Fulfilment
**Status:** In progress — schemas and checkout done, fulfilment pending (Tier 1)
**Status:** Complete (checkout, admin, fulfilment). Transactional emails pending (Roadmap #3).
- [x] Orders context with schemas (ff1bc48)
- [x] Stripe Checkout integration with webhook handling
- [ ] Order management admin UI (Roadmap #1)
- [ ] Printify order submission (Roadmap #2)
- [ ] Fulfilment status tracking (Roadmap #2)
- [x] Order management admin UI (02cdc81, Roadmap #1)
- Order list with status filter tabs (all/paid/pending/failed/refunded) and counts
- Streamed table with row click navigation to detail
- Order detail with info card, shipping address, line items table with totals
- Nav link in admin bar, 15 tests
- [x] Printify order submission and fulfilment tracking (Roadmap #2)
- 9 fulfilment fields on orders (status, provider_order_id, tracking, timestamps)
- `submit_to_provider/1` with idempotent guard, error handling, address mapping
- `refresh_fulfilment_status/1` polls provider for status updates
- OrderSubmissionWorker (Oban, :checkout queue, max_attempts: 3)
- FulfilmentStatusWorker (Oban Cron, every 30 mins, :sync queue)
- Printify order webhook handlers (sent-to-production, shipment:created, shipment:delivered)
- Stripe webhook auto-enqueues submission after payment confirmed
- Admin UI: fulfilment badge column, fulfilment card with tracking, submit/refresh buttons
- Mox provider mocking for test isolation, 33 new tests (555 total)
- [ ] Transactional emails (Roadmap #3)
See: [docs/plans/products-context.md](docs/plans/products-context.md) for schema design
@@ -196,6 +208,8 @@ See: [docs/plans/page-builder.md](docs/plans/page-builder.md) for design
| Feature | Commit | Notes |
|---------|--------|-------|
| Printify order submission & fulfilment | — | Submit, track, webhooks, polling, admin UI, 33 tests |
| Order management admin | 02cdc81 | List/detail views, status filters, 15 tests |
| Encrypted settings & Stripe setup | eede9bb | Guided setup flow, encrypted secrets, admin credentials page |
| Stripe checkout & orders | ff1bc48 | Stripe Checkout, webhooks, order persistence |
| Demo content & link fixes | cff2170 | Broken links, placeholder text, responsive about image |