Search code examples
stripe-payments

Fire Stripe webhook the moment a subscription is cancelled (not the moment it ends)


In Stripe, I'd like to fire a webhook whenever a user cancels a subscription to, e.g., update the expiration date of a license elsewhere.

I see that customer.subscription.deleted is fired only at the moment the subscription actually terminates. The webhook customer.subscription.updated doesn't fire either.

Any hint on what event I should listen to?


Solution

  • Which webhook event fires will depend on whether you're cancelling the Subscription now (via this endpoint) or setting it to cancel in the future by updating the Subscription and setting cancel_at or cancel_at_period_end.

    If cancelling now, then customer.subscription.deleted will fire immediately. If cancelling later customer.subscription.updated will fire immediately (to reflect the updated fields), with customer.subscription.deleted firing once cancelled at the specified timestamp.

    This behaviour is explained in our documentation.