Creem
Accept payments with Creem as merchant of record. Use this skill when the project needs to integrate Creem for SaaS subscriptions, one-time payments, checkout sessions, global tax compliance, or subscription management. Covers the Creem SDK, checkout sessions, subscription lifecycle, webhooks, and billing portal.
You are a payments specialist who integrates Creem into projects. Creem is a merchant of record platform for SaaS and digital products that handles payments, global tax compliance, invoicing, and subscription management. ## Key Points - Pass `referenceId` in metadata to link Creem records to your users - Store Creem customer IDs and subscription IDs in your database - Handle `subscription.past_due` with a grace period before restricting access - Use test mode keys (`creem_test_*`) for development and testing - Process all webhook events — don't just handle the happy path - Send email notifications on subscription state changes - Granting access on checkout redirect without webhook verification - Not storing Creem customer/subscription IDs - Ignoring `past_due` events — users lose access without warning - Using production keys in development - Not handling cancellation gracefully — honor the remaining paid period ## Quick Example ```bash npm install creem ``` ```typescript const subscription = await creem.subscriptions.get(subscriptionId); console.log(subscription.status); // active, past_due, canceled, etc. ```
skilldb get payment-services-skills/creemFull skill: 139 linesCreem Payment Integration
You are a payments specialist who integrates Creem into projects. Creem is a merchant of record platform for SaaS and digital products that handles payments, global tax compliance, invoicing, and subscription management.
Core Philosophy
Merchant of record for SaaS
Creem handles the legal and financial complexity of selling globally — tax collection, compliance, invoicing, and payouts. You focus on building your product while Creem is the legal seller.
Products configured in dashboard
Products and pricing are set up in the Creem dashboard. Your code references product IDs and creates checkout sessions. This keeps pricing logic out of your codebase.
Webhook-driven state management
All subscription state changes — activation, payment, cancellation, expiry — arrive via webhooks. Your database stays in sync by processing these events.
Setup
Install
npm install creem
Initialize
import { Creem } from 'creem';
const creem = new Creem({
apiKey: process.env.CREEM_API_KEY,
serverIdx: process.env.CREEM_API_KEY?.startsWith('creem_test_') ? 1 : 0,
});
Key Techniques
Create checkout session
const checkout = await creem.checkouts.create({
productId: process.env.CREEM_PRO_PRODUCT_ID,
successUrl: 'https://yourdomain.com/success',
metadata: {
referenceId: userId,
plan: 'pro',
},
});
// Redirect user to checkout.checkoutUrl
Subscription lookup
const subscription = await creem.subscriptions.get(subscriptionId);
console.log(subscription.status); // active, past_due, canceled, etc.
Customer management
const customer = await creem.customers.get(customerId);
console.log(customer.email, customer.subscriptions);
Webhook Processing
| Event | Action |
|---|---|
checkout.completed | Grant access |
subscription.active | Confirm subscription active |
subscription.paid | Renew access, send receipt |
subscription.trialing | Grant trial access |
subscription.past_due | Warn user, retry in progress |
subscription.paused | Restrict access temporarily |
subscription.canceled | Revoke access |
subscription.expired | Revoke access |
export async function POST(req: Request) {
const body = await req.text();
const event = JSON.parse(body);
const eventType = event.eventType;
const metadata = event.object?.metadata || {};
const userId = metadata.referenceId;
const customerEmail = event.object?.customer?.email;
const GRANT_EVENTS = [
'checkout.completed', 'subscription.active',
'subscription.paid', 'subscription.trialing',
];
const REVOKE_EVENTS = [
'subscription.expired', 'subscription.paused',
'subscription.canceled',
];
if (GRANT_EVENTS.includes(eventType)) {
await grantAccess(userId, metadata.plan || 'pro');
if (eventType === 'subscription.trialing') {
await sendTrialStartedEmail(customerEmail);
}
} else if (REVOKE_EVENTS.includes(eventType)) {
await revokeAccess(userId);
await sendCancellationEmail(customerEmail);
} else if (eventType === 'subscription.past_due') {
await sendPaymentFailedEmail(customerEmail);
}
return new Response(JSON.stringify({ received: true }));
}
Best Practices
- Pass
referenceIdin metadata to link Creem records to your users - Store Creem customer IDs and subscription IDs in your database
- Handle
subscription.past_duewith a grace period before restricting access - Use test mode keys (
creem_test_*) for development and testing - Process all webhook events — don't just handle the happy path
- Send email notifications on subscription state changes
Anti-Patterns
- Granting access on checkout redirect without webhook verification
- Not storing Creem customer/subscription IDs
- Ignoring
past_dueevents — users lose access without warning - Using production keys in development
- Not handling cancellation gracefully — honor the remaining paid period
Install this skill directly: skilldb add payment-services-skills
Related Skills
Klarna
Accept payments with Klarna. Use this skill when the project needs to integrate Klarna for buy-now-pay-later, installment plans, pay-in-30-days, or direct payments. Covers Klarna Payments API, Klarna Checkout, hosted payment page, order management, webhooks, and settlement.
Lemonsqueezy
Accept payments with Lemon Squeezy as merchant of record. Use this skill when the project needs to integrate Lemon Squeezy for SaaS subscriptions, digital product sales, license key management, checkout overlay, tax compliance, or affiliate programs. Covers the Lemon Squeezy API, checkout, subscriptions, license keys, webhooks, and Lemon.js.
Mollie
Accept payments with Mollie. Use this skill when the project needs to integrate Mollie for European payments, iDEAL, Bancontact, SEPA, Klarna, subscriptions, payment links, or multi-currency checkout. Covers the Mollie API, payments, subscriptions, mandates, refunds, and webhooks. Popular in Netherlands, Belgium, Germany, and across Europe.
Paddle
Accept payments with Paddle as merchant of record. Use this skill when the project needs to integrate Paddle for subscription billing, one-time payments, checkout overlay, tax compliance, invoicing, or global payment processing where Paddle handles tax, compliance, and payouts. Covers Paddle Billing API, checkout, subscriptions, transactions, webhooks, and Paddle.js.
Paypal
Accept payments with PayPal. Use this skill when the project needs to integrate PayPal for checkout, subscriptions, one-time payments, PayPal buttons, venmo, invoicing, payouts, or PayPal REST API. Covers the PayPal JavaScript SDK, REST API v2, Orders, Subscriptions, Webhooks, and Smart Payment Buttons.
Razorpay
Accept payments with Razorpay. Use this skill when the project needs to integrate Razorpay for payments in India and international markets, UPI, subscriptions, payment links, invoicing, route (split payments), or Razorpay Checkout. Covers the Razorpay API, Checkout.js, orders, subscriptions, webhooks, and UPI.