The finance feed: KolorIQ in orga-finance (operator)

orga-finance is the company's own finance cockpit. KolorIQ appears in it as its own business line, the way Caching Out does. Two things make that possible:

  1. Every KolorIQ payment is tagged in Stripe with product = koloriq (on the Checkout Session, on the payment and on the product line, which also carries the panel, for example offer = panel-1000). KolorIQ and Caching Out share one Stripe account, so without the tag orga-finance would count KolorIQ's sales as Caching Out's.
  2. A signed, read-only monthly totals feed gives orga-finance what Stripe does not carry: which Stripe payments are KolorIQ's, partner commissions and the metered model cost (both cost of sales), and counts to check its own figures against.

Sales, refunds, Stripe fees and VAT still come to orga-finance from Stripe itself. KolorIQ never calls orga-finance and orga-finance never writes to KolorIQ.

The contract is in the hub: Barquish1/portfolio-map, contracts/koloriq-finance-totals.md. Status 2026-11-22: the KolorIQ side is built and tested. In orga-finance the separation itself is built (its migration 023: every Stripe line is stored with its product, KolorIQ has its own row, nothing is merged) and waits to be deployed; its reading of this feed (partner commissions, model cost) is not built. Neither side has been run against live Stripe data.

What the feed returns, per month

Months are calendar months in Europe/Warsaw. Money is in cents of USD unless named otherwise.

Field Meaning
open true for the current month: figures still move
sales purchases recorded: count, amount paid, tax, net, how many were free through a discount code, count by panel
refunds purchases refunded in the month, and how many refunds are still waiting
stripe_payment_intents the Stripe ids of the month's payments, so finance can attribute Stripe lines exactly
partner_commissions accrued in the month, cancelled by refunds, clawbacks still open, paid out, and each payout with its reference
model_cost_usd metered model cost of surveys finished in the month, split into paid and free surveys
surveys finished paid, finished free, failed
days per day: partner commissions accrued and model cost, for conversion at each day's rate

It never contains an email, an account id, a study or a product name.

Getting started (owner)

  1. Apply 0011_finance_totals.sql after 0010 and run the two verification queries in its header.

  2. Make a secret of at least 32 characters and keep it in the password manager:

    python -c 'import secrets; print(secrets.token_urlsafe(48))'
    
  3. On the KolorIQ API set FINANCE_TOTALS_KEYS to <key-id>:<secret>, for example key id finance-2026. Restart the API. Without it both addresses answer 404 "The finance totals are not enabled."

  4. On orga-finance, once its side is built, set the same key id and secret under the names its change request gives. Deploy order: KolorIQ first.

  5. In the Stripe dashboard nothing needs doing: the tag is added to every new checkout by itself. Payments made before this version carry no tag; the stripe_payment_intents list covers them.

Rotating the secret: add the new <key-id>:<secret> next to the old one (comma separated), restart; switch orga-finance; remove the old entry, restart.

Limits

  • 30 requests an hour per key. A request is valid for 300 seconds and its nonce once.
  • At most 24 months per call; the first month served is 2026-11.
  • Model cost is what the workers metered when a survey finished. Failed attempts and the website draft are not in it, so the provider's invoice will be somewhat higher.
  • Tax is known only while Stripe Tax is on; otherwise tax_minor is 0 and net equals paid.

Troubleshooting

Answer Cause Fix
404 not_enabled "The finance totals are not enabled." FINANCE_TOTALS_KEYS is empty or holds no usable entry (malformed, or secret under 32 characters) Step 3
401 missing_signature "A signature header is missing." One of the four X-Orga- headers is absent Fix the client
401 bad_signature "The signature does not match or the key id is unknown." Wrong secret or key id, or a proxy changed the path or query Compare both sides' values; the path signed is the one the API receives
401 stale_request "The timestamp is outside the allowed 300 seconds." The two servers' clocks differ Fix the clock
401 replayed_request "This nonce was already used." The same request was sent twice Send a new nonce each time
429 rate_limited "Too many requests from this key. Try again later." Over 30 an hour Wait; Retry-After says how long
400 bad_month / out_of_range / range_too_long A malformed month, a month before 2026-11 or in the future, or over 24 months Correct the request
KolorIQ sales show under Caching Out in orga-finance Its migration 023 is not deployed, or the sale was stored before it was Deploy it before selling; a line stored earlier is moved by hand there
orga-finance shows "Lines with no known product" A payment carried no usable product tag See its help article "Stripe connection"; check this API is the version that tags checkouts