Menu

1 / 3

Build a Stripe cancel flow: cancel_at_period_end and a webhook handler that doesn't double-count

DEV Community: node·Grain64·12 days ago
#jfsYUJB3
#devtonodejs#devto#dev#stripe#subscription
Reading 0:00
15s threshold

A cancel flow on Stripe is three pieces: a place that catches the cancel click, an offer step, and a webhook that tells your app whether the cancellation was scheduled, stopped or finished. Set cancel_at_period_end to true so the subscriber keeps what they paid for, and revoke access only when customer.subscription.deleted arrives.

Cancel at period end, not immediately

By default, cancelling a subscription through the API takes effect immediately and no more invoices are generated. To let the subscriber keep the period they already paid for, update the subscription with cancel_at_period_end=true .

Schedule it: set cancel_at_period_end to true . Stripe sends customer.subscription.updated .

Offer something (optional): the subscriber is still active, so there is time to show an offer and apply it.

Stop it: set cancel_at_period_end to false any time before the period ends. Stripe sends customer.subscription.updated again.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.