If you are using Next JS Route Handler / Pages then just use req.text() for payload.
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { NextResponse } from "next/server"
import Stripe from "stripe"
const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET_KEY
// import { db } from "../firebase"
import { headers } from "next/headers"
export const config = { api: { bodyParser: false } }
export async function POST(req, res) {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
const sig = (await headers()).get("stripe-signature")
const payload = await req.text()