Chore: Updates to Notifications

This commit is contained in:
2026-09-28 23:54:24 +03:00
parent 76b807d672
commit 57d7a716bc
11 changed files with 75 additions and 0 deletions
@@ -7,8 +7,23 @@ use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Notification as NotificationFacade;
use Modules\Core\Notification\BaseNotification;
use Modules\Core\Order\Events\OrderCaptured;
use Modules\Core\Order\Services\OrderStatusFlow;
use Modules\Core\Order\Support\OrderReferenceDisplay;
/**
* "Payment captured" is only a meaningful, distinct update for a bank
* transfer order — placing that order and paying for it are genuinely two
* separate moments (Order::paid stays false at checkout; a shopper is
* told their order is confirmed and awaiting a wire, then separately told
* once staff mark it paid). For every other payment method (card,
* authorize-then-capture, COD), placing the order already means the
* shopper did everything they need to on their end — a card payment is
* captured in the very same request that places the order, so a second
* "payment captured" email would just repeat what OrderPlacedNotification
* already said. See OrderStatusFlow's own docblock for why payment method
* never affects the order's status SEQUENCE, only this kind of business
* decision about which events actually matter to the shopper.
*/
class OrderCapturedNotification extends BaseNotification
{
public function __construct(private readonly OrderCaptured $event) {}
@@ -25,6 +40,10 @@ class OrderCapturedNotification extends BaseNotification
public function via(object $notifiable): array
{
if (! app(OrderStatusFlow::class)->isBankTransfer($this->event->order)) {
return [];
}
return ['mail'];
}
@@ -46,6 +65,7 @@ class OrderCapturedNotification extends BaseNotification
return (new MailMessage)
->subject(__('Payment captured for your order :reference', ['reference' => $reference]))
->view('core::order.notifications.captured', [
'order' => $order,
'reference' => $reference,
'amount' => $this->event->transaction->amount->formatted,
]);
@@ -46,6 +46,7 @@ class OrderCompletedNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference is complete', ['reference' => $reference]))
->view('core::order.notifications.completed', [
'order' => $order,
'reference' => $reference,
]);
}
@@ -46,6 +46,7 @@ class OrderDeliveredNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference has been delivered', ['reference' => $reference]))
->view('core::order.notifications.delivered', [
'order' => $order,
'reference' => $reference,
]);
}
@@ -51,6 +51,7 @@ class OrderDispatchedNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference is on its way', ['reference' => $reference]))
->view('core::order.notifications.dispatched', [
'order' => $order,
'reference' => $reference,
]);
}
@@ -56,6 +56,7 @@ class OrderPickupReadyNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference is ready for pickup', ['reference' => $reference]))
->view('core::order.notifications.pickup-ready', [
'order' => $order,
'reference' => $reference,
]);
}
@@ -57,6 +57,7 @@ class OrderPlacedNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference is confirmed', ['reference' => $reference]))
->view('core::order.notifications.placed', [
'order' => $order,
'reference' => $reference,
'total' => $order->total->formatted,
'lines' => $order->lines,
@@ -46,6 +46,7 @@ class OrderRefundedNotification extends BaseNotification
return (new MailMessage)
->subject(__('A refund has been issued for your order :reference', ['reference' => $reference]))
->view('core::order.notifications.refunded', [
'order' => $order,
'reference' => $reference,
'amount' => $this->event->transaction->amount->formatted,
]);
@@ -58,6 +58,7 @@ class OrderStatusUpdatedNotification extends BaseNotification
return (new MailMessage)
->subject(__('Your order :reference has been updated', ['reference' => $reference]))
->view('core::order.notifications.status-updated', [
'order' => $order,
'reference' => $reference,
'statusLabel' => config("lunar.orders.statuses.{$order->status}.label", $order->status),
]);