#planetcreate

1 messages · Page 1 of 1 (latest)

obsidian wharfBOT
cold egret
#

can you share your code snippet?

#

Also, how are you testing webhooks? Are you using the Stripe CLI?

sturdy tartan
#

router code: router.post('/Succespayment', async (req, res) => {
const sig = req.headers['stripe-signature']
if (!sig){
res.status(400).send(no stripe-signature found)
return
}
const rawBody = req.rawBody
let event
try {
event = stripe.webhooks.constructEvent(rawBody, sig, WebhookSecret)
res.send()
} catch (error) {
res.status(400).send(Webhook Error: ${error.message} + ${rawBody} + ${sig})
return
}
}) and the raw data code: app.use((req, res, next) => {
if (req.originalUrl === '/Succespayment') {
req.session.giftcode = 'succes'
req.rawBody = '';
req.setEncoding('utf8');
req.on('data', chunk => {
req.rawBody += chunk;
});
req.on('end', next);
} else {
express.json()(req, res, next)
}
});

#

i am testing the webhook on a google cloud webserver with app engine.

cold egret
#

are you using Express.js?

sturdy tartan
#

yes i am using express.js with node.js

cold egret
sturdy tartan
#

i have already tried that and i got the same error message.

#

but, i can try again

cold egret
#

if you just download our sample, update the webhook secret, and run it as it is - check if that works for you

sturdy tartan
#

oke i will do that.