feat(stripe): make the database the only source of Stripe config #482
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/BUNYIP-482-remove-stripe-env-vars"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stripe configuration was readable from two places, and env won whenever the database row was empty or a field was NULL:
stripe_config_from_env()built a runtime config fromSTRIPE_SECRET_KEY/STRIPE_WEBHOOK_SECRET/STRIPE_SUCCESS_URL/STRIPE_CANCEL_URL/STRIPE_APP_TAG/STRIPE_FREE_PRICE_ID, andstripe_config_from_db_model()used it as the per-field fallback for every NULL column, so an operator who cleared a field in the admin UI silently fell back to whatever the container was started with.The
stripe_configandtier_configrows already hold everything the runtime needs, so delete the env builders and make the DB the single source.unconfigured_stripe_config()replacesstripe_config_from_env()and keepsis_configured()false via the placeholder secrets;success_url_from_env/cancel_url_from_envbecomedefault_success_url/default_cancel_url, still derived from the firstCORS_ORIGINentry sojust devreaches Checkout with only the admin-entered keys.StripeConfigResponse::from_env()becomesunconfigured()reportingsource: "unconfigured", andfree_price_id_from_env()is gone:TierConfigreads the column only.StripeConfig.free_price_idis now alwaysNone, so all fourStripeService::free_price_id()call sites read the liveArc<RwLock<TierConfig>>instead (via the newhandlers::live_free_price_idhelper), which is always fresh after an admin tier-settings save rather than baked in at startup.Operator-facing text that named env vars (the startup webhook-secret warning, the webhook fail-closed message, and the web checkout error, which also matched on the literal secret-key variable name) now points at the admin Stripe page.
The env surface is removed from
compose.dev.yml, the two Stripe key secrets incompose.yml,scripts/init-secrets.sh,.env.example,docs/stripe-test-mode.md, anddocs/e2e.md.STRIPE_ENCRYPTION_KEYand its_FILEvariant stay everywhere: that is at-rest AES-256-GCM key material for the DB row (shared withemail_config), not Stripe API information, and consolidating it is BUNYIP-483.scripts/check-no-stripe-env.shgates the removal in CI andjust check: anySTRIPE_*name outside the encryption-key allowlist fails the build. Committed migrations are excluded because sqlx checksums them and an edit stops a deployed database from booting, so their historical SQL comments stay as written.#BUNYIP-482