stripe-webhook-handler
v1.1.0
Published
A dedicated utility to verify and process incoming Stripe webhook events securely and asynchronously.
Maintainers
Readme
stripe-webhook-handler
stripe-webhook-handler verifies Stripe-style webhook signatures and dispatches events to typed handlers.
Installation
npm install stripe-webhook-handlerFeatures
- verifies
Stripe-Signaturestyle headers - validates signature age
- dispatches events by type
- works with Express-style handlers
Usage
const { createStripeWebhookHandler } = require('stripe-webhook-handler');
const webhookHandler = createStripeWebhookHandler({
secret: process.env.STRIPE_WEBHOOK_SECRET,
handlers: {
'checkout.session.completed': async (event) => {
console.log('payment completed', event.id);
},
},
});API
createStripeWebhookHandler(options)constructStripeEvent(payload, signatureHeader, secret, toleranceSeconds?)parseSignatureHeader(header)extractPayload(body)StripeWebhookError
License
MIT
