refactor(checkout): keep source cart active

This commit is contained in:
2026-08-21 13:42:30 -03:00
parent 79e721ae63
commit 1650176aa0
10 changed files with 98 additions and 216 deletions

View File

@@ -274,13 +274,6 @@ class StartCheckoutService
);
}
// The purchase owns the reservation until checkout finishes. The cart is
// retained so it can be restored if the purchase is cancelled or expires.
$cart->update([
'status' => 'checkout',
'guest_token' => null,
]);
return $this->loadPurchase($purchase);
}
@@ -299,6 +292,14 @@ class StartCheckoutService
]);
}
if ($cart->purchases()
->whereIn('status', [Purchase::STATUS_CREATED, Purchase::STATUS_PENDING_PAYMENT])
->exists()) {
throw ValidationException::withMessages([
'cart_id' => __('api.purchase.checkout_in_progress'),
]);
}
return $cart;
}