Are Webhooks the only way to trigger events that are dependent on a Stripe payment is successful?

I want to ensure that I record orders only after a user has made a successful payment. If the payment fails, I want a message to pop up saying it’s failed and that their order can’t therefore be accepted. I think this is done via Webhooks (?) and I’ve watched several YouTubes and they seem complicated and to require screens of code and settings that I can’t get my head round but which the presenters on the YouTubes just fly through as though it’s plain English!

The bubble manual doesn’t appear to cover Webhooks.

Is there any other way to make events run only when payments are successful or is there a helpful introductory guide that can explain Webhooks to me? I’ve literally just come across them this afternoon and preventing orders from being processed when payments fail seems such a basic and fundamental requirement that I’ve surely missed something basic.

Can anyone point me in a proper direction?

Is there any other way to make events run only when payments are successful

There are other ways, but they’re not as simple, reliable, or as efficient as using webhooks…

Webhooks are simple… they’re just an API call to your app from an external service when a specific action takes place on that service.

The Bubble manual explains how to set things up on the Bubble end (Workflow API - Bubble Docs) but obviously, depending on the service the webhook is coming from, you’ll need to read the docs of that service to understand how their webhooks work.

Stripes docs are amoungst the best around, but its fairly self-explanitory once you understand the concept of webhooks. Use incoming webhooks to get real-time updates | Stripe Documentation & Stripe API reference – Webhook Endpoints – Node.

They’re easy to set up (there’s certainly no code required!)…

  1. First set up and configure your webhook in Stripe.

  2. Then create a new API workflow in Bubble (exposed as a Public API Workflow), and click detect Data… add the full endpoint URL (including ‘initialize’) to the webhook in Stripe.

  3. Trigger the event somehow to initialize the workflow.

  4. Remove ‘initialize’ from the endpoint URL in Stripe

  5. Add the relevant actions to your workflow in Bubble, which can now refer to the data in the Webhook payload.

2 Likes

Many thanks for this. When I read this I can’t see why they seemed so intimidating - I guess I watched an unlucky selection of YouTubes on them with fast explanations involving the copying and editing of reams of text, links and code.
I’ll give it my full concentration again tomorrow. Probably better to give my head a break for now.
I’m truly grateful for the support you offer on this forum.
All the best
Joe

There are other ways of seeing if the Stripe transaction was successful or not though - right? For example, you can fetch stripe customer / product / subscription IDs which would indicate success, and a failure would through an error in Bubble’s workflow.

Having re-read your original question… you wouldn’t use a webhook for that… if you want to show the user the payment has failed you can do all that on the page…. (as @drfalken points out)…

If a payment fails there’s not really an issue, as nothing will happen since the workflow will fail.

The bigger issue is the opposite problem - i.e. the payment goes through successfully but, for whatever reason, the customer doesn’t complete the checkout flow (maybe they closed their browser too soon or hit the back button, their internet connection dropped out, they had power-cut, or there was some other error in the workflow)…

Now you’ll have a customer who’s made a payment, but hasn’t got access to your app/service/product as, so far as your app is concerned, the payment never went through (even though it did)…

That’s why you shouldn’t rely on anything happening on the page to confirm orders/subscription/payments, but should use webhooks instead.

1 Like