---
title: "Handle cancellations and win people back"
description: "Ask one optional question when someone cancels, make one offer that fits the answer (a pause, a smaller plan or a discount), honor the cancellation without a maze, and write again at 7 and 30 days to people who opted in."
canonical_url: "https://nuxt-backend.dev/docs/build/growth/engage/cancel-flow"
---
# Handle cancellations and win people back

> Ask one optional question when someone cancels, make one offer that fits the answer (a pause, a smaller plan or a discount), honor the cancellation without a maze, and write again at 7 and 30 days to people who opted in.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [API reference](https://nuxt-backend.dev/docs/reference/api/use-billing)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/lifecycle.ts)

Keep the subscribers you can keep, and let the rest go in one step. You get `<CancelFlow>`: cancelling takes one step, and where you turn save offers on, one optional step comes first, a question and at most one offer that fits the answer. After the plan ends, a win-back email can follow at 7 and 30 days, to people who opted in.

**What Polar does natively** (checked on 2026-10-25, [Managing subscriptions](https://polar.sh/docs/features/subscriptions/manage)):

- It cancels at the period's end, and the customer keeps the plan until then.
- It records one of eight cancellation reasons with a comment, and counts cancellations per reason in its metrics.
- It pauses a plan at the period's end, and resumes it on a date or by hand.
- Its customer portal always offers "cancel at period end", whatever your portal settings say.

**What the package adds:** the in-app flow, save offers chosen by reason, the rules that keep them lawful, and the events the win-back emails start from. Polar's metrics already count cancellations per reason.

## Turn on save offers

Without save offers, cancelling takes one step. `useBilling().cancel({ reason })` cancels at the period's end ([Cancelling takes one step](https://nuxt-backend.dev/docs/build/billing/subscriptions#cancelling-takes-one-step)). Save offers are opt-in. Declare one per reason on `setupBilling`:

```ts [backend/billing.ts]
import { setupBilling } from 'nuxt-backend/billing'
import { components } from './_generated/api'
import { audit } from './audit'
import { catalog } from './billing.generated'
import { email } from './email'

export const billing = setupBilling(components, {
  catalog,
  email,
  audit,
  lifecycle: {
    saveOffers: {
      too_expensive: { discount: 'stay30' },
      unused: { pause: { months: 2 } },
      missing_features: { downgrade: 'starter' },
    },
  },
})
```

Each key is one of Polar's cancellation reasons: `too_expensive`, `missing_features`, `switched_service`, `unused`, `customer_service`, `low_quality`, `too_complex` or `other`. Each value is one offer:

<table>
<thead>
  <tr>
    <th>
      Offer
    </th>
    
    <th>
      What the customer gets
    </th>
    
    <th>
      What it needs
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        { pause: { months } }
      </code>
    </td>
    
    <td>
      The plan pauses at the period's end and resumes by itself after 1 to 3 months. Nothing is charged meanwhile.
    </td>
    
    <td>
      Nothing more
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { downgrade: '<plan>' }
      </code>
    </td>
    
    <td>
      A switch to a cheaper plan at the period's end, so this period's price stays earned.
    </td>
    
    <td>
      A plan key from the catalog
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        { discount: '<key>' }
      </code>
    </td>
    
    <td>
      A discount on the next cycles, put on the subscription by the server.
    </td>
    
    <td>
      A discount in the catalog without a <code>
        code
      </code>
    </td>
  </tr>
</tbody>
</table>

Declare the discount in the catalog like any other, with no `code`, so only your server applies it. Then push it with `npx nuxt-backend billing sync`:

```ts [backend/billing.catalog.ts]
discounts: {
  stay30: {
    name: 'Stay with Panels',
    percentOff: 30,
    duration: { months: 3 },
    perCustomer: 1,
    products: { plans: ['pro'], interval: 'month' },
  },
},
```

`perCustomer: 1` is Polar's per-customer redemption limit, so one customer never takes the save discount twice ([Run a promotion](https://nuxt-backend.dev/docs/build/growth/offers#declare-it)). A reason with no entry cancels without an offer.

## Show it in a page

`<CancelFlow>` runs the flow below: the optional step, then the cancellation. Put it behind the "Cancel plan" button of your billing page; the billing section of `/settings` opens it on its own once save offers are on (`useBilling().saveOffers` says so):

```vue [app/pages/settings/plan.vue]
<script setup lang="ts">
definePageMeta({ auth: { workspace: ['owner', 'admin'] } })
const open = ref(false)
</script>

<template>
  <button type="button" @click="open = true">Cancel plan</button>
  <CancelFlow v-if="open" @close="open = false" @canceled="navigateTo('/settings')" />
</template>
```

1. **One question, optional.** "What is the main reason?" with the eight reasons and a comment field, then "Continue". "Cancel my plan" beside it skips the question and cancels at once.
2. **One offer.** The offer for that reason, with its real terms: "Pause Pro for 2 months instead. It resumes by itself on 1 April 2027, and nothing is charged meanwhile.", or "30% off for 3 months". Two buttons of the same size and style: accept it, or "Cancel my plan".
3. **The end.** The date the plan ends, that everything keeps working until then, and a "Keep my plan" button. It emits `canceled` with that date (epoch ms), `kept` when the person keeps the plan, and `close` from its "Close" button or Escape.

"Continue" always leads somewhere. Before it asks, the flow reads `getCancelFlow`, which says which reasons an offer could stand for now, by the rules below. Where none can (inside the withdrawal period, on a past-due plan or a trial, after an offer in the last 12 months, for a reason without an entry, or with the question skipped), the question's button reads "Cancel my plan" and carries `data-intent="cancel"`, in the danger colour. Pressing it opens a confirmation, "Your plan ends when the current period does.", with "Confirm cancellation" and "Back". The plan ends only once that is confirmed. Re-export `getCancelFlow` from `backend/billing.ts` (`nuxt-backend doctor` names it when it is missing); without it, the flow keeps "Continue" and the server decides as before.

Its steps are the parts `CancelFlowQuestion`, `CancelFlowOffer`, `CancelFlowConfirm` and `CancelFlowEnd`, each given the flow's state and actions (`CancelFlowPartProps`, from `#backend/parts`); slots named `question`, `offer`, `confirm` and `end` replace them in one place, and its words are the `cancelFlow` labels ([Billing components](https://nuxt-backend.dev/docs/reference/components/billing)). Markup of your own reads the same state from the flow a slot hands it: `offers` (whether "Continue" can lead to an offer), `submit` (the confirmation first where it cannot), `cancelNow` and `back`.

A page of your own gets the same steps from `useBilling()`:

```vue [app/components/PanelsCancel.vue]
<script setup lang="ts">
import type { CancellationReason, SaveOffer } from 'nuxt-backend/billing'

const billing = useBilling()
const reason = ref<CancellationReason>()
const offer = ref<SaveOffer>()

async function submit() {
  const result = await billing.cancel({ reason: reason.value })
  if ('offer' in result) offer.value = result.offer
}
</script>

<template>
  <form v-if="!offer" @submit.prevent="submit">
    <ReasonPicker v-model="reason" />
    <button type="submit">Continue</button>
  </form>
  <div v-else>
    <OfferCard :offer="offer" />
    <button type="button" @click="billing.acceptOffer(offer)">Keep Panels with this offer</button>
    <button type="button" @click="billing.cancel({ reason, offer: false })">Cancel my plan</button>
  </div>
</template>
```

`ReasonPicker` and `OfferCard` are your components. Read `billing.getCancelFlow` first (`{ offers, reasons }`, `null` for anyone who may not manage the billing) to word the button: "Continue" for a reason in `reasons`, else "Cancel my plan" with a confirmation. `cancel({ reason, comment, offer })` returns `{ offer }` when a save offer applies and none was made to the customer in the last 12 months. Otherwise it cancels and returns `{ canceled: true, endsAt }`, with `endsAt` in epoch milliseconds. `offer: false` cancels at once. `acceptOffer(offer)` applies the offer on the server. The browser only names the offer by its `id`: the server checks that it made this offer to this billing entity, that nobody took it yet, and that it is still open, for an hour after it was made.

A `SaveOffer` carries its real terms: `kind: 'pause'` with `months`, `resumesAt` and the current `plan`; `kind: 'downgrade'` with the cheaper `plan` and `appliesAt`; `kind: 'discount'` with the catalog `discount`, its `name`, `percentOff` or `amountOff`, `duration` and `months`. The cancel flow records `billing.save_offer_made` and `billing.save_offer_accepted` on the [activity trail](https://nuxt-backend.dev/docs/build/billing/events#on-the-activity-trail).

## The rules it keeps

A save offer is lawful when it is one honest step on the way out, not a wall. `<CancelFlow>` keeps these rules, and `useBilling()` enforces the ones a server can:

- **One optional step.** At most one question and one offer, both skippable: "Cancel my plan" is on every screen and finishes the cancellation at once.
- **One offer per cancellation,** and one save offer per billing entity in 12 months. Someone who cancels again within the year cancels in one step.
- **The same weight for both choices.** Accept and cancel are buttons of the same size and style. There is no countdown, no "offer ends when you leave", and no guilt in the labels.
- **No offer where it would stand in the way of a right.** None during the EU withdrawal period while the [withdrawal button](https://nuxt-backend.dev/docs/ship/compliance/subscriptions) is on, none on a past-due plan, and none on a trial. An offer goes only to an active plan.
- **The portal stays open.** Polar's portal cancels without any offer, and the package never hides its link.

That is the line between a save offer and the obstruction consumer law forbids. California's automatic renewal law requires cancellation online, and the EU requires a withdrawal button since 2026-06-19. [Follow subscription law](https://nuxt-backend.dev/docs/ship/compliance/subscriptions) covers both. This is not legal advice: check the rules where you sell.

## Pause instead of cancel

A pause suits someone who will be back: a seasonal user, or someone between projects. `useBilling().pause({ resumesAt })` pauses at the period's end, with or without the cancel flow ([Pause and resume](https://nuxt-backend.dev/docs/build/billing/subscriptions#pause-and-resume)). While a plan is paused, Polar revokes its benefits: features close and plan credits stop. Credits from packs stay. Resuming starts a new period and charges the card on file at once.

## Win people back

`setupEmail({ lifecycle: { winBack } })` writes to a former subscriber 7 and 30 days after the plan ended ([Send lifecycle emails](https://nuxt-backend.dev/docs/build/growth/engage/lifecycle-emails#the-ready-made-flows)). The emails go out under a marketing topic, so only people who opted in get them. They stop as soon as the person subscribes again. The 30-day email may carry a discount, shown with its real end date.

The flow starts from `billing.subscription_revoked`, the plan ended, and stops at `billing.subscription_created`. The cancellation reason shapes the message: "Panels now draws team boards" for someone who left for `missing_features`, a pause reminder for `unused`. `billing.subscription_canceled` carries the customer's `reason`, which Polar keeps on the subscription, and the win-back's event carries it on to Resend, for a condition in the flow's automation or for its template.

## What happens when…

<table>
<thead>
  <tr>
    <th>
      Situation
    </th>
    
    <th>
      Result
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      A member who is no billing manager cancels
    </td>
    
    <td>
      Refused as <code>
        forbidden
      </code>
      
      , reason <code>
        not_billing_manager
      </code>
      
       (<a href="https://nuxt-backend.dev/docs/build/billing/setup#who-may-buy-for-a-workspace">
        Who may buy for a workspace
      </a>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        acceptOffer
      </code>
      
       gets an offer the server did not make, or one already used
    </td>
    
    <td>
      Refused as <a href="https://nuxt-backend.dev/docs/reference/backend/errors#invalid_input">
        <code>
          invalid_input
        </code>
      </a>
      
      , and nothing changes
    </td>
  </tr>
  
  <tr>
    <td>
      The subscription is already set to cancel
    </td>
    
    <td>
      Refused as <code>
        invalid_input
      </code>
      
      , reason <code>
        cancel_scheduled
      </code>
      
      : Polar takes one cancellation per period
    </td>
  </tr>
  
  <tr>
    <td>
      The plan is past due, on a trial, or inside the withdrawal period
    </td>
    
    <td>
      No offer: <code>
        getCancelFlow
      </code>
      
       says so, the question's button reads "Cancel my plan", and the plan ends at the period's end once the person confirms
    </td>
  </tr>
  
  <tr>
    <td>
      Polar is unreachable
    </td>
    
    <td>
      Refused as <a href="https://nuxt-backend.dev/docs/reference/backend/errors#unavailable">
        <code>
          unavailable
        </code>
      </a>
      
      . The portal link stays as a fallback.
    </td>
  </tr>
  
  <tr>
    <td>
      The offer's discount was retired, has a code, or does not apply to the plan
    </td>
    
    <td>
      That reason cancels without an offer
    </td>
  </tr>
  
  <tr>
    <td>
      An offer is accepted after an hour, or twice
    </td>
    
    <td>
      Refused as <code>
        invalid_input
      </code>
      
       (<code>
        offer
      </code>
      
      ): the flow's sitting is over
    </td>
  </tr>
</tbody>
</table>

## Limits

- **A pause lasts 1 to 3 months.** Longer pauses rarely come back, and Polar needs a resume date after the period's end.
- **A downgrade waits for the period's end.** Polar schedules a change one period ahead at most, so an offer never takes effect mid-cycle.
- **No offer in the portal.** Polar's portal has no save-offer step. Customers who cancel there skip the flow, and that is how it should be.
- **A workspace cancels as a whole.** There are no seats, so no offer shrinks a team.

## Test it

Run the flow on Polar's sandbox after a checkout with the test card:

```ts [tests/e2e/cancel-flow.spec.ts]
import { expect, test } from '@playwright/test'

test('a customer who finds Panels too expensive sees the save discount', async ({ page }) => {
  await page.goto('/settings/plan')
  await page.getByRole('button', { name: 'Cancel plan' }).click()
  await page.getByLabel('Too expensive').check()
  await page.getByRole('button', { name: 'Continue' }).click()
  await expect(page.getByText('30% off for 3 months')).toBeVisible()
  await page.getByRole('button', { name: 'Cancel my plan' }).click()
  await expect(page.getByText(/Your plan ends on/)).toBeVisible()
})
```

[Run end-to-end tests](https://nuxt-backend.dev/docs/develop/testing/e2e) signs a test account in and checks out with `4242 4242 4242 4242` first.

## Related

- [Manage subscriptions](https://nuxt-backend.dev/docs/build/billing/subscriptions): cancel, pause and resume without the flow.
- [Follow subscription law](https://nuxt-backend.dev/docs/ship/compliance/subscriptions): the withdrawal button, renewals and refunds.
- [Run a promotion](https://nuxt-backend.dev/docs/build/growth/offers): the server-only discount a save offer applies.
- [Read revenue and usage](https://nuxt-backend.dev/docs/build/growth/measure/revenue): cancellations per reason.
- [Polar](https://nuxt-backend.dev/docs/services/polar): the sandbox, the portal settings and the pause switch.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
