basejump icon indicating copy to clipboard operation
basejump copied to clipboard

Small documentation update

Open williambarberjr opened this issue 2 years ago • 4 comments

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/[email protected]/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!

williambarberjr avatar Jan 16 '24 21:01 williambarberjr

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

tiniscule avatar Jan 17 '24 14:01 tiniscule

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.

derekfinlinson avatar Feb 26 '24 15:02 derekfinlinson

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?

salvinoto avatar Apr 06 '24 22:04 salvinoto

This is so much better!

I stared at my screen for 5 minutes looking at https://<your-instance>.com/billing-webhooks and thinking "that makes no sense!"

kaumac avatar Jan 09 '25 07:01 kaumac