Skip to content

feat: connect Shop V2 to persistent commerce and secure checkout - #3

Draft
QaliAI wants to merge 8 commits into
feature/commerce-foundation-sprint-1from
feature/commerce-production-sprint-2
Draft

QaliAI wants to merge 8 commits into
feature/commerce-foundation-sprint-1from
feature/commerce-production-sprint-2

Conversation

@QaliAI

@QaliAI QaliAI commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

This stacked Sprint 2 PR moves Shop V2 from its local prototype toward production-capable commerce. It is intentionally based on feature/commerce-foundation-sprint-1 so reviewers see only Sprint 2 changes.

Milestone status

  • Persistent immutable commerce configurations
  • Validated curated Printify catalog
  • Curated designs and collections
  • Secure Stripe test checkout
  • Idempotent dry-run Printify fulfillment
  • Hardened commerce webhooks and order state
  • End-to-end commerce flow
  • Vercel preview release
  • Commerce-first Homepage V2

Checkpoint 01 ? persistent cart

Commit: 76e3014 feat: persist immutable commerce configurations

Tag: checkpoint/commerce-s2-01-persistent-cart

Implemented:

  • versioned, validated cart and order configuration snapshots
  • deterministic configuration hashes
  • immutable order snapshot database trigger
  • guest cart HttpOnly session tokens stored only as SHA-256 digests
  • authenticated cart compatibility and secure guest-cart claiming
  • server-side Supabase cart repository behind COMMERCE_PERSISTENCE_ENABLED=false
  • local-storage v1-to-v2 resilience migration
  • immutable snapshot copying during order creation
  • rollback instructions

Validation:

  • npm test: 31 passed, 1 skipped live smoke test
  • npm run test:e2e: 1 passed at 375?812
  • npm run typecheck: passed
  • npm run lint: passed with 23 pre-existing warnings and no errors
  • npm run build: passed
  • migration applied twice to disposable local PostgreSQL 16; guest restoration and immutable-order enforcement verified

Safety

  • No production database migration was applied.
  • No production deployment was performed.
  • Stripe remains test/disabled unless explicitly configured.
  • No Printify product or order write occurred.
  • Nothing was merged into master.

Checkpoint 02 ? validated curated Printify catalog

Commit: 5c0aba6 feat: add validated curated Printify catalog

Tag: checkpoint/commerce-s2-02-live-catalog

Implemented:

  • server-only approved launch catalog for one front-print tee and one matte poster
  • current Printify blueprint/provider/variant/placement mappings
  • typed cached catalog reads with a conservative request budget and 429 handling
  • server-side ID, price, currency, availability, and placement validation before persistent cart writes
  • protected read-only sync route with dry-run reporting
  • catalog, provider, variant, placement, shipping, retail-price, and sync-run database structures
  • retail prices are never changed by sync

Validation:

  • full suite: 37 passed, 2 skipped when live mode is off
  • live read-only Printify suite: 2 passed, including approved-catalog dry-run
  • E2E, typecheck, lint, and production build passed
  • migration applied twice to disposable local PostgreSQL 16

Safety: no Printify write endpoint was called and no remote database migration was applied.

Checkpoint 03 ? curated designs and collections

Commit: d2645ec feat: connect curated designs and collections to Shop V2

Tag: checkpoint/commerce-s2-03-curated-designs

Implemented:

  • versioned design assets, curated designs, defaults, compatibility, collections, and drops schema
  • RLS-denied production tables and server-only published views
  • server repository with non-production-only five-design seed fallback
  • /designs, /designs/[slug], /drops, /drops/[slug], and /collections/[slug]
  • New, Trending, Bestsellers, and Archive filters; seed data makes no bestseller claim
  • Shop V2 repository integration and server-side design/version/asset/product compatibility validation
  • mobile dialog focus trap, Escape close, and focus restoration

Validation:

  • full suite: 42 passed, 2 skipped when live mode is off
  • Playwright: 3 passed at 375?812
  • typecheck, lint, and production build passed
  • migration applied twice to disposable local PostgreSQL 16

Safety: no remote migration or production deployment was performed.

Checkpoint 04 ? secure Stripe test checkout

Commit: a2ddce2 feat: add secure Stripe test checkout

Tag: checkpoint/commerce-s2-04-secure-checkout

Implemented:

  • guest-compatible server-side checkout with browser input limited to a UUID idempotency key
  • cart, design, version, asset, price, currency, placement, and live availability revalidation
  • transactional pending order and immutable order-item creation before Stripe redirect
  • Stripe-hosted Checkout with shipping collection and Dashboard-managed eligible payment methods
  • test-key-only and migration feature gates
  • duplicate request prevention at database and Stripe idempotency layers
  • raw-body signature verification, event deduplication, amount/currency/address checks, and webhook-authoritative paid state
  • success and cancellation routes that never treat a browser redirect as proof of payment

Validation:

  • full suite: 49 passed, 2 skipped when live mode is off
  • Playwright: 4 passed at 375?812
  • typecheck, lint, and production build passed
  • checkout migration applied twice to disposable PostgreSQL 16; pending-order idempotency, session attachment, duplicate webhook receipt, and paid transition verified

Blocker: the local environment contains a live-mode Stripe secret, not a test key. The implementation rejects it and no Stripe API request or payment was attempted. A dedicated sk_test_... key is required for an external test Checkout smoke test.

Checkpoint 05 ? idempotent dry-run Printify fulfillment

Commit: f7c285c feat: add idempotent dry-run Printify fulfillment

Tag: checkpoint/commerce-s2-05-fulfillment

Implemented:

  • persistent fulfillment jobs, attempts, event linkage, locks, and state machine
  • PRINTIFY_FULFILLMENT_MODE=disabled default with disabled/dry-run/live validation
  • payload construction solely from paid immutable order snapshots
  • blueprint/provider/variant/artwork/placement/address/quantity validation
  • SHA-256 payload identity and PII-redacted dry-run storage
  • duplicate-job protection and completed-job replay safety
  • conservative retry classification, including manual review after uncertain network submission
  • live production guard requiring paid order, fulfillment-ready state, existing Printify order ID, explicit live mode, and no prior submission
  • protected operations list and manual prepare endpoints

Validation:

  • full suite: 56 passed, 2 skipped when live mode is off
  • Playwright: 4 passed at 375?812
  • typecheck, lint, and production build passed
  • migration applied twice to disposable PostgreSQL 16; paid-event job creation, locking, and completed-job deduplication verified

Safety: automated tests made zero Printify writes. No live order was created or sent to production.

Milestone 7 ? hardened commerce webhooks and order state

Commit: a7da055 feat: harden commerce webhooks and order state

Implemented:

  • Printify HMAC-SHA256 verification over the exact raw body using the documented X-Pfy-Signature format
  • Zod validation for documented Printify event/resource envelopes and shipment fields
  • service-role-only raw event audit storage, external event-ID deduplication, and redacted normal responses
  • atomic monotonic order/fulfillment transitions for created, sent-to-production, in-production, shipped, delivered, cancelled, and failed states
  • carrier, tracking number, tracking URL, shipped-at, and delivered-at persistence
  • failed-event claiming with one-at-a-time safe replay for both Stripe and Printify
  • protected failed-event list and replay endpoints
  • unique non-null Printify order identifiers to prevent ambiguous event routing

Validation:

  • full suite: 66 passed, 2 skipped when live mode is off
  • targeted webhook suite: 17 passed
  • typecheck, lint, and production build passed
  • all seven migrations applied and replayed against disposable PostgreSQL 16
  • SQL behavior verified applied shipment progression, ignored regression, tracking persistence, and single-claim replay

Safety: no Printify write, Stripe API call, remote migration, or production deployment occurred. The existing checkpoint/commerce-s2-05-fulfillment tag was not moved; published tags remain immutable.

Milestone 7 ? hardened commerce webhooks and order state

Commit: a7da055 feat: harden commerce webhooks and order state

Implemented:

  • Printify HMAC-SHA256 verification over the exact raw body using the documented X-Pfy-Signature format
  • Zod validation for documented Printify event/resource envelopes and shipment fields
  • service-role-only raw event audit storage, external event-ID deduplication, and redacted normal responses
  • atomic monotonic order/fulfillment transitions for created, sent-to-production, in-production, shipped, delivered, cancelled, and failed states
  • carrier, tracking number, tracking URL, shipped-at, and delivered-at persistence
  • failed-event claiming with one-at-a-time safe replay for both Stripe and Printify
  • protected failed-event list and replay endpoints
  • unique non-null Printify order identifiers to prevent ambiguous event routing

Validation:

  • full suite: 66 passed, 2 skipped when live mode is off
  • targeted webhook suite: 17 passed
  • typecheck, lint, and production build passed
  • all seven migrations applied and replayed against disposable PostgreSQL 16
  • SQL behavior verified applied shipment progression, ignored regression, tracking persistence, and single-claim replay

Safety: no Printify write, Stripe API call, remote migration, or production deployment occurred. The existing checkpoint/commerce-s2-05-fulfillment tag was not moved; published tags remain immutable.

Milestone 7 — hardened commerce webhooks and order state

Commit: a7da055 feat: harden commerce webhooks and order state

Implemented:

  • Printify HMAC-SHA256 verification over the exact raw body using the documented X-Pfy-Signature format
  • Zod validation for documented Printify event/resource envelopes and shipment fields
  • service-role-only raw event audit storage, external event-ID deduplication, and redacted normal responses
  • atomic monotonic order/fulfillment transitions for created, sent-to-production, in-production, shipped, delivered, cancelled, and failed states
  • carrier, tracking number, tracking URL, shipped-at, and delivered-at persistence
  • failed-event claiming with one-at-a-time safe replay for both Stripe and Printify
  • protected failed-event list and replay endpoints
  • unique non-null Printify order identifiers to prevent ambiguous event routing

Validation:

  • full suite: 66 passed, 2 skipped when live mode is off
  • targeted webhook suite: 17 passed
  • typecheck, lint, and production build passed
  • all seven migrations applied and replayed against disposable PostgreSQL 16
  • SQL behavior verified applied shipment progression, ignored regression, tracking persistence, and single-claim replay

Safety: no Printify write, Stripe API call, remote migration, or production deployment occurred. The existing checkpoint/commerce-s2-05-fulfillment tag was not moved; published tags remain immutable.

Milestone 8 — end-to-end commerce flow

Commit: 8e7defd test: complete Shop V2 commerce flow

Implemented:

  • development-only, secret-gated, in-memory commerce harness that is unreachable when NODE_ENV=production
  • isolated persistent cart sessions for browser tests
  • real secure-checkout, Stripe-signature, webhook-idempotency, and fulfillment-service execution with no external API calls
  • mobile 375×812 and desktop 1440×900 Playwright projects
  • complete browse, configure, product switch, placement preservation, size selection, persistent restore, test Checkout, signed webhook, paid order, dry-run fulfillment, duplicate event, and confirmation flow
  • explicit assertion that dry-run completes once and Printify write count remains zero

Validation:

  • Vitest: 66 passed, 2 live tests skipped when opt-in is off
  • Playwright: 8 passed across mobile and desktop
  • typecheck passed
  • lint passed with the same 23 historical warnings and no errors
  • production build passed

Safety: the harness is disabled by default, requires an explicit test-mode flag plus request secret, and returns 404 in production. No Stripe, Printify, remote database, or deployment write occurred.

Milestone 9 — Vercel preview (blocked at environment gate)

Commit: 4f47200 chore: add preview health check

Preview deployment: https://printme-izd4qjubb-qaliais-projects.vercel.app

Observed:

  • automatic GitHub branch deployment reached Vercel READY
  • deployment target is preview (target: null), not production
  • /api/health returns 200 with status: ok
  • /shop-v2, /designs, and design detail remain feature-gated 404s because the preview environment does not have NEXT_PUBLIC_COMMERCE_V2_ENABLED=true

Blockers:

  • no Stripe test secret is available; the only local Stripe secret is live-mode and the application correctly rejects it
  • the connected Vercel integration can inspect/deploy but does not expose preview environment-variable management, and the local Vercel CLI has no authenticated session
  • checkout, signed Stripe test webhook, and dry-run fulfillment therefore cannot be verified on the hosted preview

Safety:

  • no production promotion or production environment-variable change occurred
  • no live Stripe request, payment, remote migration, or Printify write occurred
  • checkpoint/commerce-s2-06-preview-release was not created because the release gate did not pass
  • Homepage V2 remains intentionally unstarted because Milestone 10 is gated on Milestones 2–9 passing

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
printme-ai Ready Ready Preview Jul 30, 2026 5:07am

This branch was successfully deployed

1 active deployment
Preview 4f472009 Deployed Jul 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant