Creem provides flexible options for managing subscription cancellations and processing refunds. You can cancel subscriptions immediately or at the end of the billing period, and process full or partial refunds through the dashboard or API.
Canceling Subscriptions
Cancellation Options
When canceling a subscription, you have two options:
Cancel Immediately - Subscription ends right away and no further charges occur
Cancel at Period End - Customer retains access until the end of the current billing period
Programmatic Cancellation
Cancel subscriptions programmatically using the API:
TypeScript SDK
Better Auth
REST API
import { createCreem } from "creem_io" ;
const creem = createCreem ({
apiKey: process . env . CREEM_API_KEY ! ,
testMode: process . env . NODE_ENV !== "production" ,
});
// Cancel subscription
const canceled = await creem . subscriptions . cancel ({
subscriptionId: "sub_YOUR_SUBSCRIPTION_ID" ,
});
console . log ( "Subscription canceled:" , canceled );
Customer Self-Service Cancellation
Customers can cancel their own subscriptions through the Customer Portal:
Next.js
TypeScript SDK
Better Auth
import { CreemPortal } from "@creem_io/nextjs" ;
export function ManageSubscriptionButton ({ customerId } : { customerId : string }) {
return (
< CreemPortal customerId = { customerId } >
< button > Manage Subscription </ button >
</ CreemPortal >
);
}
Customer Portal Learn more about enabling self-service subscription management.
Processing Refunds
Dashboard Refunds
The easiest way to process refunds is through the Creem Dashboard:
Navigate to Transactions or Subscriptions
Find the transaction you want to refund
Click on the transaction details
Select Refund
Choose full or partial refund amount
Confirm the refund
Refund Types
Full Refund Refund the entire transaction amount to the customer
Partial Refund Refund a specific amount (less than the total transaction)
Refund Processing
When you process a refund:
Immediate processing - Refunds are processed immediately
Customer notification - Customer receives an email notification
Webhook event - A refund.created webhook is sent
5-10 business days - Funds typically appear in customer’s account within 5-10 business days
Refund availability depends on the payment method and may vary by region. Credit card refunds are generally processed within 5-10 business days.
Cancellation Policies
Best Practices
Clear Communication
Set clear expectations about cancellation policies
Communicate what happens to customer data after cancellation
Explain billing cycle and refund policies upfront
Retention Strategies
Offer to pause subscription instead of canceling
Provide downgrade options to lower-tier plans
Ask for feedback to improve your service
Grace Periods
Consider offering a grace period for failed payments
Allow customers to reactivate within a certain timeframe
Preserve customer data for a reasonable period
Cancellation Flow Example
import { createCreem } from "creem_io" ;
const creem = createCreem ({
apiKey: process . env . CREEM_API_KEY ! ,
});
async function handleCancellation ( subscriptionId : string , reason ?: string ) {
try {
// Log cancellation reason for analytics
console . log ( `Canceling subscription: ${ subscriptionId } ` , { reason });
// Cancel the subscription
const canceled = await creem . subscriptions . cancel ({
subscriptionId ,
});
// Send cancellation email to customer
await sendCancellationEmail ( canceled . customer . email );
// Update internal database
await db . subscription . update ({
where: { id: subscriptionId },
data: { status: "canceled" , canceledAt: new Date () },
});
return { success: true , subscription: canceled };
} catch ( error ) {
console . error ( "Cancellation failed:" , error );
throw error ;
}
}
Handling Cancellation Events
Use webhooks to automatically respond to cancellation events:
// app/api/webhook/creem/route.ts
import { Webhook } from "@creem_io/nextjs" ;
export const POST = Webhook ({
webhookSecret: process . env . CREEM_WEBHOOK_SECRET ! ,
onSubscriptionCanceled : async ({ subscription , customer }) => {
console . log ( `Subscription ${ subscription . id } canceled` );
// Revoke access in your database
await revokeAccess ( customer . email );
// Send cancellation confirmation email
await sendEmail ({
to: customer . email ,
subject: "Subscription Canceled" ,
body: "Your subscription has been canceled..." ,
});
},
});
Webhooks Learn more about handling subscription events with webhooks.
Failed Payments
Payment Retry Logic
When a subscription payment fails:
Automatic retries - Creem automatically retries failed payments
Status changes - Subscription moves to “unpaid” status
Customer notification - Customer receives email to update payment method
Grace period - Subscription remains active during retry period
Final failure - After all retries fail, subscription may be canceled
Handling Failed Payments
// Handle failed payment webhook
await creem . webhooks . handleEvents (
request . body ,
request . headers [ "creem-signature" ],
{
onSubscriptionPastDue : async ( data ) => {
const { subscription , customer } = data ;
// Notify customer to update payment method
await sendPaymentFailedEmail ( customer . email , {
portalLink: `https://yoursite.com/portal?customer= ${ customer . id } ` ,
});
// Optionally restrict access or show warning
await showPaymentWarning ( customer . email );
},
onSubscriptionCanceled : async ( data ) => {
// After all retries failed
await revokeAccess ( data . customer . email );
await sendSubscriptionEndedEmail ( data . customer . email );
},
}
);
Next Steps