Forum Academy Marketplace Showcase Pricing Features

Can't find users with Stripe customer ID after webhook

Hi all,

When I charge a customer’s card via Stripe I wait for webhook from Stripe to confirm the payment was successful, I then plan on stating the payment was a success on the users account.

However, after I receive the webhook, I search for the user based on the Stripe Customer ID = Request Data’s object customer:

But when the workflow runs to update the successful payment for the user it can’t seem to find the user - it runs as ‘Anonymous user’

I checked the Stripe Customer ID on Bubble’s side and and the Customer ID Stripe sent int eh webhook and they match.

How are you waiting? Likely this is a problem of asychronous vs synchronous actions. It’s possible you think you’re waiting but bubble isn’t and its trying to find the request data’s object customer basically immediately. Usually anything sort of action similar to what you’ve described requires two separate processes (i.e two different workflows) as if they are in the same workflow, they will try to run one after the other which doesn’t work.

I could be misunderstanding what you’re saying so I could be wrong.

What is the webhook event notification you are getting from Stripe? Is it checkout session completed or something else?

I am fairly confident it is not the checkout session completed webhook as Stripe doesn’t pass the customer object with that event notification.

Usually the customer object is a ‘thing’ basically, like in Bubble DB it is a custom data type and what you want is the equivalent to a datafield in Bubble which is attached to the customer object in the form of ID.

Looks like your dynamic expression taking the request data’s object customer is not getting the customer ID but just the customer object as a whole.

Check your detected data and look at the values passed. You can easily do this by clicking the ‘modify types’ button on your backend workflow to see a popup of the values sent from stripe for the webhook to get a better sense of how that data is organized and how you need to reference it.

You might see in yours the ‘customer’ and then below it as a sort of ‘expanded’ data would be the details of the customer such as ID, name and email.

If you are interested in a guided approach to a full stripe integration I created a course that covers all the details for a successful and headache free stripe integration which goes into detail the various webhooks as well.

Hi @andrewmccalister , check your privacy rules. Sometimes this happens when you haven’t checked the “ignore privacy rules” checkbox in the API workflow. Or you need to adjust privacy rules to allow the API to do a search for users. Hope it helps

Hey @Diego,

This seems to have solved it. Somewhat surprisingly it finds the user but still runs as ‘Anonymous user’. Presuming that’s because the user didn’t activate the workflow.

Hey @boston85719,

Thanks for the input. It seems the issue was down to the fact I hadn’t checked ‘Ignore privacy rules’ on the workflow.

I manually checked the webhook response in the stripe dashboard and it was sending all the expected data/.

I have come to the point I check that by default now when creating a backend workflow, and I don’t create privacy rules until the end of the build and have tested all functionality once, and after privacy rules are created I test again as different users to confirm privacy rule functions.

Privacy Rules often cause issues when testing.