How can I run code when a subscription ends?

David Verhasselt
As the title says - what's the best way to ensure some code is run when a subscription ends?

The best way I found is that I could add an `after_update` callback on `Pay::Subscription` that `runs_code if !active?` but I haven't found a way to avoid running that code twice in case a subscription that already ended is still updated.

Chris Oliver
The best place is to add a webhook listener for the Stripe customer.subscription.deleted event.

Braintree and such won't run a webhook on cancellation iirc, so you'd have to write a cron job for those. 
You’re not receiving notifications from this thread.
© 2022 GoRails, LLC