Recurring subscriptions in Stripe

Hi all,

I’m currently building an app with yearly recurring subscriptions being handled by Stripe.

My question is how failed payments are handled. So let’s say a user signs up and the first payment is successful, but one year later the payment fails. I would like access to the app to be restricted. Would I need to run an API Workflow to handle this? Any advice on this topic would be great. Thanks!


No Code Founders

1 Like

Create new “Endpoint” at API section.
Get the API workflow endpoint url of your website. add this enpoint URL into webhook on Stripe (select the failed event notify to the URL).
You can handle once you received failed payments then, stop or retry the subscription

1 Like

Thanks for this. So I take it the Stripe plugin doesn’t handle this?

Hi @josh7,
Yes, you need to handle this from webhook.

Great! I think I’m on the right tracks with this.

I’m trying to set it so that the payments are re-attempted in Stripe and then if they all fail, the subscription will cancel in Stripe which would trigger the webhook to change the subscription service in Bubble. Only thing is that there is not an event option for a cancelled subscription, only for a deleted subscription or a cancelled subscription schedule as shown in the screenshot above. Any idea if any of these options will work for it?

Thanks again!

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:

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!


Thanks so much for the in-depth explanation :pray: That’s been really useful.

Just to share a little more context, I’ve setup the following for subscriptions in Stripe.

The key part is that if all retries for the payment fail, the subscription will be cancelled.

I then want that to be sent to Bubble so that the subscription in Bubble is also cancelled. So my question is…does the customer.subscription.deleted event get triggered when the subscription is cancelled, or is a deletion different from an automatic cancellation.

My other question is…will the API Workflow run automatically when the webhook even from Stripe runs, or do I still need to trigger this elsewhere in my app via pushing a button for example?

Thanks so much for all your advice.

Much appreciated!

Hi @josh7,

No problem, happy to help!

Yes, customer.subscription.deleted will be triggered in that case, because, besides it being named “deleted” it is actually triggered in any case where a subscription ends (see: Types of events | Stripe API Reference).

As for your second question, I had a bit of trouble understanding what you’re fully asking, here’s what I believe you’re asking;

To that question, yes it will, all APIs happen in the backend with no user interaction needed.

Should I have not understood that question fully, let me know!

Hope this helped. :smile:

1 Like

Perfect :ok_hand:This is exactly what I was looking for so thanks so much for that.

With your first option of cancelling the subscription immediately, would I need to setup a search for users in my API Workflow and search for the Stripe ID to be able to identify the correct user in Bubble? As shown in the Bubble documentation :point_right:

Thanks again

Correct! Just follow that tutorial, however, adjust for cancelation.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.