Update stripe subscription

Hi everyone,

I implemented the stripe plugin for tracking subscriptions status (one plan monthly and one plan yearly) and it does not always work. This is my setup:

In my backend I have an API workflow called “stripesubscription” link to a webhook in stripe “invoice.payment_succeeded”

Then based on that webhook I use the action “create new thing” in a data type called Payments

Then I need to link that data to the correct user. So I use the action “make change to a list of thing”, type “user”, list to change "Search for users"and I use a constraint so it only affect the user who have the same “stripe customer id” than in the webhook.

So first I wonder if it’s a good practice to proceed like that ?

Then I read in another post that sometimes the webhook is triggered before bubble stores the “stripe customer ID” and as a result I would need to run that API workflow in a loop. But I have no idea on how to do that.

So if a senior bubbler with experience on tracking stripe subscriptions status could enlight me it would be much appreciated.

@baroud8812

One suggestion:

To find your user use make changes to a thing and do search :first item (with the constraint being looking for the customer stripe id)

1 Like

Hi @cmarchan,

Thank you for taking the time. Indeed I thought it was a bit strange to use the make change to a list element. Did I understood you right ?

Do you have a suggestion on how I could make it loop in case the webhook is triggered before bubble store the customer ID ?

@baroud8812

To track subscription status I would not use Stripe webhooks at all if this is all that is needed.

Male sure you have the Bubble Stripe plugin installed and find the status like this:

current user stripe subscription id status

Lookup the Stripe api docs and find all the status options that the subscription object can have (active, trialing, incomplete, … etc) and build the logic in your app accordingly :grinning:

1 Like

Yes this was the logic I used before. It’s working but the user need to log in the app so bubble can update his status.
If I use a webhook it would be more accurate.
But maybe you are right and I over complicate things.

For what purpose would you recommend the webhooks with stripe then ?

@baroud8812

For the same that you are after. Bubble just did it with everything ready to go. So, to me it makes it easier :+1:t2:

Makes sense. For curiosity purpose, how do we make a loop with an api ?

@baroud8812

1 Like

Thanks again Carlos.

1 Like