#V8.-signature
1 messages · Page 1 of 1 (latest)
Yes!
There could be various reason. Which programming language? And which Doc are you following?
node
Which Doc are you following>?
this one at the moment
How does your code look like? Do you use req.body specifically?
app.use(bodyParser.urlencoded({ extended: true }));
const endpointSecret = 'DW ABOUT THIS ';
app.post('/webhook', function(request, response) {
const sig = request.headers['Stripe-Signature'];
const body = request.body;
let event = null;
try {
console.log('made it to event')
event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret);
} catch (err) {
console.log('invalid signature')
response.status(400).end();
return;
}
console.log('made it past event')
let intent = null;
switch (event['type']) {
case 'payment_intent.succeeded':
console.log('made it')
intent = event.data.object;
channel.send({content: 'test'})
break;
case 'payment_intent.payment_failed':
intent = event.data.object;
const message = intent.last_payment_error && intent.last_payment_error.message;
console.log('Failed:', intent.id, message);
break;
}
response.sendStatus(200);
});
const port = process.env.PORT || 4242;
app.listen(port, () => {
console.log(`Express Server is now running on port ${port} `);
});```
@slender wave
qq do you use https://expressjs.com/en/starter/generator.html to generate this express app?
I see
app.use(express.json())
it will set the JSON parser on all request bodies by default, and that alter the raw body from Stripe
I did not, found this on the docs i think??
np, just try removing these lines
app.use(express.json())
app.use(bodyParser.urlencoded({ extended: true }));
done
Have you resolved the error?
This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.