Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small documentation update #64

Open
williambarberjr opened this issue Jan 16, 2024 · 4 comments
Open

Small documentation update #64

williambarberjr opened this issue Jan 16, 2024 · 4 comments

Comments

@williambarberjr
Copy link

williambarberjr commented Jan 16, 2024

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
Copy link
Contributor

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
Copy link

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 added a commit to derekfinlinson/basejump that referenced this issue Feb 29, 2024
Creating default subscription isn't working since blank defaultPlanId and defaultTrialDays are passed into the getBillingStatus function instead of using the ones passed into the stripeFunctionHandler. Related to usebasejump#64
@salvinoto
Copy link

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?

@kaumac
Copy link

kaumac commented Jan 9, 2025

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!"

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

No branches or pull requests

5 participants