Checkout sessions
Create secure, hosted payment pages that handle one-time purchases and subscriptions using Checkout Sessions.
Quickstart
Choose the fastest way to create a checkout session based on your setup.
Using the dashboard (no-code)
Create and share a checkout session directly from the PaymentKit dashboard:
Configure session details
Configure the following session details:
- Customer (optional): Select an existing customer
- Expires In (Hours): Set expiration time (default: 24 hours)
- Success URL: URL to redirect customers after successful payment
- Return URL: URL to redirect customers if they cancel
- Line Items: Add one or more prices with quantities. Each line item consists of a price (linked to a product) and a quantity.
Using the API
Create a checkout session programmatically:
The response includes a CheckoutSession object with an id and secure_token. Use the secure_token to construct the hosted checkout page URL and redirect the customer to begin checkout.
How checkout sessions work
Customizing checkout
Pre-fill customer information
Link the checkout session to an existing customer:
Apply a promotion code
Apply a promotion code to the checkout session:
Or apply a coupon directly by ID:
Redirect URLs
Configure where customers go after checkout:
Include the checkout session ID to verify the result: https://yoursite.com/success?session_id={CHECKOUT_SESSION_ID}
Session expiration
Checkout sessions expire after 24 hours by default. You can configure a custom expiration time using expires_in_hours:
Attach custom fields
Attach custom fields for internal tracking:
Custom fields are included in webhooks and retrievable from the API when expand=custom_fields is specified.
Pass parameters to the subscription
Use params_for_sub to pass parameters to the subscription created by the checkout session. Currently supports custom_fields, which are validated against subscription custom field definitions (not checkout session ones).
After the checkout completes, these custom fields appear on the created subscription and are retrievable via the API with expand=custom_fields.
Configure processor route
Override the default processor route for card checkout:
Cascade pricing
Configure fallback pricing tiers for cascade pricing. If the primary tier fails, the system automatically tries the next tier:
Best practices
- Always verify payments using the API or webhooks.
- Use webhooks for fulfillment instead of redirects.
- Handle expired sessions by creating a new session when needed.
- Pre-fill customer details to reduce friction and improve conversion.