I’m encountering an issue with adding credits to users in my Bubble app when a payment is successfully processed via Stripe webhook. I’ve set up the webhook to trigger on the invoice.payment_succeeded event, and I’ve configured a backend workflow to update the user’s credits accordingly. However, despite verifying that the webhook is triggering and sending the necessary data, the credits are not being added to users’ accounts.
Here’s an overview of my setup:
Webhook Configuration: I’ve confirmed that the webhook is successfully triggering on Stripe’s end and sending the Stripe customer ID to my Bubble app.
Backend Workflow: In the backend workflow, I’m using the "Make changes to a thing " action to update the user’s credits. The Stripe customer ID is correctly mapped to the user’s data, and the credits are supposed to increase by 150 each time a payment is successfully processed.
Also i noticed that when i manually resending Webhook from stripe,- it works.
Sounds like there is more to this setup than explained…are you creating the user in your bubble app with the webhook or does the User data type in Bubble already have the stripe customer ID properly saved b4 they make the invoice payment?
Hi, so i have a workflow setup when user subscribes to a plan and i collecting information like Customer ID, Subscription ID etc, i’m storing this information under user data type.
Also i have identical backend workflow setup for Canceling subsriptions, and it works just fine .
I think the problem is the backend workflow for the webhook that is step 2 make changes to current user…might not be finding the correct user. For my apps, I never use the current user for webhooks, and I always have a way to search for the correct user when I need to make changes to the user
Thanks for your answer, however the workflow for step 2 is not in the backend workflow, it’s on a normal page, I use Backend workflow only for webhook detecting.
Okay…in order to provide you the solution to your problem, you will need to share screen shots with all details of the entire setup so that it is clear which workflow actions are attached to which events etc.
Step 3: Backend Workflow catches (or supposed to catch) the event. I initialized event again just to show that backend workflow actually catches the webhook when it sent directly from Stripe.
The Request Data’s object customer needs to be populated…check your Stripe logs to see if the webhook sent that value or not…and share the screen shot of the entire webhook sent as there are multiple locations for customer data to be sent and Stripe has become more difficult to work with because of this
Does this only happen when the user first subscribes to a plan but not on renewals? If so, it’s likely that you’re receiving the Stripe webhook before Bubble has had a chance to populate the user’s customer ID. The fact that it works fine when you manually send the webhook make me think that’s the case. You can verify this by checking the server logs and seeing if the user is empty.
If this is what’s happening, you can solve it like this:
1 - create an api workflow with the action to make changes to the user to add credits and any other actions you want to take. Let’s call this workflow “update_sub”
2- On your webhook set up the following actions:
make changes to a user: search constraint = stripe customer ID (use the bubble field, not the field you created) = Request Data’s object customer
Schedule API workflow update_sub for current datetime if result of step 1 is not empty
Schedule API workflow update_sub for current datetime + seconds (5) if result of step 1 is empty
Hi, I tried to implement the steps you provided, but I encountered some difficulties with scheduling API workflows. When I attempt to schedule the API workflow, “update_sub” is not a possible option to choose after selecting “Parameter definition: Detect Request Data.” Perhaps I need to keep it in manual definition?
Are you trying to pass the whole webhook from the webhook to the api workflow? If so, I wouldn’t do it that way. Just define the parameters you need on the api workflow, (for example, cus_id), then in the webhook just get that value from the response data and pass it as a parameter to the api workflow. Don’t pass the result of step 1 as that will sometimes be empty
Do you mean defin parameters in that way ? If yes i had one set up already for subscription cancelation which works just fine.
And another one i had set up in the same way but for Credits but it not works.
I think you was right, I made some tests and when i’m canceling the subscription and then subscribing again backend API workflow adding credits. So i think there is a solution in scheduling API workflows. However im new in bubble developing and i don’t really understand how to schedule webhooks, maybe there is some articles or tutorials how to do this?