Type error when subscription plan limits object are not the same #1237

Closed
opened 2026-03-13 08:29:34 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Konixy on GitHub (May 20, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

use this config:

import { betterAuth } from 'better-auth';
import { stripe } from '@better-auth/stripe';
import Stripe from 'stripe';
import { env } from '$env/dynamic/private';

const stripeClient = new Stripe(env.STRIPE_SECRET_KEY!, {
	apiVersion: '2025-04-30.basil'
});

export const auth = betterAuth({
	plugins: [
		stripe({
			stripeClient,
			stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET!,
			createCustomerOnSignUp: true,
			subscription: {
				enabled: true,
				plans: [
					{
						name: 'basic', // the name of the plan, it'll be automatically lower cased when stored in the database
						priceId: 'price_1234567890', // the price ID from stripe
						annualDiscountPriceId: 'price_1234567890', // (optional) the price ID for annual billing with a discount
						limits: {
							teams: 0
						}
					},
					{
						name: 'team',
						priceId: 'price_0987654321',
						limits: {
							teams: 1,
							projects: 10
						},
						freeTrial: {
							days: 14
						}
					}
				]
			}
		})
	]
});

export const testFunction = async () => {
	const subscription = await auth.api.listActiveSubscriptions({});
	console.log(subscription);
};

Notice that the first plan lacks the ⁠projects property when compared to the second plan.
If you put this code your editor there will be a type error in the testFunction, the listActiveSubscriptions function will be undefined (and all other stripe related functions).

I don't know if it's a feature or a bug but if that's normal, please add it to the docs, it took me 2hr to notice that 😅

Current vs. Expected behavior

What version of Better Auth are you using?

1.2.8

Provide environment information

- OS: MacOS (latest)
- Browser: Arc (chromium)
- Editor: Cursor

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)

export const auth = betterAuth({
	plugins: [
		stripe({
			stripeClient,
			stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET!,
			createCustomerOnSignUp: true,
			subscription: {
				enabled: true,
				plans: [
					{
						name: 'basic',
						priceId: 'price_1234567890',
						limits: {
							teams: 0
						}
					},
					{
						name: 'team',
						priceId: 'price_0987654321',
						limits: {
							teams: 1,
							projects: 10
						},
						freeTrial: {
							days: 14
						}
					}
				]
			}
		})
	]
});

Additional context

No response

Originally created by @Konixy on GitHub (May 20, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce use this config: ```typescript import { betterAuth } from 'better-auth'; import { stripe } from '@better-auth/stripe'; import Stripe from 'stripe'; import { env } from '$env/dynamic/private'; const stripeClient = new Stripe(env.STRIPE_SECRET_KEY!, { apiVersion: '2025-04-30.basil' }); export const auth = betterAuth({ plugins: [ stripe({ stripeClient, stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET!, createCustomerOnSignUp: true, subscription: { enabled: true, plans: [ { name: 'basic', // the name of the plan, it'll be automatically lower cased when stored in the database priceId: 'price_1234567890', // the price ID from stripe annualDiscountPriceId: 'price_1234567890', // (optional) the price ID for annual billing with a discount limits: { teams: 0 } }, { name: 'team', priceId: 'price_0987654321', limits: { teams: 1, projects: 10 }, freeTrial: { days: 14 } } ] } }) ] }); export const testFunction = async () => { const subscription = await auth.api.listActiveSubscriptions({}); console.log(subscription); }; ``` Notice that the first plan lacks the ⁠`projects` property when compared to the second plan. If you put this code your editor there will be a type error in the `testFunction`, the `listActiveSubscriptions` function will be undefined (and all other stripe related functions). I don't know if it's a feature or a bug but if that's normal, please add it to the docs, it took me 2hr to notice that 😅 ### Current vs. Expected behavior - ### What version of Better Auth are you using? 1.2.8 ### Provide environment information ```bash - OS: MacOS (latest) - Browser: Arc (chromium) - Editor: Cursor ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript export const auth = betterAuth({ plugins: [ stripe({ stripeClient, stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET!, createCustomerOnSignUp: true, subscription: { enabled: true, plans: [ { name: 'basic', priceId: 'price_1234567890', limits: { teams: 0 } }, { name: 'team', priceId: 'price_0987654321', limits: { teams: 1, projects: 10 }, freeTrial: { days: 14 } } ] } }) ] }); ``` ### Additional context _No response_
Author
Owner

@Kinfe123 commented on GitHub (Aug 10, 2025):

This is more of inconsistent usage. we will see if this is issue that other can fall in to. closing this for now.

@Kinfe123 commented on GitHub (Aug 10, 2025): This is more of inconsistent usage. we will see if this is issue that other can fall in to. closing this for now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1237