I have read the stripe documentation regarding processing of payments and so on, but it doesn't work for me. Here is what I am trying to do:
const endpointSecret = 'whsec_*';
router.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {
const payload = request.body;
const sig = request.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(payload, sig, endpointSecret);
console.log(event)
} catch (err) {
return response.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle the checkout.session.completed event
if (event.type === 'checkout.session.completed') {
const session = event.data.object;
// Fulfill the purchase...
fulfillOrder(session);
}
response.status(200);
});
function that I am calling, just in case
const fulfillOrder = (session) => {
// TODO: fill me in
console.log("Fulfilling order", session);
}
But when I try to trigger an event, I don't see no messages in the Terminal of the server. This makes me unsecure if it is working or no, so I can't do any further actions.
Here is a screenshot from the dashboard, just to prove that it is all running up as needed, in my opinion.