components/api/checkout/route.tsx
import paypal from "@paypal/checkout-server-sdk"
import { NextResponse } from "next/server"
const clientId = "---"
const clientSecret = "---"
const environment = new paypal.core.SandboxEnvironment(clientId, clientSecret)
const client = new paypal.core.PayPalHttpClient(environment)
export async function POST() {
const request = new paypal.orders.OrdersCreateRequest();
request.requestBody({
intent: "CAPTURE",
purchase_units: [
{
amount: {
currency_code: "USD",
value: "10.00",
breakdown: {
item_total: {
currency_code: "USD",
value: "10.00"
},
shipping_discount: {
currency_code: "USD",
value: "0.00"
},
discount: {
currency_code: "USD",
value: "0.00"
},
tax_total: {
currency_code: "USD",
value: "0.00"
},
shipping: {
currency_code: "USD",
value: "0.00"
},
handling: {
currency_code: "USD",
value: "0.00"
},
insurance: {
currency_code: "USD",
value: "0.00"
},
}
},```