readConfig required all Dodo values, so the console could not start before
the railyard Dodo brand and products exist (owner item Y-2), although
Railyard is sold inside the Scribase add-on (bridge orgs need no checkout).
Dodo values are now optional: billingReady is true only when the key, the
webhook secret and the three product ids are all set. Without them checkout,
pause and cancel redirect with 'card payments open soon', the webhook answers
503, and everything else runs. Scribase project and session secret stay
required. 4 new tests; console 158/158, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wave E verifier (Y-2/Y-3):
- A card check started a fresh 14-day trial every time: cancel or refund,
pay $1 again (credited back) and get another trial, for $0 net. The
trial now starts only when trial_ends_at is unset; refunds keep it set
and a paid plan marks it used. access() sends a card-on-file org that
used its trial to the plan, and the Billing screen says so.
- startCheckout opened a second plan checkout for an already subscribed
(or cancelling) org, which bills twice; and a second card check for an
org with a card on file. Both are refused (BillingError, ?error=already).
- A refund of an older card-check payment kept its dollar credit, and a
second refund event for the same payment could take it back twice. The
debit now always applies once per payment, tracked in billing_events.
- subscription.* events of a subscription that is not the org's current
one (an old one expiring) no longer end or pause the current plan.
- Deploy records normalise the app name the CLI sends (folder 'My Shop'
-> my-shop) so the second deploy is not a 409; rollback_of must be a
uuid (was a database error).
Tests: 7 new (fail before, pass after); console 37/37, tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Next.js console for Cloudflare Workers (OpenNext config, wrangler.jsonc)
with data in the console's own Scribase project, schema railyard
(migration 0001: orgs, org_members, apps, deploys, entitlements,
billing_events, api_tokens, device_codes; idempotent, RLS on, no anon
grants).
- Sign-in with Google or GitHub through Scribase Auth (PKCE), user read
from the auth server, org and entitlements row created, signed
HttpOnly session.
- Money ladder (pure, immutable): $1 card check credited back to the
customer wallet, 14-day trial with the plan's limits, $19 a month or
$190 a year, pause switch and one-click cancel (ends at the next
billing date; a trial ends now).
- Webhook: Standard Webhooks signature and timestamp verified, replays
ignored by unique message id, signed checkout metadata, other brands
ignored, a refund of the card check reverses the credit and the
trial, a failed wallet call releases the id for the provider's retry.
- Apps, Usage and Billing screens, one primary action each; Add app
shows the deploy command and the Insights tag in two clicks.
- CLI device-flow login and org-scoped hashed tokens for Y-3.
- Test mode only: the live payment host is refused unless the owner
sets RAILYARD_DODO_LIVE=1.
Tests (node --test, 25): journey from sign-in to entitlements and the
snippet, refund, pause and cancel, webhook security, ladder, tokens and
org isolation, PostgREST repo, a component test of Add app with the copy
lint, a next build grep for sentinel secrets in the client bundle, and
the migration applied twice on a scratch Postgres.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>