01Stock is held, not sold, until the customer pays
The obvious design takes the stock off at checkout and puts it back when the order is cancelled. That assumes someone cancels. A customer who opens the Midtrans page and walks away never triggers anything, and the stock stays gone for good.
So checkout doesn't touch the stock. Each item gets a reservation with an expiry time, one day by default, and the available stock is always the stock minus the reservations still active. When the admin confirms the payment, the stock is taken off and the reservation removed; a cancelled order just removes its reservation. If nobody does anything, the reservation expires and simply stops counting. Releasing the stock depends on the clock, not on a customer remembering to cancel.

Available stock is calculated on every read instead of being one stored number.

