Skip to content

Notifications System

Order state change
Event dispatcher
├── Email channel (Postmark/SMTP)
├── Webhook channel (HTTP POST)
├── SMS channel (Twilio)
└── Analytics channel
pub struct NotificationService {
email_channel: EmailChannel,
sms_channel: SmsChannel,
webhook_channel: WebhookChannel,
db: Database,
}
[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 = 465
smtp_user = "user@example.com"
smtp_pass = "password"
smtp_tls = true

HTML templates with brand styling:

  • order_confirmation.html — order confirmed
  • order_shipped.html — fulfillment created
  • password_reset.html — password reset link
  • welcome.html — new account

Templates use {{ variable }} substitution.

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.

EventTrigger
order.createdOrder placed
order.paidPayment confirmed
order.shippedFulfillment created
order.completedOrder marked complete
order.cancelledOrder cancelled
order.refundedRefund processed
payment.succeededPayment confirmed
payment.failedPayment declined
product.createdProduct added
product.updatedProduct modified
customer.createdCustomer registered