usebasejump / basejump

Teams, personal accounts, permissions and billing for your Supabase app
https://usebasejump.com
MIT License
712 stars 64 forks source link

Small documentation update #64

Open williambarberjr opened 10 months ago

williambarberjr commented 10 months ago

I'm looking into how to Default users into a free plan. The docs for setting up stripe (https://usebasejump.com/docs/billing-stripe) suggest that this setting is in the basejump.config table but that table only has these columns: image

The docs later link to an environment variables page that returns a 404 (https://usebasejump.com/docs/environment-variables). The .env file does have a var for STRIPE_DEFAULT_TRIAL_DAYS. I'm guessing I could hack this default into a free plan by setting STRIPE_DEFAULT_TRIAL_DAYS to 0 and setting the STRIPE_DEFAULT_PLAN_ID to a free plan?

Either way some details on how to do that would be useful.

I would probably also change this: Endpoint URL: https://<your-instance>.com/billing-webhooks

To: Endpoint URL: https://<yourSupabaseProjRef>.supabase.co/functions/v1/billing-webhooks

Also, with my wsl setup, when I run supabase link, I get the warning: Failed to save database password: Keyring is not supported on WSL

And as a result, I have to supply --project-ref flags for each of these commands to make the edge functions deploy correctly: supabase secrets set --project-ref myrefid STRIPE_API_KEY=sk_test_mykey supabase functions deploy --project-ref myrefid billing-webhooks --no-verify-jwt

Finally, I've tried clearing my npm cache with npm cache clean --force and still, when I run: npx @usebasejump/cli@latest init

It puts an index.ts file in supabase/functions/billing-functions that has this line in it: import {billingFunctionsWrapper, stripeFunctionHandler} from "https://deno.land/x/basejump@v2.0.1/billing-functions/mod.ts";

Which isn't the latest version of basejump and doesn't deploy correctly. The current main branch of this repo uses: import {billingFunctionsWrapper, stripeFunctionHandler} from "../deno-packages/billing-functions/mod.ts";

Apologies for the lack of organization here or standard process. I'm a finance bro trying to hack together a web app and haven't gotten around to learning git/github yet so this is the best I could do for now!

tiniscule commented 10 months ago

This is awesome - thank you! I'll make these changes shortly.

As for defaulting into a free plan. Yes you can set the trial days to 0 and the plan_id to the free one you've created in Stripe. That will work just fine. I'll add a quick how-to on each of the billing scenarios listed here: https://usebasejump.com/docs/billing-stripe

derekfinlinson commented 8 months ago

I'm having similar issue getting it to start a trial subscription. I've added the STRIPE_DEFAULT_PLAN_ID and STRIPE_DEFAULT_TRIAL_DAYS as secrets to the edge functions and see them in the logs when it executes the get_billing_status function. But it's only creating a customer and not a subscription.

Digging through the function code, it appears the issue may be in the stripe-function-handler. The default plan id and trial days are passed into the handler. The getBillingStatus function in the handler also has them passed in as parameters. And the get-billing-status function that calls the stripe getBillingStatus isn't passing in any values for default plan id or trial days.

Or I may just be misreading how the code works and it's just an issue with something I'm doing.

salvinoto commented 7 months ago

Hi I'm also struggling with this. I can't figure out how to start off a customer with a free plan? I set trial days to 0 and set a price ID in the env, and started my local supabase instance. I can see me plans when I fetch them so stripe is properly set up. Will this only apply if I create a new user or something since I changed it after the fact?