Quick long answer here to help you, sorry maybe it will not be very structured.
- get in mind I am not a professionnal devloper, sometimes I may say some stupid or very non technical stuff
Webhooks are a way to send back information from a solution to another, when an event occured.
If you ask Stripe to do something via the API, you will get a response saying “I receive your demand, and will do that”. So that’s the “200” code the api return when you do something through the API.
Then Stripe does what you asked. And you have to know if it’s done or if a problem occurs.
(OR, sometimes, events happened and Stripe have to let you know (for example if one of your user’s credit card expires 6 months after he subscribed…)
When this is done, you need to know it is done, as you say. So Stripe can send webhook.
So webhooks are secured and reliable call that let you know that something went well, or not.
What I love with Stripe + bubble API Connector is that you can easily (really in 1 minute) set webhooks, for pretty much everything in Stripe (When a payment is completed, when you need to be aware of something like required infos about a customers or a connected account, etc etc…).
To set webhooks, there are two important step :
- You have to create an endpoint in your bubble app (I don’t know how devlopers describe it, but I like to say, it is exactly like a phone number or an email adress… people who need to contact you know they have somewhere to send an info to.) :
In your bubble app : you can set it up in the backend workflow tab (avalaible in the editor, at the bottom of your pages list. If not available, you have to enable backend workflows in your app setting -> API.)
So Just create an endpoint like “CheckoutSessionCompleted” . Once you have it : double click on it, click on “detect data”, copy the link.
- Create a webhook in your Stripe dashboard -> Devlopers -> Webhooks, create new webhooks.
Paste the adress.
Select the event you need to send with this webhooks.
Your are all set up ! Almost…
You have to initialize it by sending a test webhook. Back to Bubble you can check your endpoint received it. And then, remove the “initialize” in the adress from your stripe dashboard, to make it work.
Please note that there are different authentification parameters enabled, and you have to be careful about it. There are some topics on the forum about it. For my usecase, I asked to the bubble support if it was allright and secure and they did answer.
What will happen then ?
Some examples :
When a user subscribe, you process the checkout. -> When payment is completed, Stripe send a webhook to your endpoint -> You can listen to this endpoint and automate a new workflow (for example -> changing the users datas as “subscribed” -> sending a welcome email etc…
At the end, instead of saying : " Someone checkouts, it looks like the payment goes well because he came back at the success url, so I will confirmed he subscribed"… (What is not secure because a users just has to know what is the success url to be subscribed…), you will say “Ok the users processed the checkout, and I am Sure the payment went well because Stripe sent me the confirmation of the payment through the webhook… So at the second I receive the webhook, the users will be marked as subscribed and I will confirm him by email.”
You can set webhooks to listen to other events, and it is very powerfull. For example if you use subscription. Saying one users subscribes, and his credit cards expire 6 months later. I you set the right webhooks, Stripe will send you an event 6 months later to say “I can’t process this payment, because the customer credit cards is expired”, and you can automate workflows easily, for example -> When payment fails, change the user as unsubscribe, send him an email to come back and update his credit cards…
You have to create webhooks for every important actions and events. From my understanding this is key to the app health and security…
Hope it will helps you !