44 Commits

Author SHA1 Message Date
894d315a24 fix(api): stop returning raw internal error messages in production
Unhandled errors echoed the driver message to the caller, including SQL and
bound parameters. In production the caller now gets a generic message and
the detail is logged server-side with the request id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 19:57:39 +03:00
45fced409c fix(api): store a quick product before its price
prices.product_id is a foreign key in Postgres, so saving the price first
made POST /v1/merchant/products fail with a 500 on the live database. The
in-memory repositories never enforced the key; the new test does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 19:57:39 +03:00
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
c724bf1700 feat: conversion, per-link, churn and LTV metrics (G14, part 1)
GET /v1/analytics/metrics computes, from live sessions, payments,
subscriptions and catalog: checkout conversion, per-payment-link opened /
paid / conversion / revenue, repeat customers, average revenue per
customer, subscription churn, ARPU and an estimated lifetime value, with
exact bigint money. Checkout repositories gain listCreatedSince
(in-memory and Postgres). The dashboard Analytics page shows the new
cards and a payment-link table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:37:57 +03:00
1d92fa23f2 feat: branded hosted storefront per merchant (G12)
Merchants can publish a store (slug, title, tagline, https logo, accent
colour, search description, optional custom domain) through settings or
the dashboard. The checkout app serves it at /store/<slug> with SEO and
Open Graph metadata, listing active products (invoice products hidden)
that each open their payment link, and a middleware rewrites '/' on a
merchant's custom domain to its store when CHECKOUT_PRIMARY_HOSTS is set.
Slugs and domains are unique; public data at /v1/public/stores. Carts of
several products stay out of scope because hosted checkout fulfils one
product per session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:32:06 +03:00
132efd87b3 feat: cash-out hand-off to off-ramp partners (G11)
GET /v1/merchant/offramp builds sell links for Transak, MoonPay (signed
server-side with the secret key) and Ramp with the amount, network and
the merchant's own receiving wallet prefilled. SettleKit takes no
custody; partners appear only once the owner configures their keys
(TRANSAK_API_KEY, MOONPAY_PUBLISHABLE_KEY/MOONPAY_SECRET_KEY,
RAMP_HOST_API_KEY). The dashboard Balances page gets a Cash out action per
mainnet network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:24:40 +03:00
6ba53b7a92 feat: refund to payer with prepared transfers verified onchain (G10)
Refunds no longer depend on a pasted hash alone. POST
/v1/merchant/payments/:id/refund/prepare creates a pending refund and
returns the exact transfer back to the buyer: ERC-20 transfer calldata,
token, chain id and an EIP-681 link on EVM networks, or a Solana Pay
transfer request with a unique reference. The destination is the wallet
that paid when known, else the merchant enters it (validated per chain).
POST /v1/merchant/refunds/:id/confirm verifies the signed transfer
onchain with the payment verifiers (destination, amount, time, Solana
reference, one refund per tx) and only then settles: access revoked,
payment refunded once fully refunded, refund.succeeded with source
wallet. Pending refunds can be canceled. Dashboard refund form gets a
'Send from my wallet' mode (browser wallet or mobile link, auto-verify).
apps/refund-protocol stays unwired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:21:27 +03:00
c14d0ab735 feat: team roles with invitations and enforced API key scopes (G9)
Security fix plus team access. Before this change any valid API key,
including access keys the delivery system hands to BUYERS, authenticated
as the merchant on the whole management API, and GET /v1/api-keys listed
every organization's keys. Now only platform keys (issued at sign-up or
via POST /v1/api-keys/platform, marked with the platform product id) can
call the API, and each request needs its resource scope
(<resource>:read|write, write implies read; platform:admin or * for
full access), answered with 403 and details.requiredScope otherwise.
Keys cannot mint broader keys, customer keys cannot carry management
scopes, key listing is tenant-scoped and keys can be revoked by id.

Dashboard sessions get team roles (owner, admin, developer, support,
viewer) mapped to scopes. /v1/team manages members and email
invitations (packages/invitations, token hash only, 7-day expiry);
/v1/auth/invitations/accept joins the org and creates the account. The
last owner is protected and only owners grant owner. Dashboard: Team
page, invite accept page, and an API keys page that creates restricted
keys and shows the secret once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:09:06 +03:00
40f90f1c5a feat: webhook event log with resend, test events, secret rotation and auto-disable (G8)
Every seller webhook delivery now keeps an attempt log (status code,
error, time, next retry) in the worker queue (Postgres) or in memory.
New routes: GET /v1/webhooks/deliveries(/:id), POST
/v1/webhooks/events/:id/resend, POST /v1/webhooks/endpoints/:id/test
(signed webhook.test event), rotate-secret with a 0-168h grace window
(both secrets sign as two v1 values, verified by @settlekit/webhooks, the
TS/Python/Go/Rust SDKs and the WooCommerce plugin), and disable/enable.
The worker retries on a 1m..6h exponential schedule instead of every tick,
signs with the live endpoint secret, skips disabled endpoints and
auto-disables one after 100 failed attempts in a row
(WEBHOOK_DISABLE_AFTER_FAILURES). Outbound requests get a 10s timeout.
The dashboard Webhooks page shows the event log with Resend and endpoint
actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 05:34:39 +03:00
330d111510 feat: fiat pricing with live ECB rates locked per checkout (G7)
Prices can now be set in EUR, GBP and other ECB reference currencies
(displayCurrency + displayAmount, or currency on quick products). Each
checkout converts them to USDC at the live rate from a frankfurter
service (MIT, FX_RATES_URL), rounded half-up to the cent with exact
bigint math, and locks the quote on the session (fxQuote) until it
expires, so onchain verification expects exactly the quoted USDC. Promo,
tax, receipts and the hosted checkout lines use the locked rate; the
payment link page shows the fiat price and today's USDC amount. Missing
or implausible rates fail closed (503); fiat subscriptions and mixed
fiat currencies are refused. Dashboard product form gets a currency
picker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 05:13:37 +03:00
f1647a5a81 feat: embeddable checkout overlay (embed.js) with allow-listed success callback (G6, part 1)
apps/checkout/public/embed.js opens a payment link, checkout or invoice
from the same checkout origin in an overlay iframe on any site; links
marked data-settlekit-checkout bind automatically, SettleKit.open() is
available from code, and there is an open-in-new-tab fallback for
wallets that block iframes. The success page posts settlekit:success
only to a site the seller listed under Settings > Embedding
(org embedOrigins, validated https origins), and embed.js only accepts
messages from its checkout frame. Payment requests gain sendEmail and
successUrl so store plugins can redirect buyers and bring them back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:52:19 +03:00
22c3208b60 feat: merchant accounting exports with Xero and QuickBooks imports (G5)
New tenant-scoped /v1/exports routes: payments, refunds, invoices and
payouts CSVs, a full USDC ledger, and bank statement files that Xero
(DD/MM/YYYY statement import) and QuickBooks Online (three-column bank
upload) import directly, with optional date ranges. packages/exports
gains a formula-injection guard (opt-in, admin unchanged) and the
accounting formatters. The dashboard Payments page links every export
through a session-authenticated download route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:35:58 +03:00
a4d0f3f5cb feat: tax at checkout and tax-grade receipts (G4)
Sellers can turn on checkout tax in settings (label, own country and tax
ID, legal name, per-country rates, default rate, EU reverse charge).
Sessions add tax on top of the net price after any promo, so onchain
verification expects the tax-inclusive total. Buyers set billing country
and VAT ID via the API (billingCountry, vatId) or on the hosted checkout
until a payment is recorded; EU cross-border B2B with a VAT ID of the
right shape is zero-rated. Settled checkouts get a PDF receipt (pdfkit)
with the seller's tax ID, buyer country / VAT ID, tax rate and the
settlement transaction, linked from the success page, the receipt email
and the customer portal. packages/tax calculateTax is now used at
checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:30:53 +03:00
4e97fcc409 feat: promo codes at checkout (G3)
Coupons now reach checkout. POST /v1/checkout-sessions takes an optional
couponCode, payment links accept ?promo=CODE (a refused code falls back to
full price with a notice), and the hosted checkout gets a promo field
while the session is open and unpaid. The discounted total becomes the
session amount before network bindings, so onchain verification expects
the discounted amount and a locked Zcash quote is re-priced. Codes are
tenant-scoped, product-scoped codes discount only their products, and
free-trial or 100% codes are refused. The redemption is counted once
after the payment confirms (API confirm and hosted checkout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 04:09:54 +03:00
e0caf4bace feat: monthly platform fee statements with plan limits after grace (G1)
SettleKit's advertised per-payment fee was never collected because buyers
pay merchants' wallets directly. When PLATFORM_BILLING_ORG_ID is set, the
API now issues each merchant a monthly statement (confirmed payments x the
fee schedule) as an invoice from SettleKit's own org, paid through the
hosted checkout on the G2 payable-invoice path. Totals below the minimum
carry forward, test accounts are skipped, runs are idempotent and happen
automatically every six hours (or via POST /v1/billing/statements/run).
A statement unpaid past due + grace restricts new products to the free
plan limit from packages/pricing (402 with the pay link). Merchants see
accrued fees, statements and a Pay button on the Balances page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 03:50:08 +03:00
466c662ac3 feat: payable invoices and payment requests (G2)
Invoices can now be paid onchain. POST /v1/invoices/:id/send issues the
invoice, binds a public pay page (/i/<token> on the hosted checkout),
opens a checkout session for the invoice total on the merchant's
networks and emails the link. POST /v1/invoices/requests sends an
ad-hoc amount + memo to an email. The invoice turns paid only when a
confirmed onchain payment exists for one of its sessions (on read in the
API and in the new worker invoice-settle job) and emits invoice.paid.
Invoice and receipt PDFs render with pdfkit (MIT). Voiding cancels open
sessions. Dashboard gets a request-a-payment form, send buttons, pay
links and PDF downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 03:35:06 +03:00
2b2c8b471d chore: merge Tameion operator into main alongside multi-chain SettleKit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:43:33 +03:00
39b29903b2 fix(pricing): default platform fee to 1% with no fixed fee to match the landing page
DEFAULT_FEE_SCHEDULE in packages/platform-billing is the single source of truth;
.env.example documents how the API and web env mirror it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:11:28 +03:00
7647d733b1 fix(api): enforce tenant ownership on single-resource routes
Payments (GET/confirm/fail/refund), checkout sessions (GET/cancel/expire/
collect-fields) and every other route loading a record by opaque id now
require the record to belong to the authenticated org, answering 404 (never
403) on mismatch so ids in other tenants cannot be probed. Creation paths
that reference another resource (payment->session, checkout->price,
subscription->product/price, refund/dispute->payment, dunning->subscription)
apply the same guard, and escrow tasks are scoped to the caller's org
instead of a client-supplied organizationId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 21:08:55 +03:00
1b38e24f1f feat(x402-facilitator): Postgres nonce store and closed-by-default recipient allowlist
- PgX402NonceStore (x402_nonces, migration 0012): reserve is INSERT ... ON
  CONFLICT DO NOTHING on the primary key, so one settle wins across replicas.
  The API wires it whenever DATABASE_URL is set; otherwise the facilitator
  falls back to the in-memory store and logs a boot warning. One store is
  now shared by every per-environment facilitator part.
- allowedPayTo defaults to this deployment's own EVM receiving addresses
  (X402_EVM_PAY_TO + X402_PAY_TO_<CHAIN>); an empty allowlist refuses every
  recipient, and only X402_FACILITATOR_ALLOWED_PAY_TO=* opens the relayer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:59:42 +03:00
e169731b42 chore: merge feat/solana-colosseum into feat/x402-multichain
Brings in packages/routing, packages/hyperliquid (hypercore network), checkout
AnyTokenPay/HyperCorePay, Node 22 pins, tenant-ownership guards and the zcash
tag lock. Only conflict: drizzle _journal.json (kept 0010_onchain_billing and
0011_coupons_organization in order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:39:32 +03:00
b6c50500f9 fix(api): enforce tenant ownership on single-resource routes
Payments (GET/confirm/fail/refund), checkout sessions (GET/cancel/expire/
collect-fields) and every other route loading a record by opaque id now
require the record to belong to the authenticated org, answering 404 (never
403) on mismatch so ids in other tenants cannot be probed. Creation paths
that reference another resource (payment->session, checkout->price,
subscription->product/price, refund/dispute->payment, dunning->subscription)
apply the same guard, and escrow tasks are scoped to the caller's org
instead of a client-supplied organizationId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:51:05 +03:00
2545aeddfb fix(x402): require exact authorization value and map tx-hash races to 409
The facilitator policy now refuses any authorization whose value differs
from the requirements amount before settling (also on direct /settle).
Agent purchases treat a lost race on the payments tx-hash unique index as
409 conflict, so one settlement never delivers twice. The MPP buy route
fails fast if mppx does not expose the tempo/charge intent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:06:42 +03:00
d663ce3bc1 fix(api): surface settled-but-unfulfilled agent purchases
If fulfilment fails for a non-domain reason after the payment settled,
log a structured reconciliation line and return 500 fulfilment_failed
with the transaction, network, product and payer (and the settlement
receipt header) instead of a bare internal error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:01:25 +03:00
aeb7473984 fix(api): pass the GitHub App installation to agent-purchase delivery
GitHub invite / team actions resolve the installation from the product's
pinned metadata, the org's connected installation or
GITHUB_APP_INSTALLATION_ID, so repo-access products deliver inline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:54:07 +03:00
2b9172e384 feat(api): HyperCore verifier, Tempo requireMemo sessions and routed-fill bindings
- HYPERCORE_* config; the registry registers a hypercore SettlementVerifier
  (payee ledger via @settlekit/hyperliquid) only when enabled
- checkout sessions accept requireMemo (Tempo only); confirmations then need
  transferWithMemo(keccak256(session id))
- a route provider's stored destination fill skips only the payer and memo
  bindings; hypercore joins the observable networks
- drop the unused @settlekit/routing dependency from the API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:48:20 +03:00
21c5c2a979 feat(api): MPP agent payments on Tempo via mppx
GET /v1/mpp/research (mppx/hono middleware) and
POST /v1/mpp/products/:productId/buy: the mppx Tempo charge (USDC.e on
mainnet, pathUSD on Moderato) is verified first, then the purchase is
recorded, entitled and delivered through the shared fulfilment path,
returned with the Payment-Receipt header. Tests round-trip real mppx
challenges and credentials against the real Tempo charge schema with a
fake on-chain verifier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:41:21 +03:00
4cf8417728 feat(api): x402 v2 agent payments on Solana and every EVM chain
GET /v1/x402/research (x402 paymentMiddleware) and
POST /v1/x402/products/:productId/buy: one 402 challenge lists every
configured network; Solana/Base/Arbitrum settle through PayAI and
Ethereum/HyperEVM/Robinhood through the self-hosted facilitator, with
explicit per-network facilitator routing. Purchases use the upfront
flow: the facilitator settles BEFORE the handler, then the Payment is
recorded (tx hash unique, 409 on reuse), the entitlement granted and the
product's delivery actions run inline; the artifact is returned with the
PAYMENT-RESPONSE receipt. Product, price and required buyer fields are
validated before any challenge. Also exposes the facilitator's
/supported, /assets and bearer-guarded /verify and /settle, and
GET /v1/x402/networks. Runtime is built from env once at boot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:41:21 +03:00
b110508926 feat: expose operator vault state for the console
Adds buildOperatorState (bucket balances, held total, today's UTC-day spend
vs caps, pending escalations) and OperatorRuntime.state(), read from the
vault executor (on-chain reads when OperatorVault is configured), served at
GET /v1/operator/state for the operator org.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:59:41 +03:00
2134532ba3 fix: drop Solana from the Tameion branch while keeping fail-closed confirmation
The cherry-picked fail-closed payment fixes imported @settlekit/solana, which
does not exist on this branch, breaking tsc -b and the api/worker suites.
Solana verification, env and session references are removed; arc/base/
ethereum keep the per-network verifier registry and the worker keeps
payTo-bound verification. A solana network is now rejected as unsupported
(400 on checkout/observe, unsupported in the worker). Also adds the missing
packages/circle project reference to the api, points the api/worker test
scripts at the root vitest config, and removes the operator's
vitest.apps.config.ts workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:55:28 +03:00
0a86d7af03 fix: harden operator against double execution and payee swaps
- Events and escalation resolutions are claimed atomically in the store
  (operator_claims, INSERT ... ON CONFLICT DO NOTHING) before any money
  moves, so concurrent API/worker processes cannot execute twice; claims
  are released only when nothing was executed.
- x402 purchases pin the policy-approved payee and price: the settler
  refuses a re-read challenge that names another payTo or a higher price.
- A broadcast vault transaction whose receipt is unavailable or reverted
  is recorded as failed with its txHash (VaultTxError) for reconciliation.
- verifyDecision never reports a decision that moved money as valid
  without checking its DecisionAnchored logs on Arc.
- The worker's shared runtime reads the current run's clock and logger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:40:43 +03:00
1e20ece9df feat: add operator tick job to the worker
Each run expires stale escalations (vault-held ones on-chain, bills closed
as rejected), turns confirmed Arc payments into the operator vault without
a decision into revenue.received (payer read from the USDC transfer), raises
bill.due for open bills inside the due window, and emits one tick per UTC
day. Event ids are deterministic so nothing is decided twice. The API and
worker only run the operator with OPERATOR_VAULT_ADDRESS set or an explicit
OPERATOR_SIMULATION=1; otherwise the job no-ops and the routes answer 503.

Registered with one export in jobs/index.ts and one scheduler entry in
runtime.ts (the scheduler lists jobs explicitly).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:23:29 +03:00
2a4864dd49 feat: add operator API routes and public proof endpoints
/v1/operator (API key or dashboard session, scoped to the vault's org):
POST /events (caller org forced, duplicate event ids replay the recorded
decision, single-flight per event), GET /decisions[/:id], POST|GET /bills,
GET /escalations, owner-only POST /escalations/:id/approve|reject, GET and
owner-only PUT /policy which refuses drift from on-chain caps and allowlist.
/v1/public/operator: GET /proof (cached aggregates, demo org excluded) and
GET /verify/:id. Mounted with one route line in app.ts ahead of the v1
API-key group. Escalated bills close when the owner resolves them.

App-level operator tests run through vitest.apps.config.ts because the api
and worker tsconfigs reference packages/solana, absent on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:15:22 +03:00
3be266d966 feat(api): verify payments on every enabled chain and lock Zcash quotes
- config: loadEvmChains + Zcash groups (BASE_RPC_URL/ARC_CHAIN_ID aliases
  kept), per-network SettlementVerifier registry (EVM via @settlekit/chains,
  Solana adapter, Zcash via Blockchair), boot refuses on RPC chain-id
  mismatch and warns when an RPC is unreachable
- payments: network-aware tx id validation; confirm binds payTo per
  network, session createdAt, payer, session id (Tempo memo) and the locked
  quote; retryable and late (manual review) outcomes are explicit
- checkout sessions: every accepted network's payTo validated for its
  chain family, acceptedNetworks/payToByNetwork, Solana reference and a
  Zcash quote with a unique amount tag
- tests: per-network table (disabled fails closed, chain confirms, 409 on
  reuse, 400 on wrong-family payTo or malformed tx id), bindings, registry,
  boot check and env

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:11:22 +03:00
0dad9a9170 fix: fail closed on payment confirmation without an on-chain verifier
Security: POST /v1/payments/:id/confirm only verified Arc payments; any
other network confirmed with an arbitrary txHash and granted
entitlements. The API now keeps a per-network verifier registry
(ctx.verifiers: arc via the existing Arc client, base via the generic
EVM client + BASE_RPC_URL + Base USDC, solana via @settlekit/solana)
and confirm/observe reject any network without one.

- a transaction hash settles at most one payment (409 on reuse, also
  on record); EVM hashes are normalized to lowercase
- checkout sessions accept network solana, require a base58 payTo and
  get a fresh Solana Pay paymentReference the tx must include
- observe validates hash/address formats per network (base58 vs 0x)
- compliance screening maps solana to Circle's SOL chain
- env: SOLANA_CLUSTER, SOLANA_RPC_URL, SOLANA_USDC_MINT, BASE_RPC_URL,
  BASE_MIN_CONFIRMATIONS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 14:55:35 +03:00
1739fa5074 test: type the recording verifier result in payments-solana tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:37:41 +03:00
c0b39e38aa fix: fail closed on payment confirmation without an on-chain verifier
Security: POST /v1/payments/:id/confirm only verified Arc payments; any
other network confirmed with an arbitrary txHash and granted
entitlements. The API now keeps a per-network verifier registry
(ctx.verifiers: arc via the existing Arc client, base via the generic
EVM client + BASE_RPC_URL + Base USDC, solana via @settlekit/solana)
and confirm/observe reject any network without one.

- a transaction hash settles at most one payment (409 on reuse, also
  on record); EVM hashes are normalized to lowercase
- checkout sessions accept network solana, require a base58 payTo and
  get a fresh Solana Pay paymentReference the tx must include
- observe validates hash/address formats per network (base58 vs 0x)
- compliance screening maps solana to Circle's SOL chain
- env: SOLANA_CLUSTER, SOLANA_RPC_URL, SOLANA_USDC_MINT, BASE_RPC_URL,
  BASE_MIN_CONFIRMATIONS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 06:24:05 +03:00
pextacy
71e89bdfd8 feat(lepton): attribution package (RFB 6.01) + creator-dashboard
Adds @settlekit/attribution — reuse-detection, weighted provenance lineage,
and HMAC-signed proofs-of-citation — wired live into the rsshub-citation-toll
sidecar (POST /attribution/{detect,proof,verify}) and persisted via
PgLineageStore/PgProofStore over new lepton_lineage_edges + lepton_citation_proofs
tables.

Adds apps/creator-dashboard — a Next.js earnings view in the Statement
greenbar-ledger design system, driven by real domain logic (createSource +
computeRoyaltyDistribution + detectReuse, not mocks). Statement / Sources /
Payouts / Reuse & proofs (interactive) / Wallet. next build green.

Also bundles in-progress settlement hardening: settlement-core idempotency
concurrency, api env validation, bundles + contracts/worker tweaks.

Verified: 943 vitest tests, 27 Foundry tests, next build all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 01:19:22 +03:00
3a52b61096 adas 2026-06-17 03:02:36 +03:00
a8d10c0916 asado 2026-06-17 02:31:22 +03:00
3853551433 asad 2026-06-17 02:09:36 +03:00
32b89f0515 firstof 2026-06-16 02:51:34 +03:00
286b1d4adc feat(api): Postgres persistence + real integration/secrets wiring
Persistence (selected by DATABASE_URL; in-memory fallback otherwise):
- document-projection pattern (codec): canonical entity in metadata.__doc,
  typed columns projected for querying — lossless round-trip despite schema drift.
- async EntityStore<T> (in-memory + Postgres) for products/prices/customers/
  delivery-runs/webhooks/github+discord records.
- Pg adapters for packaged stores: checkout/payment/subscription repositories,
  entitlements, license keys, api keys, saas plans, bundles, agent services.
- seedDefaults() upserts the default org+merchant to satisfy merchant_id FKs.
- context.ts selects Pg vs in-memory; routes awaited end-to-end.
- drizzle migration 0000_init.sql (48 tables) + db:generate/migrate scripts.

Integrations (config/env.ts + config/integrations.ts + wiring/delivery-clients.ts):
- env-driven secrets for Arc/Circle/GitHub/Discord/Resend/S3, partial-group
  validation via ConfigError.
- real delivery clients + Arc x402 verifier when configured; in-memory fallback.

Verified: full purchase->entitlement flow run against a live Postgres 16
(rows persisted + documents round-trip); 590 in-memory tests still pass; 0 TS errors.

x402: pinned-nonce support already added earlier enables stateless verify.
2026-06-15 11:50:50 +03:00
598cd03f05 feat: implement all 8 SettleKit apps + fix x402 nonce round-trip
apps:
- api: Hono REST server, all §26 endpoints, 14 tests
- worker: delivery runner + payment-confirm + access-sync + renewal + webhook-retry jobs wired to real package clients
- dashboard: Next.js merchant dashboard, full §16/§27 sections + §28 product builder
- checkout: Next.js hosted USDC checkout with real delivery materialization
- marketplace: Next.js public marketplace + agent metadata.json route
- admin: Next.js risk/ops console wired to @settlekit/risk + database
- docs: Next.js docs site (9 static routes)
- examples: 5 runnable end-to-end examples

fix(x402): support pinned config.nonce so a stateless verifier can confirm
the challenge nonce round-trips (default stays random; package tests intact).

Full workspace: 590 tests passing (122 files), tsc green for all packages +
api/worker/examples, all 5 Next apps typecheck clean, docs next build green.
2026-06-15 10:49:14 +03:00