- Cancellation flows
- Stripe
How to build a cancellation flow with Stripe Connect
· Alex Foong · 8 min read

Most guides to Stripe cancellation flows assume the flow runs on your own Stripe account. That stops working the moment the subscriptions belong to someone else: your customers’ customers on a platform, the products an agency runs for clients, or a retention tool acting for the SaaS teams that use it. To read those subscriptions and apply an offer to them, you need Stripe Connect.
This guide covers the parts that change under Connect: how to get access to an existing account, which scope you need, how every call is routed to the right account, how webhooks from connected accounts reach you, and how to make each offer safe to retry. It is written from how Reoffer does it in production, so every step is one we actually run.
Last updated 16 November 2026. Stripe references: Connect OAuth reference, making API calls for connected accounts, Connect webhooks.
When you need Connect at all
If the subscriptions live in your own Stripe account, you don’t. Use your secret key, or Stripe’s own retention rules in the customer portal, and read our guide to building a cancellation flow on Stripe instead.
You need Connect when the flow must act on subscriptions in another business’s Stripe account:
- a platform that lets its users sell subscriptions and wants to offer them a cancel flow;
- an agency or studio running several SaaS products, each with its own Stripe account;
- a retention tool, like Reoffer, that founders connect to their existing Stripe account.
Asking each of those businesses for a secret key is the wrong answer. A pasted key can’t be scoped, can’t be revoked from your side, and turns your database into a store of full-access credentials. Connect gives you an authorization the account owner can see and revoke in their own Stripe Dashboard.
Step 1: connect an existing account with OAuth
The businesses you serve already bill on Stripe and already have customers, so you are linking an account that exists, not creating a new one. For that, use Connect OAuth with Standard accounts: the owner keeps full control of their account and approves your platform.
const url = new URL("https://connect.stripe.com/oauth/authorize");
url.searchParams.set("client_id", process.env.STRIPE_CONNECT_CLIENT_ID); // ca_…
url.searchParams.set("response_type", "code");
url.searchParams.set("scope", "read_write");
url.searchParams.set("redirect_uri", "https://yourapp.com/stripe/callback");
url.searchParams.set("state", state); // random, single use
url.searchParams.set("stripe_landing", "login"); // they have an account: sign in, don't register
The scope has to be read_write. read_only lets you show plans and prices, but it cannot create a coupon or update a subscription, so no offer could ever be applied.
Treat state as a credential. Generate it randomly, store only a hash of it with the signed-in user and an expiry, and reject a callback whose state doesn’t match or was already used. That is what stops someone from attaching their Stripe account to a victim’s workspace.
On the callback, exchange the code once:
const token = await stripe.oauth.token({ grant_type: "authorization_code", code });
const accountId = token.stripe_user_id; // acct_…
if (token.livemode !== expectLive) throw new Error("test/live mismatch");
Keep stripe_user_id. Throw the access token away. It is a long-lived credential you don’t need: every later call can be made with your platform key plus the account id (step 2). A token you never store can’t leak. Also check livemode: a test authorization recorded as live would send real offers to a sandbox, or the other way round.

Step 2: route every call with the Stripe-Account header
Every read and write for a connected account uses your platform secret key and names the account:
const sub = await stripe.subscriptions.retrieve(
subscriptionId,
{ expand: ["discounts", "schedule"] },
{ stripeAccount: accountId }
);
Forget stripeAccount once and the call runs against your own platform account: at best a “No such subscription” error, at worst a coupon created in the wrong place. Put it in one helper that every billing call goes through, rather than repeating it at each call site.
Keep test and live completely apart: separate platform keys, separate Connect client ids and separate webhook secrets per mode, and refuse to start if a test key sits in a live slot.
Step 3: check the subscription again just before you change it
The cancel page loaded a minute ago, but anything could have happened since: another discount, a plan change, a subscription schedule, a cancellation from the portal. So right before applying an offer, retrieve the subscription fresh from the connected account and re-check that the offer still fits: still active, the expected customer, no existing discount, no schedule in the way. If it no longer fits, show a clear message and let the customer cancel. Never guess.
Step 4: apply the offer, safely retryable
Networks fail halfway. If a timeout leaves you unsure whether Stripe applied the discount, you need to be able to send the same request again without applying it twice. Stripe’s idempotency keys do exactly that, as long as the key is stable: derive it from the session and the offer, never from a random value per attempt.
The three common offers map to Stripe like this:
| Offer | What you call in the connected account | Watch out for |
|---|---|---|
| Percentage discount | Create the coupon in the connected account (coupons.create with percent_off and a duration), then subscriptions.update with discounts: [{ coupon }] | discounts replaces what is there, so check for an existing discount first. Reuse one coupon per offer version instead of creating one per customer. |
| Free billing cycle | A coupon with percent_off: 100 and duration: "once", applied the same way | Only the next invoice is free, and the regular price comes back after it. It is not a trial and not a refund. |
| Pause payments | subscriptions.update with pause_collection: { behavior: "void", resumes_at } | The subscription stays active and invoices in the pause are voided, so the customer is never charged for it later. Decide separately whether paused customers keep access. |
await stripe.subscriptions.update(
subscriptionId,
{ discounts: [{ coupon: couponId }] },
{ stripeAccount: accountId, idempotencyKey: `offer:${sessionId}:${offerVersion}` }
);
Which offer fits which cancellation reason is a separate question. We compared them in discount vs free cycle vs pause.
Step 5: receive webhooks from connected accounts
Events from connected accounts don’t reach your normal webhook endpoint. Create a separate endpoint in your platform’s Dashboard that listens to events on connected accounts. It has its own signing secret: keep it apart from the secret of your own billing webhook and never try both. Each event carries an account field naming the connected account it came from.
// raw body, exactly as received: parse only after verifying
const event = stripe.webhooks.constructEvent(rawBody, signature, CONNECT_WEBHOOK_SECRET);
const accountId = event.account; // acct_… — look up which workspace this belongs to
// store the event id, answer 200 quickly, process from a queue
Store each event and process it from a queue, so a burst of events or a slow handler never makes Stripe retry, and so a duplicate delivery is recognised by its event id.
Step 6: count a save only when Stripe confirms it
A customer clicking “Accept offer” is intent, not a save. The save is real when the subscription in Stripe shows the discount, the free cycle or the pause you asked for. Count it when the customer.subscription.updated event (or a fresh retrieve) proves it, and keep a reconciliation job that re-checks offers which never got a definite answer. That is the difference between a save rate you can trust and one that flatters you. More on that in how to track your cancellation save rate and our save-rate methodology.
Step 7: keep the cancel button in sight
An offer must never stand between a customer and cancelling. Show “Cancel my subscription” on the same screen as the offer, and make declining as easy as accepting. Several US states require exactly that for online cancellation, and it is the right thing to do anyway.
What this looks like in practice
- OAuth with
read_write, a hashed single-usestate, and the access token discarded. - One helper that adds
stripeAccountto every billing call, with separate test and live keys. - A fresh retrieve and re-check right before each change.
- Coupons created inside the connected account, stable idempotency keys,
pause_collectionwithvoid. - A dedicated Connect webhook endpoint with its own secret, events queued by id.
- Saves counted from Stripe’s state, never from the click.

Or skip building it
That list is most of what Reoffer is: a hosted cancellation page that asks why the customer is leaving, shows the one offer that fits, applies it through Stripe Connect, and counts a save only when Stripe confirms it. You connect your Stripe account once, point your cancel button at the page, and test in Stripe test mode before going live. Running several products? Each one connects its own Stripe account; see Reoffer for agencies.
The Free plan needs no card and no Stripe connection: it records why customers leave and sends them on to your billing page. Paid plans, from $29 a month, add Stripe Connect and the offers. Start free.
Only when the subscriptions are in someone else’s Stripe account, such as your platform’s users, an agency’s clients, or the founders who use your retention tool. For your own account, your secret key or Stripe’s retention rules are enough.
read_write. read_only can show plans and prices but can’t create a coupon or update a subscription, so it can’t apply any offer.
No. Keep the connected account id (stripe_user_id) and make each call with your platform secret key plus the Stripe-Account header. A token you never store can’t leak.
Create a separate webhook endpoint that listens to events on connected accounts. It has its own signing secret, and each event’s account field tells you which connected account it came from.
Update the subscription in the connected account with pause_collection set to behavior: "void" and a resumes_at date. The subscription stays active and invoices in the paused window are voided.
When Stripe shows the change on the subscription, not when the customer clicks Accept. Confirm it from the subscription update webhook or a fresh retrieve, and re-check offers that never got a definite answer.
See why your customers leave
Start on the Free plan: no card, one product, feedback only. Connect Stripe on a paid plan when you want offers applied and saves counted.