Webhook configuration
Express request handler
import express from 'express';
import { createExpressWebhookHandler } from '@bates-solutions/stripe/server';
const app = express();
// IMPORTANT: use the raw body parser for the webhook route
app.use('/webhook', express.raw({ type: 'application/json' }));
app.post('/webhook', createExpressWebhookHandler({
signingSecret: process.env.STRIPE_WEBHOOK_SECRET!,
handlers: {
'payment_intent.succeeded': async (event) => {
console.log('Paid:', event.data.object.id);
},
},
}));
Create Express middleware for handling Stripe webhooks.
This middleware: