caelum0x b2f9e31fa5 fix: close org takeover at registration and harden fee statements and invoice bindings
- POST /v1/auth/register: a merchant always gets a fresh organization; a
  caller-supplied organizationId let anyone join an existing seller's org and
  receive a platform:admin key (tenant takeover, present on main too).
- Customer (portal) sessions carry the seller's org id; they are now refused
  on the management API instead of being treated as the org owner.
- Fee statements: issuance is serialized per merchant+period in-process and a
  duplicate raced in by another instance is voided before sending; a draft
  left by an interrupted run is sent on the next run. Overlapping runs
  previously issued (and emailed) several statements for one month.
- Invoices: SettleKit-owned metadata keys (pay token, session bindings,
  settlement facts, fee-statement markers) are stripped from API input, and a
  payment from another organization never settles an invoice.
- Scope map: /v1/merchant/refunds/* needs payments:write (was reports:write).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 07:08:31 +03:00
..