#praveen____

1 messages · Page 1 of 1 (latest)

sudden grottoBOT
sick aspen
#

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")
marble scarab
#

But if i passing this I am getting this

Signature verification is impossible without access to the original signed material.```
sick aspen
#

Can you share your full function/route code for the webhook?

marble scarab
#

sure

sick aspen
#

I suspect whatever framework you're using parses the payload in some way

sudden grottoBOT
marble scarab
#
  @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")

  }```
marble scarab
sick aspen
#

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

#

I imagine something similar exists for Nest

#

Seems like a couple changes to your code should solve it!

marble scarab
#

I will try if its not working i will let you know

#

thanks for replying ❤️

sick aspen
#

np

prime widget
#

Hi! I'm taking over my colleague. Please, let me know if you have any other questions.

marble scarab
#

Thanks it is working

prime widget
#

Glad to hear that!