Hi @josh7!
Great question here - one quick thing;
If your customer’s subscriptions cancel immediately when they cancel;
You’re going to want to subscribe to “customer.subscription.deleted”
If your customer’s subscriptions don’t cancel immediately when they cancel;
You’re going to want to subscribe to “customer.subscription.updated”
Since they’re different processes, I am going to break it up into two sections;
Note: Do not group them into one webhook, create a webhook per event, although Stripe allows you to subscribe to multiple events per webhook, it’s best to not in this case.
Subscriptions Cancels Immediately
Make a stipe webhook “customer.subscription.deleted” then just have it ping your app API setup to cancel the account in-app.
More info on Bubble APIs: https://manual.bubble.io/using-the-bubble-api.html
Subscriptions Cancels At End of Period
First, subscribe to the event “customer.subscription.updated” in Stripe and create an API point which uses the following If/Then;
Now you should have this API schedule another API for the end of Subscription Period;
We’re going to have this one cancel the subscription in-app and update the user, however, we’re going to add a first step which verifies the subscription should still be canceled;
We’ll need to create an API via the API connector to do this first;
(Stripe Docs: Retrieve a subscription | Stripe API Reference)
Also, for this API you’re going to use an HTTP Basic Auth;
[Password remains empty per Stripe auth docs]
Now that we have this API we’ll create an API endpoint which cancels the user in-app;
An additional step, for this you’ll have to change “cancel_at” to date in the “modify” tab;
Now that Bubble will recognize “cancel_at” as a date we’re going to use this to schedule the cancelation API;
First, add the “Schedule an API workflow” available under “Custom Events” then schedule your user cancelation workflow which updates the user in your app;
In this, I am using their Stripe User ID to find the customer;
Let me know if you have any questions!