Prompt
calendar booking API with payments
Latest observation
Oct 16, 2026
OpenAI APIWeb search: off
Here’s a solid blueprint for a calendar booking API with payments.
Core features
- Create/update/delete availability
- Search open time slots
- Create bookings
- Hold/reserve slot temporarily while payment is processed
- Confirm booking after successful payment
- Cancel/refund booking
- Send notifications (email/SMS/webhooks)
Recommended flow
- Client requests available slots
- Client selects slot and starts checkout
- API creates a temporary hold on the slot with an expiry window
- Payment is authorized/captured
- API confirms booking
- Booking is persisted and calendar is blocked
- Failure path: if payment fails or hold expires, slot is released
Suggested entities
- User
- Provider (host/service owner)
- Service (e.g. haircut, consultation)
- AvailabilityRule
- Slot
- Booking
- Payment
- Transaction/Hold
Important booking states
availableheldpending_paymentconfirmedcancelledexpiredrefunded
Example API endpoints
Availability
GET /providers/{id}/availabilityPOST /providers/{id}/availability-rulesPOST /slots/search
Booking
POST /bookingsGET /bookings/{id}POST /bookings/{id}/cancelPOST /bookings/{id}/confirm
Payments
POST /payments/intentPOST /payments/webhookPOST /payments/{id}/refund
Example booking creation request
POST /bookings
{
"provider_id": "prov_123",
"service_id": "svc_456",
"start_time": "2026-10-20T10:00:00Z",
"end_time": "2026-10-20T10:30:00Z",
"customer_id": "cus_789",
"payment_method_id": "pm_abc"
}
Example response
{
"booking_id": "bk_001",
"status": "pending_payment",
"hold_expires_at": "2026-10-20T09:10:00Z",
"payment_intent_id": "pi_123"
}
Payment integration options
- Stripe: easiest for payment intents + webhooks
- PayPal: alternative
- Square: good for small business/location-based bookings
Key implementation concerns
- Avoid double booking: use DB transactions/row locks or atomic slot holds
- Idempotency: payment and booking creation should accept idempotency keys
- Webhook reliability: confirm payment status via provider webhooks
- Time zones: store in UTC, convert for display
- Holds expiration: background job to release expired holds
- Cancellation/refunds: apply policy rules based on timing
Minimal database design
bookings
- id
- provider_id
- service_id
- customer_id
- start_time
- end_time
- status
- total_amount
- currency
- payment_id
- created_at
- updated_at
payments
- id
- booking_id
- provider
- provider_payment_id
- amount
- currency
- status
- created_at
- updated_at
availability_rules
- id
- provider_id
- day_of_week
- start_time
- end_time
- slot_duration
- buffer_minutes
Best practice architecture
- API service for booking operations
- Payment service or integration layer
- Worker queue for hold expiry and webhook processing
- Calendar sync module if integrating Google Calendar / Outlook
- Notification service for confirmations/reminders
If you want, I can also provide:
- a REST API spec
- a PostgreSQL schema
- a Node.js/Express or FastAPI implementation
- a Stripe-based payment flow