Cancel-Page Churn Survey Widget for Stripe and Paddle
A free, open-source "Before you go, what made you cancel?" step for your cancel button. The customer picks a reason or writes a line, or skips, and the cancel continues. You get the answer as a callback, a DOM event or a JSON POST to your own endpoint. MIT licensed, about 4 KB gzipped, no dependencies, TypeScript types included.
Try it
These buttons act like a cancel button on your billing page. Nothing is cancelled and nothing is sent anywhere: the answer just shows below.
No answer yet.
Copy-paste: the fastest setup
Add data-cancel-reasons to your existing cancel link or button and load the script. When the customer clicks, the step opens. After they answer or skip, the answer is POSTed as JSON to your endpoint and the link continues as before.
<a href="/billing/cancel" data-cancel-reasons data-cancel-reasons-webhook="/api/cancel-reason">
Cancel subscription
</a>
<script src="https://cdn.jsdelivr.net/gh/nar-vardanyan/frank-mcp@ededde699aa793ec3a352aece7d582ad077775da/widgets/churn-interview/dist/cancel-reasons.min.js"></script>
This URL is pinned to a commit, so the file never changes under you. Other builds and versions.
What the customer sees, and what it never does
- A short dialog: eight common reasons, an optional comment box, "Send and continue cancelling" and "Skip and continue cancelling".
- Answering is optional. Skipping is always one click. Escape or the close button just closes the dialog, like not clicking cancel.
- Your callback and webhook get at most 1.5 seconds (you can change it) before the cancel continues anyway. If anything fails, the cancel continues.
- No save offers, no discounts, no extra confirmation screens. Add those yourself only if you want them.
Stripe
Customer Portal cancel flow
Your button posts to your backend, which creates a portal session with flow_data[type]=subscription_cancel and redirects. The widget sends the reason first. If you use this widget, turn off the portal's own cancellation reason question (features.subscription_cancel.cancellation_reason) so customers are not asked twice.
<form method="post" action="/billing/cancel">
<button id="cancel" type="submit">Cancel subscription</button>
</form>
<script src="https://cdn.jsdelivr.net/gh/nar-vardanyan/frank-mcp@ededde699aa793ec3a352aece7d582ad077775da/widgets/churn-interview/dist/cancel-reasons.min.js"></script>
<script>
CancelReasons.attach('#cancel', { webhookUrl: '/billing/cancel-reason' });
</script>
// Node + Express + the official stripe package. Secret key stays on the server.
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const FEEDBACK = new Set(['too_expensive', 'missing_features', 'switched_service', 'unused',
'too_complex', 'low_quality', 'customer_service', 'other']);
// 1. Store the answer. Take the subscription from the logged-in user, never from the browser.
app.post('/billing/cancel-reason', requireUser, express.json(), async (req, res) => {
const { reason, comment, skipped } = req.body || {};
await db.cancelReasons.insert({ userId: req.user.id, reason, comment, skipped, at: new Date() });
if (!skipped) {
await stripe.subscriptions.update(req.user.stripeSubscriptionId, {
cancellation_details: {
feedback: FEEDBACK.has(reason) ? reason : undefined,
comment: typeof comment === 'string' ? comment.slice(0, 500) : undefined,
},
});
}
res.sendStatus(204);
});
// 2. Send the customer to the Customer Portal cancel flow.
app.post('/billing/cancel', requireUser, async (req, res) => {
const session = await stripe.billingPortal.sessions.create({
customer: req.user.stripeCustomerId,
return_url: 'https://example.com/account',
flow_data: {
type: 'subscription_cancel',
subscription_cancel: { subscription: req.user.stripeSubscriptionId },
},
});
res.redirect(303, session.url);
});
The reason is sent before the customer reaches the portal, so it records intent. Confirm actual cancellations from your Stripe webhooks.
Your own cancel flow with the Stripe API
<button id="cancel" type="button">Cancel subscription</button>
<script type="module">
import { attach } from 'https://cdn.jsdelivr.net/gh/nar-vardanyan/frank-mcp@ededde699aa793ec3a352aece7d582ad077775da/widgets/churn-interview/dist/cancel-reasons.min.mjs';
attach('#cancel', {
onContinue: async (result) => {
await fetch('/api/subscription/cancel', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ reason: result.reason, comment: result.comment }),
});
location.href = '/account/cancelled';
},
});
</script>
// Server: cancel at period end with the reason attached.
await stripe.subscriptions.update(req.user.stripeSubscriptionId, {
cancel_at_period_end: true,
cancellation_details: { feedback: FEEDBACK.has(reason) ? reason : undefined, comment },
});
// Or cancel now: await stripe.subscriptions.cancel(id, { cancellation_details });
The default reason values (too_expensive, missing_features, switched_service, unused, too_complex, low_quality, customer_service, other) are the values Stripe accepts for cancellation_details.feedback. Validate them on your server. References: portal deep links, update a subscription, cancel a subscription.
Paddle Billing
Cancel from your backend with the Paddle API
<button id="cancel" type="button">Cancel subscription</button>
<script src="https://cdn.jsdelivr.net/gh/nar-vardanyan/frank-mcp@ededde699aa793ec3a352aece7d582ad077775da/widgets/churn-interview/dist/cancel-reasons.min.js"></script>
<script>
CancelReasons.attach('#cancel', {
onContinue: async function (result) {
await fetch('/api/subscription/cancel', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ reason: result.reason, comment: result.comment }),
});
location.href = '/account/cancelled';
},
});
</script>
// Node 18+, plain fetch. API key stays on the server.
const PADDLE_API = process.env.PADDLE_API_BASE || 'https://api.paddle.com'; // sandbox: https://sandbox-api.paddle.com
const headers = { Authorization: `Bearer ${process.env.PADDLE_API_KEY}`, 'Content-Type': 'application/json' };
app.post('/api/subscription/cancel', requireUser, express.json(), async (req, res) => {
const subId = req.user.paddleSubscriptionId; // from your database
const { reason, comment } = req.body || {};
// Cancel at the end of the billing period ('immediately' cancels now).
const r = await fetch(`${PADDLE_API}/subscriptions/${subId}/cancel`, {
method: 'POST', headers, body: JSON.stringify({ effective_from: 'next_billing_period' }),
});
if (!r.ok) return res.status(502).send('Cancel failed');
// Optional: keep the answer on the subscription. Send existing custom_data keys too.
const current = await fetch(`${PADDLE_API}/subscriptions/${subId}`, { headers }).then((x) => x.json());
await fetch(`${PADDLE_API}/subscriptions/${subId}`, {
method: 'PATCH', headers,
body: JSON.stringify({ custom_data: { ...(current.data && current.data.custom_data),
cancel_reason: reason || null, cancel_comment: comment ? String(comment).slice(0, 500) : null } }),
});
res.sendStatus(204);
});
With next_billing_period, Paddle schedules the cancel and the subscription stays active until the period ends. References: cancel a subscription, update a subscription.
Paddle's hosted cancel page
<!-- management_urls.cancel comes from the Paddle subscription entity -->
<a id="cancel" href="PADDLE_MANAGEMENT_CANCEL_URL">Cancel subscription</a>
<script src="https://cdn.jsdelivr.net/gh/nar-vardanyan/frank-mcp@ededde699aa793ec3a352aece7d582ad077775da/widgets/churn-interview/dist/cancel-reasons.min.js"></script>
<script>CancelReasons.attach('#cancel', { webhookUrl: '/api/cancel-reason' });</script>
Paddle Retain
Paddle Retain cancellation flows (Paddle.Retain.initCancellationFlow()) already ask for a cancellation reason. Use either Retain's flow or this widget for that step, not both.
The answer you get
{
"reason": "too_expensive",
"reasonLabel": "It's too expensive",
"comment": "Budget cut this quarter",
"skipped": false,
"timestamp": "2026-11-27T10:00:00.000Z",
"page": "https://app.example.com/settings/billing",
"metadata": { "plan": "pro" }
}
Read it from onSubmit(result), from the cancelreasons:submit event, or from the JSON POST to webhookUrl. Prefer a same-origin webhook URL, and never put secrets in the browser. Every option is in the README.
Optional: invite a 5-minute voice chat
Off by default. Set interviewLink to show one line under the form, "Want to tell us more in a 5-minute voice chat?", that opens your own interview link in a new tab. It never replaces or delays the cancel.
attach('#cancel', {
interviewLink: { url: 'https://your-interview-link.example' }, // off unless you set it
});
Frank is an AI user researcher that runs short voice interviews. Put your Frank interview link in interviewLink and churned customers can tell you more in their own words.
FAQ
Does it stop people from cancelling?
No. Answering is optional, "Skip and continue cancelling" is always one click, and the cancel continues even if your callback or webhook is slow or fails. If the dialog cannot render, the cancel continues straight away. There are no save offers or extra confirmation screens.
Do I need a Stripe or Paddle key in the browser?
No. The widget never talks to Stripe or Paddle. It hands the answer to your code or your own endpoint, and your backend calls the Stripe or Paddle API with keys that stay on the server.
Where do the answers go?
Wherever you send them: an onSubmit callback, a cancelreasons:submit DOM event, or a JSON POST to a webhook URL you choose. Nothing is sent to us.
Do the reasons match Stripe?
Yes. The default reason values are the values Stripe accepts for cancellation_details.feedback, so a Stripe backend can pass them through. You can replace them with your own reasons and labels.
I use Paddle Retain. Do I need this?
Paddle Retain cancellation flows already ask for a cancellation reason. Use either Retain's flow or this widget for that step, not both, so customers are not asked twice.
Is it accessible?
It uses a native modal dialog with a labelled radio group, works with the keyboard alone, returns focus to your button, and is checked with axe-core in headless Chrome.
What does it cost?
Nothing. It is MIT licensed, about 4 KB gzipped, with no dependencies.
Related tools and guides
- Customer interview guide generator: 8 questions for churn, win-loss, discovery or pricing
- Mom Test question checker: flag leading, hypothetical and yes/no questions
- JTBD switch interview question generator: timeline questions tagged push, pull, anxiety and habit
- Cancellation reason sorter: sort churn survey answers into themes, with interview follow-ups
- How many customer interviews planner: a guidance range per segment, with cited studies
- Customer interview summary template: turn interview notes into a one-page summary with quotes and next steps
- Customer interview question bank: filter open questions by goal and stage, pick your own guide
- Churn interviews
- How to find out why customers churn