#Zetsuman

1 messages · Page 1 of 1 (latest)

slow quailBOT
indigo sphinx
#

hi! what's your exact question?

rough fractal
#

I'm using this API
return this.stripe.webhooks.constructEvent( payload, signature, webhookSecret, );

Should I use it if I already have body in request object?

indigo sphinx
#

not sure what "already have body in request object" means

#

I'd suggest reading the docs linked in the error message!

#

and/or share your full code here. And check the reply someone else posted to you in the main channel.

raw sentinel
#

If you are using expressjs you either have an expressjson middleware or body parser middleware, you need to disable the middleware for the stripe webhook route or pass in an object in there that creates a new variable on the request that you can use

rough fractal
#

I'm using Nest JS
where I can attach code parts?

raw sentinel
#

It depends on your code structure but look for a json middleware for nextjs- you should be able to modify the request where you can add additional property to the request object like rawBody (which is the buffer stripe is expecting) that you would be able to use

#

Or depending on how your controllers are setup in nestjs- you may be able to disable there parsing for that request

rough fractal
#

Give me a minute, i'll create codesanbox

raw sentinel
#

raw-body.middleware.ts

import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response } from 'express';
import * as bodyParser from 'body-parser';

@Injectable()
export class RawBodyMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: () => any) {
bodyParser.raw({type: '/'})(req, res, next);
}
}