Feat: Payment Restructuring to be fully event-driven

This commit is contained in:
2026-09-03 17:00:24 +03:00
parent a987a2d57c
commit 35c3334690
13 changed files with 698 additions and 185 deletions
@@ -0,0 +1,26 @@
<?php
namespace Modules\Core\Order\Listeners;
use Lunar\Models\Order;
use Modules\Core\Payment\Events\OrderPaymentStatusResolved;
/**
* The only place an Order's status column is written in reaction to a
* payment outcome — Payment dispatches OrderPaymentStatusResolved with
* what the status should become, never touching the Order model itself;
* this listener, living in Order's own module, is what applies it.
*
* Loads and saves the model (not a bulk ::whereKey()->update()) so
* Order::observe()'s updated() hook fires and OrderStatusUpdated goes out
* the same as any other status write — see that event's own docblock for
* why it's meant to fire "regardless of what wrote it."
*/
class ApplyResolvedPaymentStatus
{
public function handle(OrderPaymentStatusResolved $event): void
{
$order = Order::findOrFail($event->orderId);
$order->update(['status' => $event->status]);
}
}