Skip to main content
POST
/
api
/
create-checkout-session
curl -X POST https://your-domain.com/api/create-checkout-session \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123abc",
    "planId": "weekly"
  }'
{
  "sessionId": "cs_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0"
}
Creates a Stripe Checkout session for purchasing access to the LSAT Training Platform. Supports both recurring weekly subscriptions and one-time lifetime access payments.

Request Body

userId
string
required
The unique identifier of the user purchasing a subscription. This is used as the client_reference_id in the Stripe session.
planId
string
required
The subscription plan type. Must be either "weekly" for recurring subscriptions or "one-time" for lifetime access.
  • weekly - Creates a subscription mode checkout with recurring billing
  • one-time - Creates a one-time payment mode checkout

Response

sessionId
string
The Stripe Checkout Session ID. Use this to redirect users to the Stripe checkout page via stripe.redirectToCheckout({ sessionId }).

Subscription Flow

The checkout session is configured with:
  • Payment Methods: Card payments only
  • Mode: subscription for weekly plans, payment for one-time purchases
  • Success URL: Redirects to /subscription/success?session_id={CHECKOUT_SESSION_ID}
  • Cancel URL: Redirects to /subscription?canceled=true
  • Metadata: Stores userId and planId for webhook processing

Price IDs

The API automatically selects the correct Stripe Price ID based on the plan:
  • Weekly subscriptions use STRIPE_WEEKLY_PRICE_ID environment variable
  • One-time purchases use STRIPE_ONE_TIME_PRICE_ID environment variable

Error Responses

error
string
Error message describing what went wrong.

400 Bad Request

Returned when required parameters are missing.
{
  "error": "Missing userId or planId"
}

500 Internal Server Error

Returned when Stripe API fails or server error occurs.
{
  "error": "An error occurred"
}
curl -X POST https://your-domain.com/api/create-checkout-session \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user_123abc",
    "planId": "weekly"
  }'
{
  "sessionId": "cs_test_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0"
}

Integration Notes

  • Requires STRIPE_SECRET_KEY environment variable
  • Uses Stripe API version 2023-10-16
  • Session metadata includes both userId and planId for webhook processing
  • The client_reference_id is set to the userId for easy user identification in webhooks
  • Completed purchases trigger the checkout.session.completed webhook event

Build docs developers (and LLMs) love