Need help with Stripe backend

I have set up a webhook for ‘subscription_created’ which works fine. I now need to do a simple action to save data when a user joins a payment plan.

I have three payment plans. When the user clicks on Plan 2 they are subscribed to that plan successfully, but the DB is not being updated. Here’s the ‘pay now’ button workflow;

The backend set up first looks for the User …

Then I try anf make changes to the User’s company, which is not working?

The webhook seems to be working… but no customer or company info is being saved to DB.

success

My guess is that your search is not returning anything… but the server logs will show you what’s going on… so take a look at them first (as I said, I’d guess that the User is not defined correctly - unless it’s a privacy rules issue)…

But the obvious questions are:

Are you definitely storing the Stripe Customer ID on the User datatype correctly? (if so, where and how?..)

Also, how and where are you setting the Plan_ID on the Company datatype?

But, in any case, I’d first check your server logs to see where the issue lies…

Thanks @adamhholmes I will give that a go …

Do you have a minute to watch this?Loom | Free Screen & Video Recording Software | Loom

I won’t pretend to know much about how the Bubble Stripe plugin works (I’ve only ever used it a couple of times), but as far as I understand, if you use a Stripe plugin action (like Subscribe User to a Plan), then any subsequent workflow actions (at least those that make reference to the results of that step) will only run if the Stripe action was successfully processed (which is confirmed by your own testing)… although it could just be that there isn’t any information to add (i.e. customer IDs and Plan IDs etc.)…

In any case, i don’t think that’s relevant here…

As I explained previously (on an older post you made), the issue here is that the Customer ID, and Plan ID are being store on the User in client side actions, once the User is redirected back to the page after successful payment. That takes a number of seconds (from memory, last time I took a look at your sever logs there was a difference of 9 seconds between the time the Stripe event triggered your backend workflow, and the time your client side actions stored the Stripe customer and subscription IDs etc on the User)…

So, at the time the backend workflow runs, there are no customers with the Customer ID you’re searching for.

But again, you can see that for yourself in your server logs to confirm that is the issue…

As I’ve said previously, you can’t rely on the info returned by the Bubble plugin in a webhook-triggered backend workflow (the webhook event fires as soon as the event happens), so you’ll need a more reliable way to identify the Customer on the backend.

That rather depends on how you’re doing things, but presumably in your case, the only unique identifier you have for a customer is the email address, so you’ll have to use that in your backend workflow instead of the Customer ID (which won’t have been set yet).

Thank you and yes I remember you mentioned the delay before, but if I use the backend webhook then there should be no issues with delay as the data is coming in after payment made.

The problem is I don’t intuitively understand webhooks at all, never have. I don’t therefore know how to use the customer email address instead of the Customer ID - this must seem bizarre to you, I just don’t understand where/how to do that.

I’ve spend $100’s on freelancers to set my webhook up but nothing works. The crazy thing is all I am trying too do is this;

User joins Plan 1 , then database gets updated with;

  • Plan_ID *
  • Plan start date

This must not be unique to the customer, it must be related to the plan so I can reference it in my app. I need to say things like When current user’s Plan_ID is xxxxxx then they can use certain features.

I did try using an API but that was more complicated for me. The Bubble plugin is best but I have no idea why the webhooks don’t update the DB … and I struggle to know what information / type of webhook to use as there are so many.

Hi @darren.james7518 ,
Can you share your weebhook setings to? Exacly webhook URL.
If this webhook works when you set this for the first time and now didn’t work in live mode then try to remove “/initialize” phraze form the end of webhook URL .

In my case i used Stripe weebhook only to cheeck if recuring payment was paid as expected (second payment and more)
But for set user plan for the first time i use “make changes to current user…” afrer “subscribe user to a plan” action. (Without webhook) innthis case user data was updated only if user was completed their subscribction payment, and when it fails or abandon. Workflow will stop at step one and didn’t triger the next one “make changes to user”

I removed “/initialize” after it was successfully initialized.

I am listening for ‘customer.subscription.created’ but why am I listening for this? There are 100’s of webhooks and I picked one from the hat. Please can someone tell me how we know which webhook to use to tell our app the Plan_ID?

That aside, whichever webhook I listen for currently is mute because the DB never updates.

Last week I paid $120 for 90 minute one-to-one session with freelancer and webhook still wasn’t fixed. I feel that a simple (single) webhook should be setup in 2 minutes by someone who knows how - or am I being very naive?

You just need to search for the User by their ‘email address’, instead of the ‘Customer ID’ (which will still be empty when your search is being done)…

From memory, you can’t access the customer email directly from the subscription object, so you need to make a Get Customer call first (which I think you can do with the Bubble Stripe Plugin), using the request data’s Customer ID. Then you can access the email address from the customer object.

I need to be able to say to my users “If you are on Subscription Plan 1 then you can have 3 team members. If you are Subscription Plan 2 then you can have 10 team members…”

So once they checkout I need to know what plan they are on. That’s all I need to run my app!

I just tried and there is no ‘Get call’ option :frowning:

But using backend webhooks means that any delay is not a problem, I don’t think the issue is with a delay, it’s something else.

Then if you only need this, you probably have 2 separate actions (two prices) “subscribe user to a plan” just add another action after add subscribtion - “make changes to current user” and set this plan name or set number of members to your user data.


If you want to use plan ID es earlier you can recive it from “result of step 1…(subscription)”

This is how I had it and that worked … but as said in my video, this feels like the incorrect way to do it because if a user clicks ‘Pay now’ and then doesn’t checkout, Bubble may still run the workflow Step 2.

Also, why won’t my backend webhooks update the DB? I am just so curious now…

It won’t run step 2, as long as the results of payment was’t successful.

Thank you, but if that’s true then why does anyone need to make changes to their DB via a webhook if they can always make those changes via a workflow?

I just tried and there is no ‘Get call’ option :frowning:

You need to select ‘Get Data From External API’ to be able to select the Get Stripe Customer Call (which is 100% part of the Bubble Stripe Plugin, I just checked)…

But using backend webhooks means that any delay is not a problem, I don’t think the issue is with a delay, it’s something else.

If definitely is that (and your server logs will prove it),… and if you can’t see why then you’re clearly misunderstanding what’s going on here…

You’re not using your webhook workflow to update the Customer ID (you’re doing it client side), and that’s exactly the problem…

Trying now …

@adamhholmes I referenced the email but still the webhook is not updating my DB.

@adamhholmes I have some interesting information … I was wrong in that 1 of my webhooks DOES update the DB. This is the ‘deleted’ webhook.

Let me show you as it may provide some clues to why the other one doesn’t work.

So, ‘create’ webhook doesn’t work but ‘deleted’ does.

I referenced the email but still the webhook is not updating my DB.

No, that doesn’t make any sense…

The ‘Customer ID’ needs to be a valid Stripe Customer ID (not an email address)…

Try to think logically about what you’re trying to do and it should all make sense…

You’re trying to define a User by matching their email address in your database to the email address from Stripe, using a Customer’s Email address from their Stripe Customer object

So you need to use their Customer ID to retrieve that object (using the Get Stripe Customer API call)…

So in the Get Stripe Customer call box you need to enter the Customer ID of the customer you want to retrieve - i.e. the customer from the webhook’s request data… request data's object customer

Then select the email address from that customer object to use in your Search for Users.

So, ‘create’ webhook doesn’t work but ‘deleted’ does.

Yes, of course that webhook workflow will work, as you have the Customer ID stored on the User by that point…