Skip to content

Instantly share code, notes, and snippets.

@stevepeak
Last active December 30, 2019 23:04
Show Gist options
  • Save stevepeak/2a22b6a648f890e2a6aaae24600d4f8e to your computer and use it in GitHub Desktop.
Save stevepeak/2a22b6a648f890e2a6aaae24600d4f8e to your computer and use it in GitHub Desktop.

Make sure you don't miss this very important webhook or else your customers will remain on paid plans that they no longer pay for.

# Delete subscriptions when they are deleted by Stripe
when stripe events customer_subscription_deleted as subscription
customer = stripe retrieve_customer id:subscription["customer"]
psql update table:"users" values:{"subscribed": false} where:{"email": customer["email"]}
mailgun send to:customer["email"]
from:"[email protected]"
subject:"Subscription Cancelled"
text:"Your subscription has been cancelled due to a failed payment."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment