Express Stripe Webhook Middleware

A TypeScript library that simplifies Stripe webhook integration in Express applications by automating signature verification. Provides secure implementation and type safety with just a few lines of code.

Key Features

Installation

npm install express-stripe-webhook-middleware stripe express

Quick Start (TypeScript)

import Stripe from 'stripe';
import express from 'express';
import { createStripeWebhookMiddleware } from 'express-stripe-webhook-middleware';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const app = express();

app.post(
  '/webhook',
  ...createStripeWebhookMiddleware(process.env.STRIPE_WEBHOOK_SECRET!, stripe),
  (req, res) => {
    const event = req.body as Stripe.Event;
    // Handle the event
    res.json({ received: true });
  }
);

app.listen(4242, () => console.log('Server running on port 4242'));

Benefits

Without this package, developers must manually configure body parsing and implement signature verification logic. This middleware abstracts that complexity into a single function call, reducing boilerplate code significantly while maintaining security standards.

Tags

ExpressStripeWebhookTypeScriptnpm

License

MIT