Migrate checkout to Stripe

dev-box · ~/src/lumen-shop

waiting

Claude Code · claude-opus-4.6

Migrate checkout from the mock cart to Stripe Payment Intents. Keep the existing orders table — just swap the charge path.

I'll inspect the current checkout flow and any Stripe env usage first, then replace createMockCharge with Payment Intents without touching the order schema.

Readsrc/app/checkout/page.tsx
export async function CheckoutForm({ cart }: Props) {
  const order = await createOrder(cart)
  const charge = await createMockCharge(order.total)
  return <Confirm clientSecret={charge.id} />
}
Readsrc/lib/orders.ts
export async function createOrder(cart: Cart) {
  return db.orders.insert({ total: cart.total, status: "pending" })
}

Checkout currently calls createMockCharge. I'll add a Stripe client, create a PaymentIntent for order.total, and thread clientSecret into the existing confirm step.

Writesrc/lib/stripe.ts
+ import Stripe from "stripe"
+
+ export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)
+
+ export async function createPaymentIntent(amount: number) {
+ return stripe.paymentIntents.create({
+ amount,
+ currency: "usd",
+ automatic_payment_methods: { enabled: true },
+ })
+ }
Editsrc/app/checkout/page.tsx
const order = await createOrder(cart)
- const charge = await createMockCharge(order.total)
- return <Confirm clientSecret={charge.id} />
+ const intent = await createPaymentIntent(order.total)
+ return <Confirm clientSecret={intent.client_secret!} />

Edits are in. I need to install the Stripe SDK on the host before the typecheck will pass — waiting on your approval for the install.

Needs approval

9h ago

npm install stripe @stripe/stripe-js

Installs the Stripe Node SDK and browser elements into ~/src/lumen-shop. Writes package.json and lockfile.

bash·Migrate checkout to Stripe