Fix: Marking orded placed and setting order as awaiting payment when payment is bank transfer

This commit is contained in:
2026-09-28 17:10:57 +03:00
parent 7f2ddea240
commit d189a7559a
2 changed files with 35 additions and 16 deletions
@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Event;
use Lunar\Models\Order;
use Modules\Core\Checkout\Events\OrderPlaced;
use Modules\Core\Order\Services\OrderPaymentResolutionService;
use Modules\Core\Order\Services\OrderStatusFlow;
use Modules\Core\Payment\Events\PaymentDeferred;
/**
@@ -36,11 +37,18 @@ use Modules\Core\Payment\Events\PaymentDeferred;
* visibility and stock decrement, but nothing ever moved `status` off its
* initial value, since resolveCaptureOrAuthorization() only does that for
* an actual capture. Caught and fixed after the fact.
*
* The status advance is skipped for a bank transfer order
* (OrderStatusFlow::isBankTransfer()) — unlike COD, it genuinely has
* something to await at 'awaiting_payment': the wire itself. Only
* OrderFulfillmentService::markPaid() ever advances it past that point
* (see BankTransferPaymentDriver's own docblock).
*/
class MarkOrderPlacedOnDeferredPayment
{
public function __construct(
private readonly OrderPaymentResolutionService $resolution,
private readonly OrderStatusFlow $flow,
) {}
public function handle(PaymentDeferred $event): void
@@ -53,7 +61,9 @@ class MarkOrderPlacedOnDeferredPayment
$order = Order::findOrFail($orderId);
$this->resolution->resolveDeferredPayment($order, self::class);
if (! $this->flow->isBankTransfer($order)) {
$this->resolution->resolveDeferredPayment($order, self::class);
}
if (! blank($order->placed_at)) {
return;