I'm using the stripe webhook to add the purchased products to my sql database when the checkout.session.completed happens, here is my code:
router.post('/webhook', bodyParser.raw({ type: 'application/json' }), (request, response) => { const sig = request.headers['stripe-signature']; let event; try { event = stripe.webhooks.constructEvent(request.body, sig, endpointSecret); } 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; //here i want to increment the product's buy counter by 1 in the database but stripe only gives name and price, which are not unique, so i need the product id } // Return a response to acknowledge receipt of the event response.json({ received: true }); }); I'm using Sequelize so i need to execute something like this when checkout.session.completed happens:
products.findOne({ where: product_id: the purchased product id }).then(product => { product.update({ buy_counter: product.buy_counter++}) } Any way I can find the product ID of the products in the Stripe session