{"object":"doc","slug":"integrate-antique-store-pos","title":"Integrate an antique-store POS with the terminal reference components","summary":"A read-first recipe for composing the reviewed Node terminal checkout, webhook receiver and order-evidence components into an existing antique store POS.","tags":["guide","agents","snippets","terminals","sandbox"],"body":"# Integrate an antique-store POS\n\n> I built an antique-store POS. Send the trusted sale amount from my computer to a\n> Poynt terminal and show the customer's payment result.\n\nStart with a plan for the existing app and an isolated simulated-terminal test. The\nthree components below supply payment plumbing, not a complete POS, browser login,\ninventory system or permission to use a physical device. Read this guide together\nwith `accept-a-terminal-payment`, `handle-every-payment-state`, `webhooks` and\n`troubleshoot-terminal-integration` through `get_doc`.\n\n## 1. Discover before editing or sending payments\n\nInspect the app's server runtime, order model, user authorization and trusted price\ncalculation. Call `get_openapi`, `list_snippets`, and `integration_checklist` when the\nkey has its required read scopes. Missing scope is an operator setup task, not a reason\nto try another route or key. Checklist history belongs to the platform; it does not\nprove this app is integrated. Availability is not permission to perform a test.\n\nUse `get_snippet` with each supported ID, then read its entire README and manifest:\n\n| Component ID | Version in this draft | Purpose |\n| --- | --- | --- |\n| `zeropoint.node.terminal-pos` | `0.3.1` | Durable order identity, at most one uncertain create attempt, and read-only recovery |\n| `zeropoint.node.webhook-receiver` | `0.3.0` | Raw-byte signature verification, durable receipt inbox, optional trusted merchant lookup |\n| `zeropoint.node.order-payment-evidence` | `0.1.2` | Trusted order binding and transactional application of inbox evidence |\n\nCheck the connected catalog rather than assuming these drafts are deployed. Unknown\nsnippet tools mean that release lacks discovery; stop and ask for the reviewed source\nor a release decision. Never invent a download URL or silently substitute another\npayment provider. A different component version needs its own compatibility review.\n\nThese references support server-side Node.js >=24.21.0 <25, one process on one host,\ndurable local SQLite, sandbox mode, USD and zero-tip terminal payments. They have no\nruntime npm dependencies. A serverless, Python, older-Node or distributed app needs a\nseparately verified adapter; do not claim that copying these files supplies one.\n\nThe checkout needs `payments:write` and `payments:read`; an existing full sandbox key\nworks but is not necessary. Optional setup/acceptance calls need their own permissions:\n`create_sandbox_merchant` requires merchants:write and terminals:write, terminal reads\nrequire terminals:read, event inspection requires events:read, and webhook registration/\nverification requires webhooks:write. The integration checklist requires platform:read,\nmerchants:read, payments:read, refunds:read and webhooks:read. A checkout does not need\nrefund write access. Physical registration and other calls retain their documented scopes.\n\nPresent the proposed files, app-owned business decisions and isolated test plan to the\nowner. Work only within the approved plan and approved test objects. Keep credentials\nin server-side configuration; never put them in chat, generated client code, browser\nstorage or reports. Do not reuse another operator's probe transactions or refund keys.\n\n## 2. Copy complete bundles and run their offline tests\n\nPlace the bundles in distinct server-only directories, preserving every returned\nrelative path, including manifests and tests. For example:\n\n```text\nserver/zeropoint/terminal-pos/\nserver/zeropoint/webhook-receiver/\nserver/zeropoint/order-payment-evidence/\n```\n\nVerify each returned UTF-8/LF file's SHA-256 and byte size before executing anything.\nDo not overwrite unrelated app files. Run `node --test test/*.test.mjs` from **each**\nbundle directory. Terminal/evidence examples use synthetic fixtures; the receiver's\n`example.mjs` instead expects configured signing secrets and opens a loopback listener.\nDo not run that receiver example as though it were a credential-free offline test.\nDo not copy any example's TEST ONLY inbox seeding into an application path.\n\nPassing these tests verifies the copied reference, not app authorization, hosted reachability,\nphysical hardware or successful use by a fresh coding agent. Record every failure; do not\nweaken signature, ownership or duplicate-handling checks to get a green result.\n\n## 3. Connect trusted order state to checkout\n\nThe host authenticates the user, authorizes the order, calculates integer cents from\ntrusted product data, and applies its own request/CSRF/rate controls. A browser-supplied\namount, webhook field or button click is not authoritative order data.\n\nConstruct `TerminalCheckout` as its README specifies, using the approved API origin,\nsandbox key, merchant and terminal. Use durable storage with a separate checkout database\nfor that origin/merchant/terminal binding. Keep the original order ID and database across\nrepeated clicks and restarts. Call `begin({orderId, amountCents})` only for the approved\nlogical sale; repeated calls return its stored snapshot. One logical order has at most\none create attempt whose outcome is uncertain, and never two payments.\n\nA timeout or unknown create result requires investigation and `refresh(orderId)` read-only\nrecovery. Never delete the local row, change the order ID, or substitute a new payment\nidentity to force another POST. The two exceptions go through `begin()` itself: after a\n`not_submitted` snapshot (the server refused the create, for example `terminal_busy`, and\nwrote no payment) the next `begin()` sends a new attempt, and after\n`review_required / processor_unavailable` the next `begin()` resends the identical request\nwith the same Idempotency-Key, at most twice. A declined/canceled/expired order does not automatically\ncreate a replacement; the host owns any separately authorized new-sale decision.\n\nIf the host caches snapshots for a local status display, its cache needs its own crash\ntests. Persist an incomplete-operation marker before a refresh. A repeated `begin`\ncan return an old cached success without a GET; that must not clear an interrupted\nrefresh's uncertainty. Preserve review until appropriate read-only recovery, including\nacross restart. Test process death during the read, not just a rejected fetch promise.\nThis boundary was missed by the first offline agent construction and caught by\nindependent review; copying the components does not automatically validate host glue.\n\n## 4. Compose authenticated receipt and order evidence\n\nCreate the receiver's `SqliteInbox` first. Configure a trusted receiver namespace,\nsigning secret and merchant allowlist. Verify exact raw bytes before JSON parsing and\nacknowledge only after durable inbox commit. Keep the platform API key separate from\nthe webhook signing secret. Unknown events may be received without business effects.\n\nConstruct `OrderEvidence` with the **same inbox database and receiverId** as the receiver.\nOnce checkout has a known payment ID, pass its locally saved binding directly:\n\n```js\nconst binding = checkout.getBinding(order.id);\nevidence.registerOrder(binding);\nconst counts = evidence.processBatch(20);\nconst currentEvidence = evidence.getOrder(order.id);\n```\n\nThis is an integration point, not a complete HTTP route or application worker. Authorize\naccess to `order` before it runs. Never build the binding from incoming webhook metadata.\n`payment_unbound` means recovery has not established an identity yet; unbound inbox evidence\nis held. Do not fabricate an ID or bypass the binding check to process it.\n\nThe checkout snapshot and evidence projection have different meanings. A checkout `paid`\nsnapshot is a verified observed success with no known refund. Evidence `success_observed`\nis historical evidence, not permission to fulfill. Attention, conflicting final states,\nlate reversal or refund evidence makes the evidence projection require review. That state\nis sticky; a later success event cannot clear it, and this component has no review-reset API.\n\n`listOutbox` is inspection of deduplicated local evidence, not a shipping/message dispatcher.\nThe host must check current payment truth and its own order/review policy before making\ntransactionally deduplicated inventory or fulfillment changes. A webhook HTTP 200, a success\noutbox entry or a receipt URL alone cannot establish exactly-once business effects.\nThe snapshot's validated same-origin receipt URL may be shown to an authorized customer;\nits hosted rendering and access still need the app's acceptance checks.\n\n## 5. Validate the app and hand off honestly\n\nExercise repeated clicks, process restart, lost create response, decline, cancel/expiry,\ninvalid signatures, duplicate deliveries, wrong ownership and attention after success.\nAssert no new create identity after uncertainty and no automatic fulfillment on review.\nKeep tests on synthetic credentials and fake transports until a separately approved\nsandbox acceptance flow is ready. The repository's `tests/test_retrieved_terminal_scenario.py`\nis a deterministic composition example; it is not a fresh-agent or deployed acceptance run.\n\nA controlled HTTPS receiver with independent bad-signature rejection must be tested before\npartner reliance. The existing hosted sink's expected 3/4 is delivery evidence only, not a\nregression or proof of independent signature verification. Provisioning or registering a\nreceiver, using a real terminal, deploying code and live payments need their own authorization.\nA physical-terminal capability flag never replaces separate hardware approval.\n\nReport copied versions/hashes, changes outside the copied bundles, tests and actual results,\nmanual interventions, unresolved outcomes and the next owner's action. Keep secrets, raw\npayloads and card data out of the handoff. Use `troubleshoot-terminal-integration` for a safe\nnext action when stopped. Say explicitly what was only tested offline. Do not deploy or\nclaim that a prototype, local fixture or historical checklist clears a release.\n\nThis recipe does not implement the salon's texted checkout, deposits, remaining balances or\ncustomer-selected tips. Those require separately selected and verified product contracts.","updated":1795275945}