Order Notifications
Send WhatsApp notifications to customers when orders are created or their status changes.
Overview
The SendOrderNotification listener automatically sends WhatsApp messages to customers at key points in the order lifecycle — when an order is placed and when its status is updated.
SendOrderNotification
File: app/Modules/Commerce/Listeners/SendOrderNotification.php
This listener subscribes to OrderCreated and OrderStatusChanged events and sends WhatsApp messages to the customer.
Events Handled
| Event | Method | Description |
|---|---|---|
OrderCreated |
handleOrderCreated() |
Sends order confirmation with optional payment link |
OrderStatusChanged |
handleOrderStatusChanged() |
Sends status update with emoji and details |
Order Created Flow
- Finds the WhatsApp Business account for the order's company
- Checks if order processing is enabled (
shop.enable_order_processing) - For card payment orders:
- Generates a Paystack payment link via
PaymentService::generateOrderPaymentLink() - Looks up vendor's Paystack subaccount for payment splitting
- Calculates Nviti platform fee and passes as
transaction_charge - Shortens the payment URL
- Sends a CTA URL interactive message with a "Pay Now" button
- Falls back to plain text with payment link if interactive fails
- Generates a Paystack payment link via
- For cash/other orders: sends a simple text confirmation with order ID and total
- Payment link is stored in
Order.metadatafor status updates
Order Status Changed Flow
- Only processes orders from
whatsappsource - Generates a status summary with appropriate emoji:
- 🔄 Processing — "We are preparing your order now."
- ✅ Confirmed
- 🚚 Shipped — "Your order is on its way!"
- 📦 Delivered — "Thank you for shopping with us!"
- ❌ Cancelled
- 💸 Refunded
- Tries to send via WhatsApp Flow (interactive), falls back to plain text
- Includes payment link for card orders in
confirmed/processingstatus
Status Summary Format
The buildStatusSummary method generates messages like:
📦 *Order Update*
Order #ORD-ABC123
Status: *Delivered*
Your order has been delivered! 📦
Thank you for shopping with us! 🙏
Total: ₦15,500.00
See Also
- Payment Processing
- Checkout Flow
- Test file:
tests/Feature/Modules/Commerce/SendOrderNotificationTest.php
Keywords
notifications, order status, whatsapp, order confirmed, order shipped, order delivered, payment link