Customer guide map
Account and counter setup
Roles, credentials, OAuth, webhooks, location, and device setup.
Sandbox test plan
Success, cancel, timeout, offline, expiry, duplicate event, and stock tests.
Catalog synchronization
Direction selection, links, conflicts, prices, counts, and no-delete rules.
Production launch
Physical pairing, first live sale, go/no-go gate, and customer handoff.
Operations
Payments hub observability, lifecycle, reconciliation, and daily checks.
Troubleshooting
Safe symptom-based recovery and escalation packets.
How the flow works
- A shopper checks out on a
checkoutMode: 'square_terminal'storefront. Tuturuuu validates Square readiness, creates a local checkout reservation, stores the provider assquare_terminal, and returns the buyer to the local order reference page. - A Square Terminal Storefront dispatches the reserved checkout immediately; an eligible reserved row can also be sent or canceled from the Inventory Commerce workflow. Tuturuuu creates a Square order, then creates a Terminal checkout for the selected location and device with the Square order id and itemized cart display enabled.
- Square sends terminal checkout and payment webhooks. Tuturuuu verifies the raw webhook body signature before parsing, reconciles duplicate deliveries idempotently, and completes the checkout only after a verified paid payment.
- On Square create failure, cancellation, expiry, or failed terminal checkout,
Tuturuuu releases the local reservation so stock returns to availability. A
five-minute expiry sweep materializes abandoned 15-minute reservations as
expired; checkout reads and new checkout creation also reconcile stale rows.
Workspace credentials
Square credentials are self-serve per workspace, like Inventory Polar settings. Do not configure Square app credentials, access tokens, or webhook signature keys as deployment secrets. Workspace admins save these values in Inventory → Payments → Connect & set up → Square POS, where Tuturuuu encrypts secret values before private-schema storage. The Square REST client pinsSquare-Version: 2026-05-20 and uses native
fetch. OAuth is the recommended connection method because Tuturuuu can refresh
tokens and validate granted scopes. Manual access-token configuration remains
available for controlled deployments and does not require saved Square OAuth app
credentials.
Configure Square
- Create or open a Square application in the Square Developer Dashboard.
-
Configure the OAuth redirect URL:
-
Grant these OAuth scopes:
MERCHANT_PROFILE_READORDERS_READORDERS_WRITEPAYMENTS_READPAYMENTS_WRITEDEVICE_CREDENTIAL_MANAGEMENTITEMS_READITEMS_WRITEINVENTORY_READINVENTORY_WRITE
-
Create a webhook subscription for the Inventory Square endpoint:
Subscribe to these required events:
device.code.pairedterminal.checkout.createdterminal.checkout.updatedpayment.updatedoauth.authorization.revokedcatalog.version.updatedinventory.count.updated
payment.createdcan be added for additional delivery visibility, butpayment.updatedis the required payment-state signal in the customer setup checklist. - Copy the webhook signature key into Inventory → Payments → Connect & set up → Square POS for the matching environment.
apps/web with an HTTPS tunnel and either use the
tunnel URL in Square or save that exact URL as the workspace webhook
notification URL so signature validation uses the same value.
Connect a workspace
- Open Inventory → Payments → Connect & set up → Square POS. Configuration changes open in a three-tab dialog; incomplete checklist steps deep-link to the required tab.
- Choose
SandboxorProduction. - Save the Square Application ID and Application Secret for that environment. If Square is configured with a tunnel or canonical URL that differs from the actual request URL, also save the exact webhook notification URL so HMAC validation uses the same URL Square signed.
- Prefer Connect OAuth. For manual setup, paste an access token and save it with the matching environment.
- Save the webhook signature key for the same environment.
- Select a Square location.
- Pair or select a terminal:
- Production: create a device pairing code, enter it on the physical Square
Terminal within five minutes, then select the paired device. The pairing
request uses Square’s
TERMINAL_APIproduct type. Create this code inside Tuturuuu; device codes from Square Dashboard are not compatible with Terminal API pairing. - Sandbox: use Square’s sandbox terminal device id when device listing is not available.
- Production: create a device pairing code, enter it on the physical Square
Terminal within five minutes, then select the paired device. The pairing
request uses Square’s
- Set a storefront’s checkout mode to
Square Terminal. - In Catalog and stock sync, import from Square first in Sandbox. Review counts and conflicts, then rehearse publish and two-way sync. Repeat in Production only after confirming the selected seller and location.
Runtime ownership and endpoints
The Inventory satellite owns the customer-facing Square routes and delegates provider orchestration to@tuturuuu/inventory-core. Client components use
@tuturuuu/internal-api; they must not call provider APIs or private database
tables directly.
The environment, workspace, seller connection, location, and device are checked
again server-side. A client-visible control is not an authorization boundary.
State and idempotency boundaries
Provider IDs have unique database indexes, webhook events carry Square event IDs, and reconciliation routines are safe to call repeatedly. Never weaken those constraints to make a duplicate test pass. The local checkout is reserved for 15 minutes. The database expiry function is service-role only, concurrency-safe, and invoked by a five-minute cron plus lazy reconciliation on reads and new checkout creation. Terminal cancellation and Square final-state webhooks use the same release/complete boundaries.Focused verification commands
Run the narrow Square contract suites before the wider repository gate:Hardware-free verification
No mocked test can prove that a specific production countertop terminal is online, paired to the right Square seller account, assigned to the selected location, has a working network path, and can complete a real card-present payment. Without hardware, treat the automated suite as Square contract and reconciliation verification, not physical-device certification. The no-hardware suite must cover these Square contracts before release:- OAuth authorization URL, token exchange, refresh, scope parsing, encrypted storage, and secret redaction.
- REST base URLs for sandbox and production,
Square-Version, bearer auth, sanitized upstream errors, and idempotency keys. - Catalog search, additive Batch Upsert, unknown-variation preservation, two-sided hash conflict detection, deleted-object preservation, and physical inventory count payloads that never contain a delete instruction.
- Orders API payloads before Terminal checkout creation.
- Terminal checkout payloads with
order_id,device_options.device_id, anddevice_options.show_itemized_cart. - Device Code creation with
product_type: TERMINAL_APIand paired-device webhook reconciliation. - Raw-body webhook HMAC validation against the exact Square notification URL before JSON parsing.
- Terminal checkout, payment, OAuth revocation, cancellation, expiry, failure, duplicate delivery, and event-id reconciliation behavior.
- Reservation-first lifecycle: create local reservation before Square calls, release on Square create/cancel/failure/expiry, and complete stock/ledger state only after verified Square payment success.
- Scheduled and lazy checkout-expiry reconciliation, including concurrent sweeper safety and service-role-only database access.
Physical-terminal smoke checklist
Complete the simulator matrix in Sandbox first. Square does not pair real hardware to Sandbox, so physical-device certification requires a separately approved Production test with a low-value item and real card-present processing. Do not promise that a refund also refunds every processing fee; the Square owner must approve the store’s refund plan.- Pair a terminal for the selected Square location.
- Create a small Storefront order and confirm Inventory shows it as reserved.
- Use Inventory commerce actions to send it to the terminal.
- Complete the payment on the terminal.
- Confirm Square webhook delivery succeeded and Tuturuuu marked the checkout completed with Square order, terminal checkout, payment, and receipt URL metadata.
- Confirm stock reservations were consumed and the finance ledger sale was booked once.
- Repeat cancel, expiry/failure, duplicate webhook delivery, and transient Square failure cases in Sandbox. Cancel/failure/expiry must release inventory. Do not repeat destructive Production failure tests unless the owner explicitly approves their real-money and operational effects.
Refund and dispute reconciliation
Square connections created before Inventory–Finance reconciliation may not includeDISPUTES_READ. Existing payment capture remains usable without that
scope. Ask the Square owner to reconnect OAuth during a planned maintenance
window before enabling dispute history synchronization.
Subscribe the configured Square webhook endpoint to:
refund.createdrefund.updateddispute.createddispute.state.updated
WON creates a positive release, while
LOST and ACCEPTED leave the hold final. Webhook retries update the same
provider source key and must never create duplicate ledger rows.
After deployment, use the Finance reconciliation provider-sync action in
bounded pages. It reads Square refund and dispute history but does not create,
accept, challenge, or otherwise mutate a Square dispute. Validate these flows
in Square Sandbox; do not create or capture Production payments merely to test
reconciliation.