Repository navigation
fix(shop): a late payment no longer eats another shopper's stock hold - #225
Merged
Merged
Conversation
Stock holds expire after 15 minutes, but a Beam QR is payable for 30 and a payment link for 60. When a customer paid after their hold had lapsed, markPaid committed the sale by decrementing `reserved` anyway — reserved that had already been given back, so it consumed another shopper's hold and left the books low. Orders weren't linked to their holds, so markPaid couldn't tell. - Migration 0035: shop_inventory_reservations.order_id (+ index). checkout/start links the holds it took to the order. - markPaid commits a linked hold that is still live as before (on_hand and reserved), and a lapsed one from on_hand only. Orders from before the migration keep the old path. - checkout/pay extends the order's live holds to the charge's payment window (QR 30 min, link 60), so stock stays held while the customer can still pay. Never shortens a hold or revives a lapsed one. - checkout/start refuses an empty cart up front with CART_EMPTY (#217) instead of failing later as INVALID_SHIPPING_METHOD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-link # Conflicts: # src/plugins/shop/cart-service.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2.4. Closes #217 (server-side
CART_EMPTYguard).Bug
Holds expire after 15 min; a Beam QR is payable for 30 and a payment link for 60. A payment after the hold lapsed still committed by decrementing
reserved, which had already been released, so it consumed another shopper's hold and left the counts low. Orders had no link to their holds, somarkPaidcouldn't tell.Fix
0035_reservation_order_link:shop_inventory_reservations.order_id+ index (nullable).0034is left for feat(analytics): visitor sources — referrer + UTM, aggregate-only #210.checkout/startlinks the holds it took to the new order.markPaid: a linked live hold commits as before (on_handandreserved); a linked lapsed hold deductson_handonly. Bundles are expanded to components. Unlinked (pre-migration) orders keep the old path.checkout/payextends the order's live holds to the payment window (QR 30 min / link 60 min). It never shortens a hold or revives a lapsed one.checkout/startreturns400 CART_EMPTYup front (Checkout: retrying after a failed payment re-runs checkout/start against an empty cart #217). Previously the empty cart was priced first and failed asINVALID_SHIPPING_METHOD.Tests
4 integration tests (real migrations, SQLite): holds linked to the order; paid while held →
100/1 → 99/0; paid after lapse with another shopper holding 2 →99/2(was99/1); extension survives the 20-min sweep and never shortens.Gate: lint 0 errors · check 0 · 1165/1165 · build · contract-guard · css-inventory.
0035applied cleanly withwrangler d1 migrations apply --local.Rollout
Additive nullable column, safe to apply before deploying. bactrack's fork-local
0033_bactrack_order_methodsdoesn't conflict.🤖 Generated with Claude Code