#Zakariya-webhook

1 messages · Page 1 of 1 (latest)

crimson cliff
#

Hi! What do you mean by "send webhook to success page"?

#

Webhook are just a way for you to listen to Stripe events.

light trail
#

I mean is there any way with which I can send the webhooks to the success page and use the required info in it so that I can create an order in my MongoDB

#

if not then what is the other way around

crimson cliff
#

I don't quite understand. Usually things look like this:

  • Your users enter their payment information and submit a form. They are redirected to a success page.
  • In parallel, a webhook event is sent to your backend server, where you will process the order (like create an order in your MongoDB database)
light trail
#

yes I just want to understand that how can I send webhook info which holds the "payment_intent" need to be sent to the success page so that I can use and create a post request to my /order route to create an order in my DB

crimson cliff
#

Why don't you create the order in your webhook directly?

light trail
#

And how can I do that? for mongoDB

gaunt cape
#

Hi there 👋 you can send webhook events to any URL that you want, this is specified when you create your Webhook Endpoint.

light trail
#

Any doc to refer to?

gaunt cape
light trail
#

this end point is a backend url but the success page is on the frontend. So how can I send this webhook to the success page which is on the frontend not on the server side

gaunt cape
#

Chances are you can't, but you also likely don't want to rely on your frontend to handle business logic. What if a customer places an order, and then immediately closes their browser or loses internet connection? You'd charge them, but then their order wouldn't be processed/sent to your database. These actions are better suited to be handled by a backend server.

light trail
#

Understood,
Can you please provide an example like how to use this webhook event to create an order in my backend for mongodb?

#

This is the order schema, previously I was making a post request to" /order" route and passing these but now I don't know how to pass these from the backend itself

gaunt cape
#

Sorry, but that's going to depend largely on how your environment is setup and we won't have the insight to give a ton of advice. The high level of the flow is that you need to configure an endpoint on your backend server to receive the events, and then the server needs to have event handling code that sends any necessary information to your database.

light trail
#

alright I'll figure it out.