Unable to get access to authClient.stripe.subscription

import { emailOTPClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import { stripeClient } from "@better-auth/stripe/client"

export const authClient = createAuthClient({
/** the base url of the server (optional if you're using the same domain) */
baseURL: "http://localhost:3000",
plugins: [
emailOTPClient(),
stripeClient({
subscription: true,
}),
],
});

export const { signIn, signUp, useSession, signOut, stripe } = authClient;
import { emailOTPClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import { stripeClient } from "@better-auth/stripe/client"

export const authClient = createAuthClient({
/** the base url of the server (optional if you're using the same domain) */
baseURL: "http://localhost:3000",
plugins: [
emailOTPClient(),
stripeClient({
subscription: true,
}),
],
});

export const { signIn, signUp, useSession, signOut, stripe } = authClient;
When I do authClient.stripe. it only shows webhook as option? Also, I dont know why but when user pays for sub, the webhook is not updating the data in db.
2 Replies
shadow
shadowOP2w ago
auth.ts
plugins: [
stripe({
stripeClient,
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
createCustomerOnSignUp: true,
subscription: {
enabled: true,
plans: async () => {
const products = await stripeClient.products.list();

const plans = products.data.map((product) => ({
name: product.name,
priceId: product.default_price as string | undefined,
}));

return plans;
},
},
}),
]
plugins: [
stripe({
stripeClient,
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
createCustomerOnSignUp: true,
subscription: {
enabled: true,
plans: async () => {
const products = await stripeClient.products.list();

const plans = products.data.map((product) => ({
name: product.name,
priceId: product.default_price as string | undefined,
}));

return plans;
},
},
}),
]
is it supposed to not automatically update the user in db? Invalid db[getModelName(model)].update() invocation in /Users/mayanktripathi/Projects/adam/prod/bv-prod/.next/server/chunks/58a27_better-auth_dist77281df6..js:3150:62 3147 } 3148 const whereClause = convertWhereClause(model, where); 3149 const transformed = transformInput(update, model, "update"); → 3150 const result = await db[getModelName(model)].update({ where: { id: "cus_S5ZkzLrh2oHinN" }, data: { plan: "pro", stripeSubscriptionId: "sub_1RBPxKLW6jnevwpozuutGeB4", status: "active", periodStart: new Date("Invalid Date"), ~~~~~~~~ periodEnd: new Date("Invalid Date"), seats: 1 } }) Invalid value for argument periodStart: Provided Date object is invalid. Expected Date. getting this now https://docs.stripe.com/changelog/basil/2025-03-31/deprecate-subscription-current-period-start-and-end I will probably open a PR for this Stripe deprecated the current_period_start and current_period_end fields on the subscriptions API on March 31, 2025, and instead, you should use the current_period_start and current_period_end fields on the items[] field.
shadow
shadowOP2w ago
GitHub
Fix stripe webhook handler by Evy04 · Pull Request #2173 · better...
Temp fix for #2171 Not sure if multiple items needs to be handled, since sub will likely not have multiple

Did you find this page helpful?