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.

Sending emails

Sending emails

All right guys, so the last thing to do is to actually send the e-mail which is pretty simple There's a few lines of code. We basically just need to call this function send purchase receipt Now where we want to call this is going to be in the order actions file So lib actions order dot actions and we want to go to update order to paid. That's the function We want to send the e-mail in Okay, because we want to send it when when it's actually paid for so this right here Okay, so let's come down all the way to the bottom of the function Let's see. Where does it end? So we have the transaction Then we have Get the order after and then checking if the order is not there So we're gonna go to the very end which is under the if not updated order. So from here, we're gonna call send purchase receipt, right and I'm gonna bring that in from at slash e-mail and And we need to pass into that the order or an object with the order. But we have a type for shipping address and payment result. So what…

Contents