Incorrect docs: uauth.api.listActiveSubscriptions does not exist
The documentation for the Stripe plugin shows this server-side function:
const subscriptions = await auth.api.listActiveSubscriptions({
query: {
referenceId: '123',
},
// This endpoint requires session cookies.
headers: await headers(),
});
However, the method does not exist on the better auth server side object at all. Are the docs incorrect here? I'm using better-auth ^1.3.7 and better-auth/stripe ^1.3.7Solution:Jump to solution
It is working now. I think the issue was that I needed to add subscription plans to my better auth server configuration. Thanks-
3 Replies
Works for me, can you show me your auth config & tsconfig?
Sure. Here is my tsconfig:
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
Here is my auth config:
export const auth = betterAuth({
baseURL: envPublic.PUBLIC_BETTER_AUTH_BASE_URL as string,
secret: envPrivate.BETTER_AUTH_SECRET as string,
database: drizzleAdapter(db, {
provider: 'pg',
schema: schema
}),
user: {
deleteUser: {
enabled: true
}
},
socialProviders: {
google: {
clientId: envPrivate.GOOGLE_OAUTH_CLIENT_ID as string,
clientSecret: envPrivate.GOOGLE_OAUTH_CLIENT_SECRET as string,
disableSignUp: envPrivate.SIGNUP_ENABLED === 'false'
}
},
plugins: [
sveltekitCookies(getRequestEvent),
stripe({
stripeClient: stripeClient,
stripeWebhookSecret: envPrivate.STRIPE_WEBHOOK_SECRET as string,
createCustomerOnSignUp: true
})
]
});
export type Session = typeof auth.$Infer.Session;
export type User = typeof auth.$Infer.Session.user;
Solution
It is working now. I think the issue was that I needed to add subscription plans to my better auth server configuration. Thanks-