ShipNext

Add A Notification Provider

Add a new operational notification channel and enable business events.

Operational notifications are split between src/integrations/notify for third-party implementations and src/modules/notify for shared types, provider selection, and handlers. Built-in providers include Telegram, Discord, Slack, and Feishu.

Implement the provider

Create a file such as:

src/integrations/notify/webhook.ts

Implement NotifyProvider:

import type {
  NotifyPaymentData,
  NotifyProvider,
  NotifySubscriptionData,
  NotifyUser,
} from "@/modules/notify/types";

class WebhookProvider implements NotifyProvider {
  readonly name = "webhook";

  async onUserRegistered(user: NotifyUser) {
    // Call your third-party API.
  }

  async onUserSubscription(data: NotifySubscriptionData) {}

  async onUserPayment(data: NotifyPaymentData) {}
}

export default WebhookProvider;

Export the provider

export { default as WebhookProvider } from "./webhook";

Add it to the provider factory

import { WebhookProvider } from "@/integrations/notify";

export function getNotifyProvider(): NotifyProvider {
  switch (websiteConfig.notify.provider) {
    case "webhook":
      return new WebhookProvider();
  }
}

Configure website and env vars

const notifyConfig = {
  provider: "webhook",
  events: {
    userRegistered: true,
    userSubscription: true,
    userPayment: true,
  },
};

Document any required variables:

WEBHOOK_NOTIFY_URL=
WEBHOOK_NOTIFY_SECRET=

Enable business events

Handlers already exist:

notifyOnUserRegistered
notifyOnUserSubscription
notifyOnUserPayment

Import from:

"@/modules/notify/handler"

and call them from the desired auth or payment hook.

Notification failures should be caught and logged without interrupting registration, subscription, or payment flows.

On this page