How to fix Stripe error
[Better Auth]: Error fetching subscription from Stripe RangeError: Invalid time value
at Date1.toISOString (<anonymous>)
at Array.map (<anonymous>)
at Array.map (<anonymous>)
at Array.map (<anonymous>)
6 Replies
Do you have any code details to potentially share? This is not very descriptive.
Solution
I downgraded Stripe to version 17.7.0, and it works!
Hey, is your webhook running fine?
I am getting problem with subs
no any problem.
can you check #Unable to get access to authClient.stripe.subscription
@TAM
add: authorizeReference
stripe({
stripeClient,
stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
createCustomerOnSignUp: true,
subscription: {
enabled: true,
plans: [
{
name: "pro", // the name of the plan, it'll be automatically lower cased when stored in the database
priceId: process.env.NEXT_PUBLIC_STRIPE_MONTHLY_PRICE_ID, // the price id from stripe
annualDiscountPriceId:
process.env.NEXT_PUBLIC_STRIPE_YEARLY_PRICE_ID, // (optional) the price id for annual billing with a discount
},
],
// updateUserMetadata: true, // Track subscription info in user metadata
authorizeReference: async ({ user, session, referenceId, action }) => {
try {
// Check if the user has permission to manage subscriptions for this reference
if (
action === "upgrade-subscription" ||
action === "cancel-subscription"
) {
const [org] = await db
.select()
.from(schema.members)
.where(
sql
${schema.members.organizationId} = ${referenceId} AND ${schema.members.userId} = ${user.id}
,
)
.limit(1)
return org?.role === "owner"
}
return true
} catch (error) {
console.error("Error authorizing subscription reference:", error)
return false
}
},
....