#masini_code
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/1325787479357394954
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
What variable type is it?
Does it have the type param?
No it doesnt
Promise {
{
id: 'evt_3QeEXcKxtxyGkem62DIY1vrO',
object: 'event',
api_version: '2024-11-20.acacia',
created: 1736163139,
data: { object: [Object], previous_attributes: [Object] },
livemode: false,
pending_webhooks: 2,
request: { id: null, idempotency_key: null },
type: 'charge.updated'
},
[Symbol(async_id_symbol)]: 104400,
[Symbol(trigger_async_id_symbol)]: 104360,
[Symbol(kResourceStore)]: undefined,
[Symbol(kResourceStore)]: undefined,
[Symbol(kResourceStore)]: {
headers: [Getter],
cookies: [Getter],
mutableCookies: [Getter],
draftMode: [Getter],
reactLoadableManifest: {},
assetPrefix: ''
},
[Symbol(kResourceStore)]: {
isStaticGeneration: false,
urlPathname: '/api/webhook',
pagePath: '/api/webhook/route',
incrementalCache: IncrementalCache {
locks: Map(0) {},
unlocks: Map(0) {},
hasCustomCacheHandler: false,
dev: true,
disableForTestmode: false,
minimalMode: false,
requestHeaders: [Object],
requestProtocol: 'http',
allowedRevalidateHeaderKeys: undefined,
prerenderManifest: [Object],
fetchCacheKeyPrefix: '',
cacheHandler: [FileSystemCache]
},
isRevalidate: false,
isPrerendering: undefined,
fetchCache: undefined,
isOnDemandRevalidate: undefined,
isDraftMode: undefined,
prerenderState: null,
requestEndedState: undefined,
revalidate: 0
},
[Symbol(kResourceStore)]: undefined,
[Symbol(kResourceStore)]: undefined,
[Symbol(kResourceStore)]: { isAppRoute: true, isAction: false },
[Symbol(kResourceStore)]: undefined
}
I just noticed that the log returns "Promise" in the start... however this doesn't make sense compared with the documentation for the Stripe SDK
stripe.webhooks.constructEvent(body, sig, WEBHOOK_SECRET)
(method) Stripe.Webhooks.constructEvent(payload: string | Buffer, header: string | Buffer | Array<string>, secret: string, tolerance?: number, cryptoProvider?: Stripe.CryptoProvider, receivedAt?: number): Stripe.Event
Constructs and verifies the signature of an Event from the provided details.
@throws โ Stripe.errors.StripeSignatureVerificationError
Here, we can see that the return type is not a Promise but a Stripe.Event
In fact there are no typescript errors in my route handler nor in my stripe functions file
Have you tried handling it as a Promise? Does it work then?
Will try it now give me a second
Now it works...
But does this mean that all the other projects which I have webhooks integrated are going to break automatically? As in those projects I did not handle the function as a Promise and they were working fine at the time of implementation
I don't think anything would change unless you update the Stripe library version.
Ok, thanks for the help