Understanding Subscriptions
A subscription represents a recurring payment agreement between you and your customer. Subscriptions automatically handle billing cycles, payment retries, and customer management. The diagram below shows how subscription access is managed based on different states:
Subscription Status
A subscription can be in different states throughout its lifecycle:- Active: The subscription is current and payments are being processed normally.
- Canceled: The subscription has been terminated and will not renew or bill again.
- Unpaid: Payment for the subscription has failed or is overdue; access may be restricted until payment is made.
- Paused: The subscription is temporarily paused (no charges are processed and billing is on hold).
- Trialing: The subscription is in a trial period before the first payment is collected.
- Scheduled Cancel: The subscription is scheduled to cancel at the end of the current billing period but is still active until then.
Billing Cycles
Subscriptions operate on billing cycles that determine when payments are collected:- Monthly billing - Charged every month
- 3 month billing - Charged every 3 months
- 6 month billing - Charged every 6 months
- Yearly billing - Charged annually
Creating a Subscription
To create a subscription:- Create a subscription product in your Creem dashboard (set billing type to “recurring”)
- Generate a checkout session for the subscription
- Direct your customer to the checkout URL
- Next.js
- TypeScript SDK
- Better Auth
- REST API
Handling Successful Subscriptions
After a successful subscription creation, users are redirected to yoursuccess_url with subscription details as query parameters:
| Query parameter | Description |
|---|---|
checkout_id | The ID of the checkout session created for this subscription. |
subscription_id | The ID of the subscription created. |
customer_id | The customer ID associated with this subscription. |
product_id | The product ID that the subscription is for. |
request_id | Optional. The request/reference ID you provided when creating this checkout. |
signature | All previous parameters signed by Creem using your API-key, verifiable by you. |
Managing Subscription Access
Creem makes it incredibly simple to grant and revoke access based on subscription status. Instead of manually handling multiple webhook events, you can use the high-levelonGrantAccess and onRevokeAccess callbacks that automatically fire at the right times in your subscription lifecycle.
How It Works
onGrantAccess- Automatically called when a customer should have access (when subscription isactive,trialing, orpaid)onRevokeAccess- Automatically called when a customer should lose access (when subscription ispausedorexpired)
- Next.js
- TypeScript SDK
- Better Auth
- Manual Webhook
Key Features
Free Trials
Learn how to set up trial periods for your subscriptions.
Seat-Based Billing
Implement per-seat pricing for team-based products.
Customer Portal
Enable self-service subscription management.
Discount Codes
Create discount codes for subscriptions
Managing Subscriptions
Learn how to update, upgrade, and manage active subscriptions
Cancellations & Refunds
Handle subscription cancellations and process refunds