#praveen____
1 messages · Page 1 of 1 (latest)
The issue is you're not passing the raw payload to constructEvent which it expects. You're passing a JSON string
stripe.webhooks.constructEvent(data, sig, "whsec_xxx")
But if i passing this I am getting this
Signature verification is impossible without access to the original signed material.```
Can you share your full function/route code for the webhook?
sure
I suspect whatever framework you're using parses the payload in some way
@Post(`subscription-webhook`)
async handleSubscriptionWebhook(
@Body() data: any,
@Headers("stripe-signature") sig: string
) {
console.log("called", typeof sig, sig)
return await this.stripeService.handleSubscriptionWebhook(data, sig)
}```
//function
``` async handleSubscriptionWebhook(data: any, sig: string) {
const raw_data = JSON.stringify(data)
const event = this.stripe.webhooks.constructEvent(data, sig, "whsec_d82a6759d034f42427e403fdcc92ac7e7e012086b42d7d1d256c85f0e1404d90")
}```
I think all data coming correctly. Not sure how the constructEvent function is working
I suspect whatever framework you're using parses the payload in some way. So when you get data from the body, Nest (?) has already parsed it
You can prevent that in things like Express with express.raw (see example here: https://stripe.com/docs/webhooks/quickstart?lang=node)
I imagine something similar exists for Nest
Seems like a couple changes to your code should solve it!
np
Hi! I'm taking over my colleague. Please, let me know if you have any other questions.
Thanks it is working
Glad to hear that!