Skip to content

feat/e-commerce-stripe-v2#54

Merged
CarmenDou merged 17 commits into
mainfrom
feat/e-commerce-stripe-v2
Jun 5, 2026
Merged

feat/e-commerce-stripe-v2#54
CarmenDou merged 17 commits into
mainfrom
feat/e-commerce-stripe-v2

Conversation

@CarmenDou

@CarmenDou CarmenDou commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary by cubic

Add real Stripe Checkout via InsForge Payments, a wishlist, and an order status timeline with admin fulfillment. Checkout now redirects to Stripe, then back to a success page that polls and routes to the order; inventory is finalized via a payment trigger that uses greatest(0, ...) to surface oversells and avoid silent errors.

  • New Features

    • Stripe Checkout from the checkout form; creates a pending order, starts a session, redirects to Stripe, then /checkout/success polls until paid and redirects to the order. Finalization happens via a database trigger on payments.payment_history that decrements inventory with greatest(0, ...). Uses NEXT_PUBLIC_APP_URL for redirects and handles timeouts/errors.
    • Order timeline on the order page (placed, payment confirmed, preparing, shipped, delivered), with admin actions: mark shipped (optional tracking) and mark delivered.
    • Wishlist with optimistic heart toggle on cards and PDP, plus /account/wishlist.
    • Product and variant stripe_price_id support; missing-price errors are surfaced clearly. Parallelized data fetch and resilient wishlist lookups.
    • Updated docs for Stripe setup, promo-code caveat, and the order lifecycle.
  • Migration

    • Run the DB migration (adds order_status_events, wishlists, Stripe columns on products/variants and orders, RLS, admin RPCs, and a payments trigger that finalizes paid orders and safely decrements inventory).
    • Upgrade @insforge/sdk to ^1.3.1.
    • Configure InsForge Payments with your Stripe keys and seed products/prices; write stripe_price_id to matching products/product_variants rows.
    • Set NEXT_PUBLIC_APP_URL for production.

Written for commit 539206e. Summary will update on new commits.

Review in cubic

CarmenDou added 15 commits June 2, 2026 13:16

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 issues found across 22 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="e-commerce/lib/store-actions.ts">

<violation number="1" location="e-commerce/lib/store-actions.ts:140">
P1: The new checkout-success poll path only reads `orders.payment_status` and no longer finalizes paid sessions, so paid checkouts can remain unfinalized when the projection/webhook update is delayed or missed.</violation>
</file>

<file name="e-commerce/lib/store.ts">

<violation number="1" location="e-commerce/lib/store.ts:743">
P1: Stripe checkout session omits shipping/tax from the charged amount, so customers can be charged less than `orders.total_cents`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread e-commerce/app/page.tsx Outdated

export async function pollOrderPaymentAction(payload: { orderId: string }) {
const { viewer, accessToken } = await requireSession();
const result = await getOrderPaymentState({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The new checkout-success poll path only reads orders.payment_status and no longer finalizes paid sessions, so paid checkouts can remain unfinalized when the projection/webhook update is delayed or missed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At e-commerce/lib/store-actions.ts, line 140:

<comment>The new checkout-success poll path only reads `orders.payment_status` and no longer finalizes paid sessions, so paid checkouts can remain unfinalized when the projection/webhook update is delayed or missed.</comment>

<file context>
@@ -119,3 +134,38 @@ export async function setDefaultAddressAction(
+
+export async function pollOrderPaymentAction(payload: { orderId: string }) {
+  const { viewer, accessToken } = await requireSession();
+  const result = await getOrderPaymentState({
+    accessToken,
+    userId: viewer.id,
</file context>

Comment thread e-commerce/lib/store.ts

const { data: session, error: sessionError } = await insforge.payments.createCheckoutSession('test', {
mode: 'payment',
lineItems,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Stripe checkout session omits shipping/tax from the charged amount, so customers can be charged less than orders.total_cents.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At e-commerce/lib/store.ts, line 743:

<comment>Stripe checkout session omits shipping/tax from the charged amount, so customers can be charged less than `orders.total_cents`.</comment>

<file context>
@@ -603,6 +673,143 @@ export async function placeOrderForUser(args: {
+
+  const { data: session, error: sessionError } = await insforge.payments.createCheckoutSession('test', {
+    mode: 'payment',
+    lineItems,
+    successUrl: `${args.successOrigin}/checkout/success?order_id=${args.orderId}&session_id={CHECKOUT_SESSION_ID}`,
+    cancelUrl: `${args.successOrigin}/cart`,
</file context>

Comment thread e-commerce/migrations/db_init.sql Outdated
Comment thread e-commerce/migrations/db_init.sql
Comment thread e-commerce/app/products/page.tsx Outdated
Comment thread e-commerce/app/page.tsx Outdated
Comment thread e-commerce/app/account/wishlist/page.tsx
Comment thread e-commerce/components/wishlist-button.tsx
Comment thread e-commerce/migrations/db_init.sql Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="e-commerce/lib/store-actions.ts">

<violation number="1" location="e-commerce/lib/store-actions.ts:140">
P1: The new checkout-success poll path only reads `orders.payment_status` and no longer finalizes paid sessions, so paid checkouts can remain unfinalized when the projection/webhook update is delayed or missed.</violation>
</file>

<file name="e-commerce/lib/store.ts">

<violation number="1" location="e-commerce/lib/store.ts:743">
P1: Stripe checkout session omits shipping/tax from the charged amount, so customers can be charged less than `orders.total_cents`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread e-commerce/migrations/db_init.sql Outdated
Comment thread e-commerce/migrations/db_init.sql Outdated
… to surface oversell rather than silent skip

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - approved.

@CarmenDou
CarmenDou merged commit ebcd6d9 into main Jun 5, 2026
4 checks passed
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.

2 participants