feat(cloud): the cloud prices online orders itself; sites only touch their own data (platform-v2 3S, S.2)
- services/checkout.py: orders and quotes priced from the site's snapshot per sales point
(prices map; older snapshots: digital_price less discount); refused: unavailable or
not sold there, bad quantity/option/type, empty, order.price_changed when the browser's
unit price or total differs. Nothing the browser says about money is stored.
- POST /api/orders/{site}/quote; delivery needs phone + address.
- Fixes: pending orders, menu sync and stats snapshot acted on the site_id given, not the
authenticated site (a site could read another's orders or overwrite its menu/stats).
- Order refs are unique per site (a second site's first order failed); tracking by a
random token GET /api/orders/track/{token}; old /status/{ref} only while unambiguous.
- Alembic 0003: online_orders sales_point, table_label, tracking_token; table rebuilt.
- menu-app: tracking link uses the token, shows the order number; tells the customer when
the menu changed or the order failed.
- Tests: test_checkout.py (6), 0003 data migration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,15 @@ export async function submitOrder(siteSlug, body) {
|
||||
return data // { order_id, public_ref, status }
|
||||
}
|
||||
|
||||
export async function fetchOrderStatus(publicRef) {
|
||||
const { data } = await api.get(`/api/orders/status/${publicRef}`)
|
||||
return data // { public_ref, status, rejection_reason }
|
||||
// The tracking link carries the order's random token (phase 3S, S.2); links from before that
|
||||
// carry the public ref and use the old endpoint.
|
||||
export async function fetchOrderStatus(ref) {
|
||||
try {
|
||||
const { data } = await api.get(`/api/orders/track/${ref}`)
|
||||
return data // { public_ref, status, rejection_reason }
|
||||
} catch (err) {
|
||||
if (err?.response?.status !== 404 || !/^ORD-\d+$/.test(ref)) throw err
|
||||
const { data } = await api.get(`/api/orders/status/${ref}`)
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user