The claimTxHash flow is designed so the worker's payment-confirm job can
finish confirming a payment even after the buyer closes the tab (an agent
that never polls hits the same path). But the job only flipped the payment
to "confirmed" and emitted the webhook — it never completed the checkout
session or created an entitlement, both of which only happened in the
buyer-driven confirmOnce/fulfillOnce flow and the API's /payments/:id/confirm
route.
Result: a payment the worker confirms settles on-chain and fires the
seller's webhook, but the session stays "open" forever, so the success/
receipt page 409s "not paid yet" indefinitely and no entitlement is ever
created — the GitHub/Discord retry jobs have nothing to retry since they
only act on entitlements that already exist.
Add WorkerStore.saveCheckoutSession (in-memory + Postgres) and complete the
session + grant a payment entitlement per line item right after the worker
confirms a payment, guarded against double-granting.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The rotation grace check used the wall clock while the job used ctx.now(),
so the retry test started failing once its fixed grace date passed.
The repo already declared MIT in package.json and contract SPDX headers;
add the LICENSE file so GitHub shows it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
- render.yaml deploys the five buyer/seller services on Node 22 with every
env var the new surfaces read (chains, routing, HyperCore, Zcash, x402/MPP,
onchain billing, service token, Discord, fee); Node builds install only the
app and its workspace deps (pnpm --filter <app>...). Free plans everywhere
except the worker (Render has no free background workers: starter).
- API/worker Dockerfiles install filtered; the API runs migrations on boot
because preDeployCommand is paid-only.
- worker boots without GitHub App / Resend / Discord credentials: those
deliveries stay pending and emails are skipped with a warning.
- .env.example documents the service token, manage-link secret and Discord OAuth.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- checkout: buyers connect Discord (OAuth2 identify + guilds.join) in the
delivery-fields step; the callback saves their user id on the session and
joins them to the product's server. After payment the bot adds the role via
PUT /guilds/{guild}/members/{user}/roles/{role}; the grant is recorded for
access-sync revocation. Without DISCORD_BOT_TOKEN the buyer sees
"pending setup" instead of a fake success.
- worker: discord-delivery-retry grants pending Discord entitlements once the
bot is configured (backoff per entitlement); DISCORD_BOT_TOKEN is optional.
- api: a configured bot delivers roles even before GitHub is set up;
checkout subscriptions pass the buyer's Discord / GitHub ids so subscription
delivery reaches the right accounts.
- dashboard: product settings explain server / role ids and link the bot invite.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shared outbox in @settlekit/persistence writes one idempotent webhook_events
row per (org, type, business key) and queues a worker_webhook_jobs delivery per
subscribed endpoint; the worker signs and retries them (capped attempts).
payment.confirmed is emitted from checkout, worker confirmations, API confirms
and agent payments; subscription.charged (+ payment.confirmed) from every
collected onchain period. In-memory API mode delivers in-process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- @settlekit/hyperliquid createHyperCoreUsdSender: operator-signed usdSend
(EIP-712 via viem), submitted through the HyperCore client; the L1 hash is
read back from the operator ledger (action digest as a labelled fallback).
The API wires it as the HyperCore refund sender when HYPERCORE_ENABLED and
an operator key (HYPERCORE_REFUND_PRIVATE_KEY or the billing operator key)
are set. BillingNetwork is now PaymentNetwork; the renewal-invoice and
access-hook network casts are gone.
- Access hooks call queueDelivery on the first successful charge and when an
expired (suspended) subscription is paid again. API: runs the product's
delivery actions inline through the real handler registry and persists the
run (retryable via /v1/delivery-runs/:id/retry), minting the entitlement
first when needed. Worker: enqueues a pending run on the worker delivery
queue for the delivery-runner job. Both idempotent per charge payment id;
a delivery failure never undoes the charge.
- deliveryActionsFor moved into @settlekit/delivery (zod-free) and shared by
the API agent-payments path and the worker.
- Onchain billing routes use requireOwned / requireOwnedPayment: product
ownership on subscription create, linked core subscription ownership,
foreign customer ids refused on subscription and escrow create.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Registers the per-period charge job (WORKER_SUBSCRIPTION_CHARGE_INTERVAL_MS,
default 5 min) over the shared onchain-billing runtime and Postgres
stores; dunning on failure, entitlement suspension when exhausted,
extension on success. No-op until onchain billing is configured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- jobs/route-watch.ts: polls in-flight any-token routes (Relay / LI.FI) and
records a payment ONLY after the destination fill passes the session
network's fail-closed verifier (Transfer to payTo >= amount owed, after
session creation, hash not used by another payment); provider success
without such a transfer stays unpaid and backs off; refunds are logged
- payment verification: hypercore via the payee's ledger (HYPERCORE_*),
routed fills skip only the payer / Solana reference / Tempo memo bindings
(Solana fills are bound by block time), requireMemo sessions need
transferWithMemo, pending results carry retryable/claimable
- config: HYPERCORE_*, ROUTING_*, WORKER_ROUTE_WATCH_INTERVAL_MS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New @settlekit/hyperliquid on @nktkas/hyperliquid (MIT): EIP-712 usdSend
typed data pinned by golden vectors against the SDK signer, submission of
buyer-signed actions, and fail-closed verification through the payee's
userNonFundingLedgerUpdates (destination == payTo, USDC >= expected, time >=
session creation, payer binding). HYPERCORE_ENABLED / NETWORK / API_URL env.
Registers the workspace packages in the lockfile (filtered install; unrelated
peer rewrites reverted).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checkout stores a GitHub entitlement as pending when the merchant's GitHub
App is not set up yet (or GitHub fails) and nothing retried it. The new
github-delivery-retry job (every 2 min, WORKER_GITHUB_RETRY_INTERVAL_MS)
re-delivers pending repo/team entitlements of confirmed payments through
the real GitHub App access client once an installation id is configured,
then marks them active. Targets come from the entitlement or product
metadata and the username from the checkout session; payments owned by the
delivery runner are skipped; failures back off 5 min doubling to 6 h.
The worker also accepts GITHUB_APP_INSTALLATION_ID (the checkout's name)
and gains WorkerStore.getProduct for product delivery metadata.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- 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>
.env.example and render.yaml (api + worker) list SETTLEKIT_CHAIN_ENV,
ENABLED_EVM_CHAINS, per-chain RPC/NETWORK/MIN_CONFIRMATIONS, Solana and
Zcash settings; api/worker tsconfig reference @settlekit/chains and
@settlekit/zcash; the UI explorer map covers every PaymentNetwork.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- config: loadEvmChains + Zcash (ZCASH_ENABLED, explorer, confirmations)
and WORKER_ZCASH_WATCH_INTERVAL_MS (default 90s)
- payment verification routes every EVM key through @settlekit/chains
(Arc moves onto the same path; chain-id asserted), Solana as before, and
Zcash against the locked quote; late Zcash payments go to manual review;
payTo resolves per network and acceptedNetworks is honoured
- new zcash-watch job: no network call unless open watchable Zcash
sessions exist, one explorer call per payTo, exact-amount match, attaches
or records the pending payment and never reuses a txid
- chains: transport failures are retryable rpc_unavailable, never paid
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/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>
@settlekit/chains carries the verified EVM registry (Ethereum, Base,
Arbitrum, Robinhood Chain, HyperEVM, Tempo, Arc; mainnet + testnet), a
generic stablecoin verifier over the arc EvmRpc seam (chain-id assertion,
receipt status, token/payTo/amount, confirmations, block time vs session,
payer binding, Tempo TIP-20 memo), CAIP-2 ids, network-aware tx-hash and
payTo rules, env loaders (SETTLEKIT_CHAIN_ENV, ENABLED_EVM_CHAINS, per-chain
overrides, Zcash) and the settlement-verifier contract. Tests replay
receipts recorded from each chain's public RPC.
PaymentNetwork widens to solana|base|arc|ethereum|arbitrum|robinhood|
hyperevm|tempo|zcash and CheckoutSession gains settlementQuote,
payerAddress, acceptedNetworks and payToByNetwork. The hosted checkout
fails closed on the new networks until its wave-2 UI lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OperatorAgent drives the Anthropic SDK tool runner (betaZodTool) over read
tools (treasury state, open bills, counterparty risk, payment history, x402
quotes) and policy-checked action tools that require rationale,
alternatives and confidence. claude-sonnet-5 handles revenue and ticks,
claude-opus-5-5 bills, refunds and disputes; at most 12 iterations, with
HeuristicOperator fallback when no key is set or the API fails.
OperatorService turns each event into one hash-chained DecisionRecord with
the tool trace, verdict, usage cost and outcome. The vault anchors a
pre-execution commitment hash of the reasoning; owner approvals, rejections
and 72h expiries are recorded as decisions too. Invoice and customer text
is passed as escaped untrusted data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The payment-confirm job verified every pending payment on Arc with
to = the USDC contract address instead of the merchant's payTo, so a
transfer to anyone could confirm. It now loads the payment's checkout
session (new WorkerStore.getCheckoutSession, in-memory + Pg) and routes
by network: Arc via the Arc client against session.payToAddress, Solana
via @settlekit/solana (base58 signature, session paymentReference, no
0x check). Networks the worker cannot verify (base/ethereum, or solana
without SOLANA_CLUSTER) stay pending — fail closed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The payment-confirm job verified every pending payment on Arc with
to = the USDC contract address instead of the merchant's payTo, so a
transfer to anyone could confirm. It now loads the payment's checkout
session (new WorkerStore.getCheckoutSession, in-memory + Pg) and routes
by network: Arc via the Arc client against session.payToAddress, Solana
via @settlekit/solana (base58 signature, session paymentReference, no
0x check). Networks the worker cannot verify (base/ethereum, or solana
without SOLANA_CLUSTER) stay pending — fail closed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Root cause: isomorphic ids.ts uses globalThis.crypto (a global only in Node 20+, per engines.node>=20). A Vercel project building on Node 18 has no global crypto, so any page generating an id at build time throws and the deploy fails.
- Add .node-version=20 to repo root + every app (Vercel reads it from each app's Root Directory) so deploys use Node 20.
- ids.ts: resolve Web Crypto lazily with an actionable error instead of a cryptic undefined access — still browser-safe (no node:crypto import).
- 1304 tests / 213 suites, typecheck + full build green.
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>