Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.

Latest commit

 

History

History
77 lines (60 loc) · 2.25 KB

File metadata and controls

77 lines (60 loc) · 2.25 KB

@paymesh/fastify

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


Installation

npm install paymesh @paymesh/fastify fastify

Usage

Fastify 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);
    },
  }),
);

Available Hooks

@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.

Why Use It

@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.