Repository navigation
feat(billing): choose the payment provider and catalog from env settings - #41
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lemon Squeezy is winding down, and moving CourseLit between Dodo and Lemon Squeezy has needed code changes each time. This adds
@codelitdev/billing/providers/envso a product switches provider by changing settings.readBillingProviderEnv(env, { offers })readsBILLING_PROVIDER(dodoorlemonsqueezy), the catalog revision, currency, encryption key and each offer'sBILLING_<OFFER>_AMOUNT_MINORand_PRODUCT_ID, and checks that provider's credentials. It returns null whenBILLING_PROVIDERis unset, and names the missing or invalid setting otherwise.createBillingProvidersFromEnv(providers, env, clock)builds the adapters with dynamic imports, sododopaymentsis needed only with Dodo.dodoOptionsFromEnvandlemonSqueezyOptionsFromEnvbuild options alone (Dodo now also takesDODO_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 andtest:packedpass.