Stripe not handling subscription.update events from Billing Portal.
As the title states. I create a subscription for my user. If the user cancels their subscription from their billing portal, this isnt reflected in the database. Instead, I have to use the cancel() and restore() functions from better-auth. Is this normal?
Better auth config:
export const auth = betterAuth({
baseURL: envPublic.PUBLIC_BETTER_AUTH_BASE_URL as string,
secret: envPrivate.BETTER_AUTH_SECRET as string,
logger: {
disabled: false,
level: envPublic.PUBLIC_ENV === 'production' ? 'warn' : 'debug'
},
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,
subscription: {
enabled: true,
plans: [
{
name: plans.pro.id,
priceId: plans.pro.price?.monthly?.id,
annualDiscountPriceId: plans.pro.price?.annual?.id
}
]
}
})
]
});
export type Session = typeof auth.$Infer.Session;
export type User = typeof auth.$Infer.Session.user;
2 Replies