Skip to content

feat(billing): choose the payment provider and catalog from env settings - #41

Merged
clbotdev merged 2 commits into
mainfrom
feat/billing-provider-from-env
Nov 17, 2026
Merged

clbotdev merged 2 commits into
mainfrom
feat/billing-provider-from-env

Conversation

@clbotdev

Copy link
Copy Markdown
Contributor

Lemon Squeezy is winding down, and moving CourseLit between Dodo and Lemon Squeezy has needed code changes each time. This adds @codelitdev/billing/providers/env so a product switches provider by changing settings.

  • readBillingProviderEnv(env, { offers }) reads BILLING_PROVIDER (dodo or lemonsqueezy), the catalog revision, currency, encryption key and each offer's BILLING_<OFFER>_AMOUNT_MINOR and _PRODUCT_ID, and checks that provider's credentials. It returns null when BILLING_PROVIDER is unset, and names the missing or invalid setting otherwise.
  • Any other provider whose credentials are set stays connected, so its existing subscribers keep receiving webhooks after a switch.
  • createBillingProvidersFromEnv(providers, env, clock) builds the adapters with dynamic imports, so dodopayments is needed only with Dodo.
  • dodoOptionsFromEnv and lemonSqueezyOptionsFromEnv build options alone (Dodo now also takes DODO_PAYMENTS_WEBHOOK_KEY_PREVIOUS).

The env record is passed in; the package still never reads the process environment. Based on MediaLit's existing parsing, which uses the same names. ADR 0019 records the decision; README has a "Choosing the provider by settings" section; changeset is a minor bump.

Tests: bun test (171 pass), typecheck, lint, build and test:packed pass.

@clbotdev
clbotdev merged commit 0a54e5a into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants