Saving Stripe Webhook Data to Current User Record

Help!!! I created an endpoint in stripe using the invoice_payment_succeeded event. I would like to capture the subscription id, subscription status, plan id and plan nickname after a customer’s trial period ends. I’ve tried capturing this information upfront when a customer subscribes; however, it doesn’t change the subscription status from “trialing” to “active” once the trial period has expired and the customer has paid.

At one point in time, this worked where I was able to save the stripe event data as a record with the database and the event would capture the change in the subscription status. Then all of a sudden it stopped working one day.

I’ve checked the stripe events and logs under the developer section in Stripe. The events are processed without any errors. I also checked the logs under the webhook endpoint, no issues as far a I can see there either. It’s just not updating the fields under the current user.

Here’s what my endpoint setup.

I’m a newbie and I’m not a developer. Any help in figuring this out would be greatly appreciated.

You can read the data in the stripe webhook event log. There you can see which data field is not correct or if the issue is on Bubble side.

I’m having this same problem if anyone has a solution; no issues on Stripe’s end, all the data is present in the Stripe webhook event log, it just doesn’t update the fields in the User data type :thinking:

Do I somehow need to specify/identify to Stripe the user in question, more than just ‘Current User’? As I can use this Webhook to create a whole new data point with a different “Thing”, however it won’t update fields when it comes to the User data type

Hey, yes, there’s no “current user” if your endpoint is triggered by a webhook (i.e. an event coming from outside your Bubble app). This is visible in the logs. You therefore need to to “do a search for” the right user by matching him with the Stripe customer_id sent as part of the webhook payload.

Beware: when your user subscribes, the first Stripe webhook may trigger your Bubble endpoint before your Bubble app gets the chance to record the Stripe customer_id on the user. The consequence will be that your API workflow won’t find any user matching the Stripe customer_id sent with the webhook. To mitigate that, you can either delay your API workflow or make it loop until it finds the Stripe customer_id (maybe with a timeout, in case something went wrong).

4 Likes

Oh wow, THANK YOU! This seems so obvious in hindsight but you just fixed a problem that’s been driving me mad for days! Thank you so much for taking the time to explain this :smile::tada:

2 Likes

Hey,

Does anyone knows how to achieve this?

Thanks in advance :slight_smile: :computer:

Yes inside the current API workflow which is calling from “webhook” create another API call and schedule it to your required time and pass your required data