Skip to content

@kotodayori/stripe

The Stripe package extends the core router with Stripe-specific types and provides a signature verifier for Stripe webhooks.

Terminal window
pnpm add @kotodayori/stripe stripe
ExportDescription
StripeWebhookRouterRouter with full Stripe event type inference
StripeEventMapType map of 351+ Stripe event types
createStripeVerifier(stripe, secret)Factory for Stripe signature verification
Re-exports from @kotodayori/coreWebhookRouter, WebhookEvent, Verifier, etc.

Event names are autocompleted and validated; the handler receives the correct Stripe event type:

import { StripeWebhookRouter } from '@kotodayori/stripe';
const router = new StripeWebhookRouter();
router.on('payment_intent.succeeded', async (event) => {
// event is Stripe.PaymentIntentSucceededEvent
const amount = event.data.object.amount;
const currency = event.data.object.currency;
});
router.on('customer.subscription.created', async (event) => {
// event is Stripe.CustomerSubscriptionCreatedEvent
const customerId = event.data.object.customer;
});

Use createStripeVerifier with your Stripe instance and webhook signing secret:

import Stripe from 'stripe';
import { createStripeVerifier } from '@kotodayori/stripe';
const stripe = new Stripe(process.env.STRIPE_API_KEY!);
const verifier = createStripeVerifier(stripe, process.env.STRIPE_WEBHOOK_SECRET!);
// Pass verifier to your adapter (e.g. honoAdapter(router, { verifier }))

The verifier validates the Stripe-Signature header and returns the parsed event. Never parse the webhook body before verification.

StripeEventMap is manually maintained and covers 351+ event types across categories such as:

  • account.*, charge.*, checkout.session.*, customer.*
  • invoice.*, payment_intent.*, subscription.*, and more

See the Stripe Events API for the full list. When the Stripe SDK is updated, run pnpm run check-events in the stripe package to detect missing or obsolete events.