Skip to content

createStripeVerifier

createStripeVerifier(stripe, webhookSecret): Verifier<Event>

Defined in: stripe/src/index.ts:416

Creates a Stripe webhook verifier function

This verifier handles Stripe signature verification using the stripe-signature header and returns the verified Stripe event.

Stripe

Pre-configured Stripe instance

string

Stripe webhook secret (starts with ‘whsec_‘)

Verifier<Event>

A Verifier function compatible with all Kotodayori adapters

import Stripe from 'stripe';
import { createStripeVerifier, StripeWebhookRouter } from '@kotodayori/stripe';
import { honoAdapter } from '@kotodayori/hono';
const stripe = new Stripe(process.env.STRIPE_API_KEY!);
const router = new StripeWebhookRouter();
// With Hono
app.post('/webhook', honoAdapter(router, {
verifier: createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!),
}));
// With Express
app.post('/webhook',
express.raw({ type: 'application/json' }),
expressAdapter(router, {
verifier: createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!),
})
);
// With Lambda
export const handler = lambdaAdapter(router, {
verifier: createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!),
});