aiot-production-kit / atomic-vending-qr
STRIPE + HARDWARE · ZERO DOUBLE-VEND

30-Second PII-Free Hashed QR & Atomic Dispense State Machine

Battle-tested in London smart drink kiosks: separates payment webhooks, 30s single-use HMAC tokens, and fail-closed hardware locks.

TL;DR ENGINEERING FACTS
  • Zero PII in QR Payloads: QR tokens carry only `<exp>|<nonce>|<order_id>|<sku>|<hmac16>` with 30s expiry and one-time server nonce burn.
  • Fail-Closed RESERVED -> COMMITTED / RELEASED: Refuses new reservations while vending hardware is offline and releases locks atomically on sensor fault.
  • Stripe Webhook Idempotency: Deduplicates retries on persistent `event.id` and `Idempotency-Key` before emitting downstream commands.

Run & Test Locally (Zero External Dependencies)

python3 -m unittest discover -s tools -p "test_*.py"
python3 tools/atomic_vending_guard.py --demo

Field Failure Mode vs. Spacebit Reference Fix

Field Failure ModeWhy Naïve Implementations BreakProduction Guardrail
User shares QR screenshot across friendsStatic user ID encoded inside QR code30s server-signed HMAC + single-use nonce consumption
Stripe retries webhook on slow ACKDuplicate dispense order queued to kioskStrict deduplication on Stripe `event.id`
Machine offline or cup sensor jamsOptimistic commit charges without drinkFail-closed reserve check + RELEASED rollback state

Full-Stack Architecture Guides & Source Modules