Skip to main content

Creating a Checkout Session

Learn how to programmatically create checkout sessions for your products using Creem’s APIs and SDKs.

Video Tutorial

What is a Checkout Session?

A checkout session is a dynamically generated payment page that gives you programmatic control over the payment flow. Unlike static payment links, checkout sessions allow you to:
  • Pass custom tracking IDs for each payment
  • Pre-fill customer information
  • Set dynamic success URLs based on your app’s context
  • Apply discount codes programmatically
  • Add metadata for internal tracking

Prerequisites

Before you begin, make sure you have:
  • A Creem account with an API key
  • At least one product created in your dashboard
  • Your development environment set up
Find your product ID by going to the Products tab, clicking on a product, and selecting “Copy ID” from the options menu.

Quick Start

Choose your preferred integration method:

Next.js

Use the Next.js adapter for seamless integration

TypeScript SDK

Full type-safety for any JavaScript framework

Better Auth

Integrate with authentication and user management

REST API

Use the REST API from any language

Common Use Cases

1. Pre-fill Customer Email

Ensure users complete payment with their registered email:
const checkout = await creem.checkouts.create({
  productId: 'prod_YOUR_PRODUCT_ID',
  customer: {
    email: 'user@example.com',
  },
});

2. Track Payments with Custom IDs

Associate payments with your internal system:
const checkout = await creem.checkouts.create({
  productId: 'prod_YOUR_PRODUCT_ID',
  requestId: 'order_12345',
  metadata: {
    userId: 'internal_user_id',
    source: 'marketing_campaign',
  },
});

3. Apply Discount Codes

Pre-fill discount codes for special offers:
const checkout = await creem.checkouts.create({
  productId: 'prod_YOUR_PRODUCT_ID',
  discountCode: 'LAUNCH50',
});

4. Seat-Based Billing

Charge for multiple units or seats:
const checkout = await creem.checkouts.create({
  productId: 'prod_YOUR_PRODUCT_ID',
  units: 5, // Charge for 5 seats
});

Next Steps

Checkout API Documentation

View the complete Checkout API reference

Webhooks

Set up webhooks to receive real-time payment notifications

Test Your Integration

Learn how to test without processing real payments

Checkout Customization

Brand your checkout with custom colors and logos

Need Help?

Having trouble? Check out our complete Checkout API documentation or contact us