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>
SettleKit Worker
Background worker for delivery execution, payment confirmation, access sync, renewals, and webhook
retries (plan §17). A real Node ESM service that drives the @settlekit/* domain packages on
interval-based schedules with graceful shutdown.
Jobs
| Job | Cadence env | What it does |
|---|---|---|
delivery-runner |
WORKER_DELIVERY_INTERVAL_MS |
Executes pending delivery runs through @settlekit/delivery DeliveryRunner with the concrete wired clients; retries failed runs. |
payment-confirm |
WORKER_PAYMENT_INTERVAL_MS |
Polls @settlekit/arc verifyUsdcTransfer / getConfirmations, confirms payments via @settlekit/payments, and enqueues delivery. |
access-sync |
WORKER_ACCESS_SYNC_INTERVAL_MS |
Reconciles GitHub (syncAccess) + Discord (syncDiscordAccess) grants; expires due entitlements (@settlekit/entitlements expireDue). |
renewal-sweep |
WORKER_RENEWAL_INTERVAL_MS |
Advances subscriptions, enters grace, and expires via @settlekit/payments. |
webhook-retry |
WORKER_WEBHOOK_RETRY_INTERVAL_MS |
Redelivers failed webhooks via @settlekit/webhooks deliverWithRetry. |
Wiring
src/wiring/delivery-clients.ts builds the concrete adapters that implement the delivery package's
client interfaces, each backed by a REAL package call:
GithubAccessClient→@settlekit/githubDiscordRoleClient→@settlekit/discordLicenseIssuer→@settlekit/license-keysApiKeyIssuer→@settlekit/api-keysFileGrantor→@settlekit/file-deliverySaasEntitler→@settlekit/saasWebhookSender→@settlekit/webhooksEmailSender→@settlekit/notifications
The GitHub/Discord transports, Arc RPC, email transport, and webhook HTTP sender are injectable, so the wiring test exercises the exact production assembly path against in-memory doubles.
Run
pnpm --filter @settlekit/worker build
pnpm --filter @settlekit/worker start
Required env vars are validated at boot (src/config.ts); missing secrets fail fast.