Project

General

Profile

Feature #165

Updated by Eugene Suhanov 4 months ago

Design document only for now — a time constraint, not a blocked one. Deliverable: 
 `docs/posiflora-integration.md`, written as an executable plan so implementation can start without 
 another round of questions. 

 Establishes the boundary: **`nota-admin` owns the catalogue** and nothing about a product is ever 
 pushed to Posiflora; **Posiflora owns orders and payment statuses**, including the manual 
 confirmation an admin performs for WhatsApp and IBAN orders. The storefront database bridges the 
 two. 

 Key constraints from the API spec (`Posiflora API 2022_16-v2`, JSON:API, 114 paths — **the spec is 
 not in this repo; request it from the maintainer**): payments exist only nested under an order, so a 
 real local `Order` is a prerequisite; payment state is a `posted` boolean, not a status enum; **there 
 are no webhooks**, so inbound confirmation must be polled; `externalId` is response-only, so 
 idempotency has to come from a client-supplied deterministic UUID; and there is no 
 `/v1/payment-methods` or `/v1/shifts` endpoint, so those UUIDs must come from the tenant. 

 The document covers: adopting the existing-but-unused `orders`/`order_items` tables as the system of 
 record for all three payment paths; a separate `orders.payment_status` enum rather than extending 
 `PaymentState`; an authority split (Revolut owns card status, Posiflora owns manual); a queued 
 outbound push that never changes the storefront verdict; a `posiflora:reconcile` polling command; 
 and console commands including a `posiflora:fake-confirm` that makes the feature demoable with no 
 credentials. 

 **Blockers to name:** production runs `QUEUE_CONNECTION=sync` (the push would run inline in the 
 customer's request) and has no `schedule:run` cron (polling would never fire — this already breaks 
 `revolut:reconcile`). 

 **Credentials now exist**, so before writing the open-questions section, spend half an hour probing 
 the demo tenant: `GET /v1/stores`, `/v1/order-sources` and `/v1/workers` resolve three of the five 
 required UUIDs directly, and one test order settles whether int32 amounts are minor or whole units 
 (a 100× POS pricing error is the worst failure mode this feature has). Expect these to survive the 
 probing: the payment-method and shift UUIDs, which no endpoint exposes and which must be read from 
 the Posiflora admin UI — and specifically whether a payment requires an *open* shift, since a 03:00 
 web order would then be unpostable; and whether the checkout form needs structured address fields. 

 Keep `POSIFLORA_ENABLED=false` as the default throughout, with the Fake client bound whenever it's 
 off. Credentials go in `.env` only — never in the design document, config defaults, or fixtures.

Back