I am creating a payment gateway using Stripe.
I want to set my localhost url localhost/stripe/webhook.php
as my webhook url. Is it possible to set a localho
Even simpler, add this endpoint to your app when running locally (not in prod!):
const eventsSeen = new Set();
app.post("/test/simulate-stripe-webhook", async (req, res) => {
const events = await stripe.events.list({ limit: req.query.limit || 10 });
for (const event of events) {
if (eventsSeen.has(event.id)) continue;
await processStripeEvent(event);
eventsSeen.add(event.id);
}
return res.status(200).end();
});
...where processStripeEvent
is whatever logic your webhook triggers.
Then there's no need to manage webhooks in stripe.