createStripeCheckoutSession
Creates a Stripe Checkout session for purchasing event tickets. This action handles the creation of a payment session with Stripe Connect, applying a 1% application fee and setting up proper expiration times.Authentication
This action requires authentication via Clerk. The user must be authenticated before calling this function.Function Signature
Parameters
The unique identifier of the event for which to create a checkout session
Return Value
The Stripe Checkout session ID
The URL to redirect the user to for completing the checkout
Metadata Structure
The checkout session includes metadata for tracking and webhook processing:Application Fee
The action automatically calculates and applies a 1% application fee on top of the ticket price:Session Expiration
The checkout session expires after 30 minutes (the minimum allowed by Stripe). This matches the ticket offer expiration time defined inDURATIONS.TICKET_OFFER:
Workflow
- Authentication Check: Verifies the user is authenticated via Clerk
- Event Validation: Fetches event details from Convex database
- Queue Position Check: Verifies user has a valid “offered” status in the waiting list
- Stripe Connect ID: Retrieves the event owner’s Stripe Connect account ID
- Offer Expiration: Validates the ticket offer has an expiration date
- Session Creation: Creates a Stripe Checkout session with:
- Payment method: Card only
- Currency: GBP
- Line items with event details and pricing
- 1% application fee
- 30-minute expiration
- Success and cancel URLs
- Metadata for tracking
Stripe API Usage
This action uses the Stripe Checkout Sessions API with Stripe Connect:Error Handling
The action throws errors for the following conditions:- User not authenticated
- Event not found
- No valid ticket offer found (must have “offered” status)
- Stripe Connect ID not found for event owner
- Ticket offer has no expiration date
- Stripe API errors
Example Usage
Related Actions
- Stripe Connect Actions - Managing Stripe Connect accounts
- Refunds - Processing ticket refunds