@kissandcode/stripe-utils
v0.0.4
Published
## Nest utility
Downloads
4
Readme
Stripe utilities
Nest utility
First we need to use raw body on bootstrap of main.ts
async function bootstrap() {
const app = await NestFactory.create(AppModule, { rawBody: true });
// More things...
}
import { Controller, Post, Body, Req, RawBodyRequest } from '@nestjs/common';
import {
get_stripe_event_from_nest_express_request,
set_stripe_key,
set_stripe_webhook_secret,
} from 'libs/stripe-utils/src';
set_stripe_key('sk_key');
set_stripe_webhook_secret('webhook_secret');
@Controller('stripe-weebhooks')
export class StripeWeebhooksController {
constructor() {}
@Post()
stripe_webhook(@Req() req: RawBodyRequest<Request>) {
const event = get_stripe_event_from_nest_express_request(req);
// DO SOMETHING
return { msg: 'ok' };
}
}