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

  1. Finds the WhatsApp Business account for the order's company
  2. Checks if order processing is enabled (shop.enable_order_processing)
  3. 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
  4. For cash/other orders: sends a simple text confirmation with order ID and total
  5. Payment link is stored in Order.metadata for status updates

Order Status Changed Flow

  1. Only processes orders from whatsapp source
  2. 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
  3. Tries to send via WhatsApp Flow (interactive), falls back to plain text
  4. Includes payment link for card orders in confirmed/processing status

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

Keywords

notifications, order status, whatsapp, order confirmed, order shipped, order delivered, payment link