#will1067_node-webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1461438483464982767
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
will1067_node-webhooks
@inland quartz this is common when you use a version of stripe-node pinned to api version A but then your account and/or WebhookEndpoint is pinned to api version B
I recommend reading https://docs.stripe.com/webhooks/versioning and then making sure you create a WebhookEndpoint pinned to the same API version as the stripe-node version you're using
i've read this, and I don't see where is the mismatch. To me it should be all fine
docs (https://github.com/stripe/stripe-node/blob/v20.1.2/CHANGELOG.md#2010---2025-12-16) says :
20.1.0 => "This release changes the pinned API version to 2025-12-15.clover."
and I'm running "stripe": "^20.1.2"
Share your exact code and the exact error you are getting please
stripe.ts :
import 'server-only'
import Stripe from 'stripe'
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
apiVersion: '2025-12-15.clover'
})
route.ts :
export async function POST(request: Request) {
const payload = await request.text()
const sig = request.headers.get("stripe-signature")!
let event: Stripe.Event
try {
event = stripe.webhooks.constructEvent(
payload,
sig,
process.env.STRIPE_WEBHOOK_SECRET!
)
} catch (err) {
console.error("Invalid signature", err)
return new Response("Invalid signature", { status: 400 })
}
switch (event.type) {
case "customer.subscription.created": {
const sub = event.data.object as Stripe.Subscription
console.log(sub.items.total_count)
break
}
}
Property 'total_count' does not exist on type 'ApiList<SubscriptionItem>'.ts(2339)
but webhook send this total_count field. Why sdk doesnt recognize that field ?
total_count was deprecated a while ago and is not in the types so that really is just the issue
Our API has a lot of historical properties that can be returned for historical reasons but are not in public types and are considered deprecated
So it's normal having a mismatch between the sdk and the API ?
aren't the SDK's types generated from the API definition ?
the SDK types matches the public/official API definitions yes and our docs.
But our API internally has extra properties we have deprecated but not actively removed. But if the types had them, then everyone would think they are good and usable.
So yes it is fairly common and it's better to trust the official SDK types and not use anything undocumented
ok; is that documented somewhere ?
I mean, the fact that API and sdk mismatch is known by stripe and that sdk's is the source of truth
not really, it's kind of implicit in a way if you use the SDK and use its types. But there's no specific docs for it
ok
and so I should never encouter a situation where a field exist in the sdk but not on the webhook's payload ?
Lots of properties in our API are optional so they can be in the types but not in the payload (though usually the types will reflect that the property is optional)
But other than that, no as long as you use the same API version on your WebhookEndpoint as the one for the SDK's types it should match
Ok, thanks for your time and have a good day
you too ๐