Notifications System
Architecture
Section titled “Architecture”Order state change ↓Event dispatcher ├── Email channel (Postmark/SMTP) ├── Webhook channel (HTTP POST) ├── SMS channel (Twilio) └── Analytics channelNotification service
Section titled “Notification service”pub struct NotificationService { email_channel: EmailChannel, sms_channel: SmsChannel, webhook_channel: WebhookChannel, db: Database,}Postmark
Section titled “Postmark”[notifications.email]postmark_token = "your-server-token"from_email = "shop@example.com"from_name = "Your Store"[notifications.email]smtp_host = "smtp.example.com"smtp_port = 465smtp_user = "user@example.com"smtp_pass = "password"smtp_tls = trueTemplates
Section titled “Templates”HTML templates with brand styling:
order_confirmation.html— order confirmedorder_shipped.html— fulfillment createdpassword_reset.html— password reset linkwelcome.html— new account
Templates use {{ variable }} substitution.
Webhooks
Section titled “Webhooks”Events are dispatched to registered webhook URLs:
{ "event": "order.paid", "timestamp": "2024-01-01T12:00:00Z", "data": { "order_id": "uuid", "total": 150.00 }}Signed with HMAC-SHA256. Failed webhooks retried with exponential backoff.
Event types
Section titled “Event types”| Event | Trigger |
|---|---|
order.created | Order placed |
order.paid | Payment confirmed |
order.shipped | Fulfillment created |
order.completed | Order marked complete |
order.cancelled | Order cancelled |
order.refunded | Refund processed |
payment.succeeded | Payment confirmed |
payment.failed | Payment declined |
product.created | Product added |
product.updated | Product modified |
customer.created | Customer registered |