#Mao

1 messages · Page 1 of 1 (latest)

mortal gustBOT
midnight reef
#

Hi there!

tough gazelle
#

Hi Soma !

midnight reef
#

This is a classic issue. And the 2 main causes are:

  • Using the wrong webhook endpoint secret, so can you double check that?
  • And not using the raw body
#

Are you using Node + Express?

tough gazelle
#

For the secret I use the one that is returned in my terminal after running this command:

stripe listen --forward-to localhost:9002/stripe/webhook
#

I use NodeJS and Express exactly

#

I think the problem must come from my way of sending the payload

midnight reef
#

Could you try using something like this for your route:

xxx.post("/stripe/webhook", express.raw({ type: "application/json" }), async (req, res) => { ... });

This way req.body should be the raw body.

tough gazelle
#

Currently I have that, it's same no ?

app.route("/stripe/webhook")
    .post(CommandeController.webhook, bodyParser.raw({ type: 'application/json' }));
#

Because I can't access express function

midnight reef
#

Not sure, have you tried this? Is it working?

tough gazelle
#

I have a question, it looks like correct sig ?

t=1663322291,v1=c18928949b35b88655b410f6de1ed659d49a68dcf6507810fe624babb24e9951,v0=879bab0b9791aa036f0186d737452f66e6ca8f956ede89b61564766dd8fcea4
const sig = String(req.headers['stripe-signature']);
tough gazelle
#

I have only RawListeners

midnight reef
#

it looks like correct sig ?
Yes it looks okay to me.
No I haven't tried, because I can't find the .raw function
I recommend following what we do in the documentation with express.raw({ type: "application/json" }): https://stripe.com/docs/webhooks/quickstart?lang=node

tough gazelle
#

Ok, I just have to find the raw function, and I'll see

#

Beacause I use that of my routes :

import { Application } from "express";
midnight reef
#

In the doc we use const express = require('express');