#1voy
1 messages · Page 1 of 1 (latest)
could this be a next13 error? i am also using the export const = { api: {bodyParser: false } }
not sure why you use buffer(request) here (Sorry not familiar with NextJS) but in most case if this value is different or modified somehow, it will fail the signature verification
The buffer is just from following this: https://www.youtube.com/watch?v=nVvDr6MyEXE
I am not sure what could be modified here, I am just testing it with the VSCode extension events
Learn how to get a Next.js app up and running, install the Stripe libraries, configure your application securely, and create a webhook endpoint and handler using Next.js and Stripe.
Presenter
Paul Asjes - Developer Advocate at Stripe - https://twitter.com/paul_asjes
Resources
Next.js: https://nextjs.org
Table of contents
00:00 In...
Ummm it looks similar to me. Could you paste here the full file code?
I tried some stuff out and now this happens:
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});
const signingSecret = process.env.STRIPE_SIGNING_SECRET;
const signature = req.headers['stripe-signature'];
const reqBuffer = await buffer(req); ```
```error TypeError: Cannot read properties of undefined (reading 'stripe-signature')```
import { buffer } from 'micro';
export const config = {
api: {
bodyParser: false,
},
};
export async function POST(request) {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2022-11-15',
});
const signingSecret = process.env.STRIPE_SIGNING_SECRET;
const signature = request.headers['stripe-signature'];
const reqBuffer = await buffer(request);
try {
stripe.webhooks.constructEvent(reqBuffer, signature, signingSecret);
} catch (error) {
return new Response('Error with stripe', {
status: 400,
});
}
console.log('event received');
NextResponse.json({ requestLog: req.json() });
}```