POST /api/stripe/create-checkout
Create a Stripe Checkout session for one-time payments or subscriptions. This endpoint is triggered by theButtonCheckout component.
Request
Stripe Price ID for the product or subscription plan.
URL to redirect to after successful payment. Must be a valid URI.
URL to redirect to if user cancels the checkout. Must be a valid URI.
Checkout mode. Either
payment for one-time payments or subscription for recurring subscriptions.Response
The Stripe Checkout session URL to redirect the user to.
Error message returned when request fails.
Code Examples
Request Validation
Validation Code
Validation Code
packages/landing/app/api/stripe/create-checkout/route.ts
Error Handling
Validation ErrorReturned when:
priceIdis missing:"Price ID is required"successUrlorcancelUrlis missing:"Success and cancel URLs are required"modeis missing:"Mode is required (either 'payment' for one-time payments or 'subscription' for recurring subscription)"
Internal Server ErrorReturned when Stripe API call fails or unexpected server error occurs.
Success Response
Status Code:200 OK
POST /api/stripe/create-portal
Create a Stripe Customer Portal session for managing billing and subscriptions. This endpoint is triggered by theButtonAccount component and requires an authenticated user.
Authentication
This endpoint requires a valid Supabase user session. Users must be signed in with a session cookie.Request
URL to return to after the user completes their session in the billing portal. Must be a valid URI.
Response
The Stripe Customer Portal URL to redirect the user to.
Error message returned when request fails.
Code Examples
Request Validation
Validation Code
Validation Code
packages/landing/app/api/stripe/create-portal/route.ts
Error Handling
Validation ErrorReturned when:
returnUrlis missing:"Return URL is required"- User has no Stripe customer account:
"You don't have a billing account yet. Make a purchase first."
UnauthorizedReturned when user is not authenticated.
Internal Server ErrorReturned when Stripe API call fails or unexpected server error occurs.
Success Response
Status Code:200 OK
Implementation Notes
- The endpoint includes a TODO for looking up the Stripe customer ID from the database
- Currently uses a placeholder
customerIdthat is alwaysnull - Users must make a purchase first to create a Stripe customer account before accessing the portal
- All authentication is handled via Supabase session cookies