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.

Create PayPal order action

Create PayPal order action

OK, so we know that the PayPal API functions are working. We ran some unit tests to make sure of that. Now we want to integrate those into our application. And those are going to be called in a few different actions that we're going to create. Now, before we add those actions, I want to just add a Zod schema and a type for the payment result. So when we get data back from PayPal, it's going to go in this field right here, this payment result object, which will have an ID that will come back from PayPal, a status, an email address, and the price paid. All right, so let's create a new schema in lib validators. So we want a Zod schema here. Let's say export and const payment result schema. And we're going to set that to z.object. And then let's pass in those fields that I just mentioned, the ID. And these are all going to be strings, so z.string. We're going to have four fields. Second one is going to be the status. And the status, when everything is paid and approved, that will be set…

Contents