Stripe Webhook Fails When Processing User Subscription
The webhook fails due to invalid values for periodStart and periodEnd.
To reproduce:
1. Create a new user subscription via Stripe.
2. Wait for the Stripe webhook to be triggered and attempt to update the subscription in the database.
3. Check the server logs for the error.
2025-04-02T23:00:28.177Z ERROR [Better Auth]: Stripe webhook failed. Error:
Invaliddb[getModelName(model)].update()invocation in
C:\Users\ayrto\tibiaprofit.next\server\chunks\node_modules_better-auth_diste7fe42cb..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: "oQdc19odFn60TucUBQ5uqUrf30neRD6R"
},
data: {
plan: "explorer",
stripeSubscriptionId: "sub_1R9aGjGfZ5Enq2zqWc3j4qep",
status: "trialing",
periodStart: new Date("Invalid Date"),
~~~~~~~~
periodEnd: new Date("Invalid Date"),
seats: 1
}
})
Invalid value for argumentperiodStart: Provided Date object is invalid. Expected Date.
To reproduce:
1. Create a new user subscription via Stripe.
2. Wait for the Stripe webhook to be triggered and attempt to update the subscription in the database.
3. Check the server logs for the error.
"@better-auth/stripe": "^1.2.5"
"@prisma/client": "^6.5.0"
"better-auth": "^1.2.4"
"stripe": "^18.0.0"Solution
I believe it's due to this breaking change.
@ayrtonaguiar Do you think you can downgrade your stripe version to
@ayrtonaguiar Do you think you can downgrade your stripe version to
@17.7.0 until this is fixed?
