---
title: "Verify checkout handles stock exhausted before payment completion"
description: "Remove the last fixture unit after checkout begins and verify the product prevents an unsupported purchase or clearly applies its documented backorder policy."
canonical_url: "https://vostride.com/agent-library/checkout-payments/inventory-sold-out-at-submit.md"
md_url: "https://vostride.com/agent-library/checkout-payments/inventory-sold-out-at-submit.md"
content_kind: "recipe"
topic: "checkout-payments"
---

# Verify checkout handles stock exhausted before payment completion

Remove the last fixture unit after checkout begins and verify the product prevents an unsupported purchase or clearly applies its documented backorder policy.

## Risk

Inventory displayed when checkout opens may be stale by submission. The test checks the actual reservation boundary and payment result together, because declining an order after collecting funds can still require an explicit reversal workflow.

## Fixtures

- A sandbox product with exactly one available unit and backordering disabled for this recipe.
- A supported inventory fixture that consumes that unit after the test reaches final review.
- Hooks for reservation state, order state, and payment authorization or reversal outcomes.

## Steps

1. Add the last available unit and open final checkout review; verify quantity one and the expected total.
2. Use the fixture to consume the remaining available stock, then verify the inventory hook reports zero before submitting payment.
3. Submit the checkout once and verify an out-of-stock explanation with a usable route to edit the cart.
4. Inspect order and payment records; verify no fulfillable paid order exists and any temporary authorization follows the documented void or reversal policy.
5. Restore one unit, return through the correction flow, and verify the customer can complete a new valid sandbox purchase without a stale reservation conflict.

## Expected results

- An unavailable unit cannot become a fulfillable order when backordering is disabled.
- Payment handling follows the explicit no-stock reversal or prevention contract.
- Restored stock enables a deliberate successful purchase without leaked reservations.

## False-pass traps

- An out-of-stock toast can coexist with a captured payment that still needs reversal.
- Changing visible stock text without changing reservation state fails to establish the intended race condition.

## Cleanup

- Cancel or refund the successful fixture order and restore the original stock level.

## Use with agent-qa

Adapt this test design to your application's acceptance criteria and configured target using the [recipe execution guide](/agent-library/software-factory/turn-a-recipe-into-an-agent-qa-test.md). External fixture setup and non-UI checks require your own supported hooks or test tooling. Validate the authored test, execute it, and inspect the completed evidence; this recipe is not a recorded test result.

## References

- [agent-qa test](/docs/agent-qa/configuration/test.md)
- [agent-qa hooks](/docs/agent-qa/guides/hooks.md)
- [agent-qa auth state](/docs/agent-qa/guides/auth-state.md)

- [Checkout and payment QA recipes](/agent-library/checkout-payments.md)
- [Software factory QA library](/agent-library.md)
