OrderStockCoverage
in package
Is the order covered by a stock reservation when its payment is created or arrives? Pure decisions without I/O; the caller ({@see \App\UI\Api\Eshop\Models\Managers\EshopPaymentHook}) reads the inputs from the DB and acts on the answer.
The Store reservation expires on its own (ReservationExpirer, default 72 h) while the order
stays payable in WAITING-ON-PAYMENT, so a late payment may meet stock already sold to
somebody else. Only an order that once held a reservation is re-checked: NONE means the
order never reserved anything on purpose (no stock card, or the shop sells out of stock),
CONFIRMED means the goods have already left the warehouse.
Table of Contents
Constants
- HELD : string = 'held'
- Active reservation within its window — nothing to do.
- NOT_TRACKED : string = 'notTracked'
- Nothing to hold (`NONE` / `CONFIRMED`) — payment may proceed.
- RENEW : string = 'renew'
- Reservation lapsed or was released — it has to be renewed before the order counts as paid.
Methods
- allowPartialForRenewal() : bool
- A partial reservation was an accepted decision (admin or out-of-stock selling), so its renewal may stay partial; a full one is renewed strictly unless the shop sells out of stock.
- checkoutMustWithdraw() : bool
- Checkout: a reservation that failed after commit leaves the order uncovered.
- decide() : string
Constants
HELD
Active reservation within its window — nothing to do.
public
string
HELD
= 'held'
NOT_TRACKED
Nothing to hold (`NONE` / `CONFIRMED`) — payment may proceed.
public
string
NOT_TRACKED
= 'notTracked'
RENEW
Reservation lapsed or was released — it has to be renewed before the order counts as paid.
public
string
RENEW
= 'renew'
Methods
allowPartialForRenewal()
A partial reservation was an accepted decision (admin or out-of-stock selling), so its renewal may stay partial; a full one is renewed strictly unless the shop sells out of stock.
public
static allowPartialForRenewal(string $stockState, bool $allowOutOfStock) : bool
Parameters
- $stockState : string
- $allowOutOfStock : bool
Return values
boolcheckoutMustWithdraw()
Checkout: a reservation that failed after commit leaves the order uncovered.
public
static checkoutMustWithdraw(bool $reservationFailed, bool $allowOutOfStock) : bool
Unless the shop sells out of stock (then an unreserved order is legitimate), the order must be withdrawn before any gateway payment exists.
Parameters
- $reservationFailed : bool
- $allowOutOfStock : bool
Return values
booldecide()
public
static decide(string $stockState, bool $hasActiveReservation, bool $windowLapsed) : string
Parameters
- $stockState : string
- $hasActiveReservation : bool
- $windowLapsed : bool