From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Webhook to mark order as paid

Webhook to mark order as paid

All right, guys, so now we're going to create a webhook. So a webhook is a way for a service to notify another service when something happens. And in our case, we want to notify our application when a payment is made through Stripe so that we can mark it as paid. Because right now, if we go through and pay for something with Stripe, it does make the payment. And we can see it in our Stripe dashboard. But in our database, our orders, anything paid with Stripe, the is paid is still going to be false and paid at is still going to be null. So our webhook is going to basically just let our app know that the Stripe payment went through so we can then update our order to paid. Now this is only going to be for the production version of the website because the webhook needs to be able to hit an endpoint of our website. And obviously, our local host, our development site, isn't accessible to the outside world. So this will be on our production site, which is where it matters, because that's…

Contents