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.

Approve and update order

Approve and update order

So, we created the create PayPal order action in the last video, which calls this create order from the PayPal TS file, right, so it calls this. Now we want to create an approved PayPal order action, and that's what is going to call the capture payment. So it'll make a request to PayPal with that order ID, and once approved, that it'll give us a status of completed, okay? And when we have our PayPal buttons in the front end, we plug both of these actions into it. So let's go back into order actions down to the very bottom here and we're going to add our approve. Let's say this is going to approve PayPal order and update order to paid because it's our responsibility to do that, because in our database, we have this is paid, which is set to false. So we want to make sure after it goes through and it's approved and it's paid that we update that to true and add the current date and time into paid at. Also, the payment result, this right here, this object, will have the status completed…

Contents