Merge branch 'fix/cancelledpurchase' into feature/tickets_adminapp
This commit is contained in:
@@ -43,6 +43,11 @@ class ReleaseCheckoutService
|
||||
): Purchase {
|
||||
$purchase = $this->lockPurchase($purchase);
|
||||
|
||||
if ($purchase->status === Purchase::STATUS_EXPIRED
|
||||
&& $targetStatus === Purchase::STATUS_CANCELLED) {
|
||||
return $this->loadPurchase($purchase);
|
||||
}
|
||||
|
||||
if ($purchase->status === Purchase::STATUS_EXPIRED
|
||||
&& $targetStatus !== Purchase::STATUS_EXPIRED) {
|
||||
throw new PurchaseExpiredException;
|
||||
@@ -72,6 +77,14 @@ class ReleaseCheckoutService
|
||||
|
||||
$cart = $purchase->cart()->withTrashed()->lockForUpdate()->first();
|
||||
|
||||
// Leaving checkout is allowed at the exact instant the reservation
|
||||
// expires. Finish the expiration while holding the purchase lock so
|
||||
// the request is idempotent with the scheduled expiration job.
|
||||
if ($targetStatus === Purchase::STATUS_CANCELLED
|
||||
&& $this->hasOverdueActiveReservation($purchase)) {
|
||||
$targetStatus = Purchase::STATUS_EXPIRED;
|
||||
}
|
||||
|
||||
if ($targetStatus === Purchase::STATUS_CANCELLED
|
||||
&& $cart?->status === 'active'
|
||||
&& in_array($purchase->status, [
|
||||
|
||||
Reference in New Issue
Block a user