0:00 All right, so in this lecture, let's head back to our payment controller 0:04 and into our webhook controller route, where now we actually 0:08 want to respond to this webhook event properly. 0:13 So at this point, we have the event, we have verified it, and we actually 0:16 have its details, and now we can do something with this. 0:21 So what we can do here is introduce a switch statement on the 0:24 event object, and then on the event object, 0:27 we have the type 0:28 property, which is gonna be the type of webhook 0:32 event 0:32 that is actually sent to the server. 0:35 Now, I'll leave a link below to the Stripe docs 0:37 here, where you can 0:38 actually see all of the different kind of events that Stripe will emit 0:43 t- through webhooks. Now, there's a ton of different events that 0:47 we can react to depending on what's going on with our Stripe 0:50 implementation. In our case, really the only event that we 0:54 want is the 0:55 checkout.session.completed. 0:59 This occurs when a checkout session has been successfully completed. 1:03 That means we have successfully paid for our 1:06 product and have completed the checkout process, and then and 1:10 only then do we want to react to this and update our application 1:14 state accordingly. 1:17 So inside of the switch statement, we can now do a case for 1:20 checkout.session.completed, and 1:24 we're using a switch statement here because there might be other events you 1:28 want to 1:28 listen for. In our case, this is going to be enough to 1:32 do what we need to do. 1:34 Now, the first thing we wanna do is create a const and get access to the 1:38 session object. This will be on the 1:40 event.data.object. 1:44 Now, you can see here on the checkout session 1:47 completed 1:47 data.object, which corresponds to data.object 1:51 here. 1:52 If you click on this, it actually will link you to what the
The rest of the transcript is for members.
Sign in