Notification
ShipSaaS supports sending notifications when a user successfully completes a purchase, allowing your team to receive real-time order alerts in your preferred workspace tools.
Currently, two notification channels are supported: Discord and Feishu. You can add more notification channels by implementing the NotificationProvider interface.
Enable Notification Channel
Section titled “Enable Notification Channel”Enable the notification feature in src/config/website.ts and configure the channel to receive messages:
src/config/website.ts
export const websiteConfig: WebsiteConfig = { // ...other config notification: { enable: true, provider: 'discord', // or 'feishu' }, // ...other config}Configure Webhook URL
Section titled “Configure Webhook URL”Based on your chosen notification channel, configure the corresponding Webhook URL:
Discord
Section titled “Discord”- Open your Discord server and navigate to the channel where you want to receive notifications.
- Click the gear icon to open
Channel Settings. - Select
Integrations>Webhooks>New Webhook. - Set a name and an avatar for the Webhook (optional).
- Copy the
Webhook URLand add it to your environment variable file:
.env
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."Feishu
Section titled “Feishu”- Enter your Feishu group chat.
- Click the group name >
Group Settings>Bot Management. - Add a new
Custom Botand enableWebhooks. - Copy the generated
Webhook URLand add it to your environment variable file:
.env
FEISHU_WEBHOOK_URL="https://open.feishu.cn/open-apis/bot/v2/hook/..."If you are setting up your environment, you can now return to the Environment Configuration document and continue. The remainder of this document can be read later.
Environment configuration set environment variables
Notification Message Examples
Section titled “Notification Message Examples”Discord
Section titled “Discord”Discord notifications are sent as rich messages with green colors and structured fields for high readability.
Feishu
Section titled “Feishu”Feishu notifications are sent as plain-text messages with all purchase details displayed clearly.
Extending New Notification Channels
Section titled “Extending New Notification Channels”ShipSaaS supports extending and integrating new notification channels:
- Create a new file in the
src/notification/providerdirectory (e.g.,slack.ts). - Implement the
NotificationProviderinterface:
src/notification/provider/slack.ts
import type { NotificationProvider, SendPaymentNotificationParams,} from '../types';
export class SlackProvider implements NotificationProvider { private webhookUrl: string;
constructor() { const webhookUrl = process.env.SLACK_WEBHOOK_URL; if (!webhookUrl) throw new Error('SLACK_WEBHOOK_URL is required.'); this.webhookUrl = webhookUrl; }
getProviderName(): string { return 'slack'; }
async sendPaymentNotification( params: SendPaymentNotificationParams ): Promise<void> { const { sessionId, customerId, userName, amount } = params; try { // Your Slack message implementation await fetch(this.webhookUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: `🎉 New Purchase\nUsername: ${userName}\nAmount: $${amount.toFixed(2)}`, }), }); } catch (error) { console.error('Failed to send Slack notification:', error); } }}- Register the new notification channel in the
providerRegistryinsrc/notification/index.ts:
src/notification/index.ts
import { SlackProvider } from './provider/slack';
const providerRegistry: Record<NotificationProviderName, ProviderFactory> = { discord: () => new DiscordProvider(), feishu: () => new FeishuProvider(), slack: () => new SlackProvider(),};- Choose your new notification channel in
websiteConfig:
src/config/website.ts
notification: { enable: true, provider: 'slack',},References
Section titled “References”Next Steps
Section titled “Next Steps”Now that you know how to use notifications in ShipSaaS, explore these related topics:
-
Email - Configure email service
-
Authentication - Configure user authentication
-
Analytics - Configure analytics services
-
Storage - Configure storage services