Reservations Feature — Availability, Deposits, Google Calendar
Enable a modular reservations feature with business-hours availability, Stripe Checkout deposits, webhook confirmation, ICS attachments, and Google Calendar links.
Reservations (Demo Feature)
This modular feature showcases a complete reservation flow you can plug into your app:
- Business‑hours availability with buffers and conflict checks
- Soft holds until payment completes
- Stripe Checkout for deposits or full prepay
- Webhook confirmation to mark bookings confirmed
- Email confirmation via Resend with ICS calendar attachments
- One‑click “Add to Google Calendar” links (no OAuth required)
- i18n‑ready UI at
/:locale/reserveand/:locale/account/reservations
Core Concepts
- Services — title, duration, price/currency, deposit, buffers, cancellation window
- Availability — generated from business hours in a base time zone (configurable)
- Reservations —
pending→ Stripe payment → webhook →confirmed - Modularity — feature can be toggled off; routes return 404 when disabled
Setup
- Environment & Code Config
Add these to .env (see .env.example):
NEXT_PUBLIC_FEATURE_RESERVATIONS_ENABLED=true
STRIPE_PRIVATE_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
RESEND_API_KEY=...
EMAIL_FROM="Your App <no-reply@your-domain.com>"
NEXT_PUBLIC_WEB_URL="http://localhost:3000"Then adjust business hours, hold minutes, horizon, and base timezone in code at:
src/data/reservations.ts
- Database
Generate and apply the reservations tables (reservation_services, reservations):
pnpm drizzle-kit generate --config src/db/config.ts
pnpm drizzle-kit migrate --config src/db/config.ts- Webhooks (local)
stripe listen --forward-to localhost:3000/api/pay/webhook/stripe- Run
pnpm devVisit /en/reserve to try the flow. A demo service is auto‑seeded by default. Tweak hours/timezone in src/data/reservations.ts.
Usage
- Choose a service and date; select an available time
- Enter contact info → Stripe Checkout opens
- On success, you return to the calendar with a confirmation banner
- You receive an email with an ICS attachment and a Google Calendar link
- Review bookings at
/en/account/reservations
Customization
- Base timezone: edit
baseTimeZoneinsrc/data/reservations.ts(e.g.,Europe/Paris). Availability uses this tz; the UI displays in the user’s local tz. - Deposit vs full prepay: configure
deposit_amountandrequire_depositper service. - Buffers:
buffer_before_min,buffer_after_minto avoid back‑to‑back scheduling. - Cancellation: tune
cancellation_window_hoursand surface your policy in the UI/email. - Calendar: Google link builder needs no OAuth. For provider-side sync, add Google OAuth and create events via the Calendar API.
Credits-Based Tasks — Text to Video
Add usage-based monetization with a generic tasks table, a credit ledger, and a pluggable text-to-video generator. Learn the schema, APIs, config constants, and a minimal UI to ship paid AI features fast.
SaaS 101: What 'Software as a Service' Really Means
An introduction to the Software‑as‑a‑Service (SaaS) model — understanding what SaaS means, how it works, its key benefits, and why it's become a dominant way to deliver software in the cloud era.