Skip to content
Tulos

Stripe payments

Connect Stripe Checkout and the webhook that marks orders paid.

Tulos uses Stripe Checkout. When a customer checks out, the server reads the prices from Sanity, creates a pending order and opens Stripe’s hosted payment page. After payment, Stripe calls the webhook at /api/webhook, which marks the order Paid and stores the invoice.

Tip

The browser only sends product IDs, quantities and the chosen address. Prices always come from Sanity on the server, so nobody can change what they pay.

1. API key

In the Stripe dashboard (test mode), copy the Secret key into STRIPE_SECRET_KEY.

2. Webhook, locally

Run the webhook forwarder in a second terminal and copy the whsec_… it prints into STRIPE_WEBHOOK_SECRET:

stripe listen --forward-to localhost:3000/api/webhook

Keep it running while you test.

3. Webhook, in production

In Developers → Webhooks → Add endpoint, use https://your-domain.com/api/webhook and these events:

  • checkout.session.completed
  • checkout.session.async_payment_succeeded
  • checkout.session.async_payment_failed

Use that endpoint’s signing secret as STRIPE_WEBHOOK_SECRET in production.

4. Test a payment

Pay with the test card 4242 4242 4242 4242, any future date and any CVC. The success page appears, and the order shows as Paid in My orders and in /admin/orders.

Unpaid orders

If a customer leaves Stripe without paying, the order stays pending. They can open it from My orders and press Pay now to start a new Checkout for the same order.