Fastify-native webhook handling for Paymesh.
Keep Fastify performance characteristics and developer ergonomics while delegating payment webhook verification and event normalization to Paymesh.
Installation · Usage · Available hooks · Why use it
npm install paymesh @paymesh/fastify fastifyFastify integrations should preserve the raw request body for webhook routes so signature verification can run against the exact incoming payload.
import Fastify from "fastify";
import { Webhooks } from "@paymesh/fastify";
import { paymesh } from "./paymesh";
const app = Fastify();
app.post(
"/webhooks/stripe",
{
config: {
rawBody: true,
},
},
Webhooks({
client: paymesh,
async onEvent(event) {
console.log(event.type);
},
async onCheckoutCompleted(event) {
console.log(event.data.id);
},
async onPaymentSucceeded(event) {
console.log(event.data.id);
},
}),
);
@paymesh/fastify supports the same built-in hooks as Paymesh itself: onEvent, onUnhandledEvent, onPaymentCreated, onPaymentSucceeded, onPaymentFailed, onPaymentCanceled, onPaymentRefunded, onCustomerCreated, onCustomerUpdated, onCustomerDeleted, onSubscriptionCreated, onSubscriptionUpdated, onSubscriptionCanceled, and onCheckoutCompleted.
@paymesh/fastify gives Fastify services a thin, typed integration layer over the Paymesh webhook engine. It preserves the runtime you already want while removing repetitive provider-specific verification code.
That keeps your billing endpoints fast and your implementation compact.