Skip to main content

Create Checkout Session

Initiates a Stripe Checkout session for plan selection. Returns a URL to redirect the user to Stripe.
POST /api/billing/checkout-session

Request Body

{
  "plan": "pro",
  "cycle": "monthly"
}
FieldTypeDescription
planstringbasic, pro, or enterprise
cyclestringmonthly or annual

Response

{
  "url": "https://checkout.stripe.com/..."
}
Redirect the user to url to complete payment.

Open Billing Portal

Returns a Stripe Customer Portal URL where the user can manage their subscription, update payment methods, and download invoices.
POST /api/billing/portal

Response

{
  "url": "https://billing.stripe.com/..."
}

Stripe Webhook

Receives Stripe webhook events. This endpoint must be configured as the webhook destination in the Stripe dashboard.
POST /api/billing/webhook
This endpoint verifies the Stripe-Signature header against your STRIPE_WEBHOOK_SECRET. Do not call this endpoint directly — it is for Stripe’s servers only.

Handled Events

EventAction
checkout.session.completedActivates the subscription
invoice.payment_succeededRenews the subscription period
invoice.payment_failedTriggers a payment failure notification
customer.subscription.deletedMarks the subscription as canceled