STRIPE WEBHOOK INTEGRATION
Anonymous
PRO
7 months ago
Getting "No signatures found matching the expected signature for payload" on my NestJS app. Everthing works fine on local environment:
Code:
import { NestFactory } from '@nestjs/core';
import { config } from 'dotenv';
import { AppModule } from './app/app.module';
config();
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
rawBody: true,
});
app.enableCors();
await app.listen(process.env.PORT);
}
bootstrap();
@Controller('stripe')
export class StripeController {
private endpointSecret: string;
constructor(private readonly stripeService: StripeService) {
this.endpointSecret = process.env.STRIPE_WEBHOOK_SECRET;
}
@Post('webhook')
@HttpCode(201)
@Public()
async stripeWebhook(
@Headers('stripe-signature') sig: string,
@Request() request: any,
) {
try {
const event = this.stripeService.constructEvent(
request.rawBody,
sig,
this.endpointSecret,
);
await this.stripeService.handleWebhookEvent(event);
return { received: true };
} catch (error) {
Logger.error(error);
}
}
}
4 Replies
7 months ago
This is a Stripe API issue. Please review the Stripe API documentation: https://docs.stripe.com/webhooks/signature
Status changed to Awaiting User Response railway[bot] • 7 months ago
Anonymous
PRO
7 months ago
christian does Railway use a proxy by default that can modify a requet body?
Status changed to Awaiting Railway Response railway[bot] • 7 months ago
Status changed to Awaiting User Response railway[bot] • 7 months ago
denisk13005
FREE
2 months ago
have you solve the issue ? i got the same with express ?
Status changed to Awaiting Railway Response railway[bot] • 2 months ago