---
title: "Discussion on \"Stripe webhooks in Next.js: verify, deduplicate and process each event once\" | Hashnode"
description: "Discussion on \"Stripe webhooks in Next.js: verify, deduplicate and process each event once\". Stripe delivers events at least once and not always in order. A route handler, an events table and a worker that make retries harmless."
url: "https://hashnode.com/posts/stripe-webhooks-in-next-js-verify-deduplicate-and-process-each-event-once/6ae86d2557dd48491df9ec27"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Stripe webhooks in Next.js: verify, deduplicate and process each event once](https://redliolabs.hashnode.dev/stripe-webhooks-in-next-js-verify-deduplicate-and-process-each-event-once?utm_source=hashnode&utm_medium=feed)

Stripe delivers events at least once and not always in order. A route handler, an events table and a worker that make retries harmless.

Nov 2 · 6 min read · redliolabs.hashnode.dev  
Read the article

-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#stripe](https://hashnode.com/tag/stripe)
-   [#saas](https://hashnode.com/tag/saas)
-   [#webdev](https://hashnode.com/tag/webdev)

## Written by

[Redlio Labs](https://hashnode.com/@redliolabs)

@redliolabs · Ahmedabad, India

  
[View profile](https://hashnode.com/@redliolabs)

Software development company since 2014. Custom software, ERP, SaaS, web and mobile apps for mid-size and large companies.

Redlio Labs is a software development company in Ahmedabad, India, founded in 2014. We design, build and grow custom software, ERP systems, SaaS products and web and mobile apps for mid-size and large companies, and write here about the engineering problems we solve along the way. Rated 5.0 on Clutch and Google. Website: https://redliolabs.com

## Responses 2

Markdown supported · ⌘↵ to post

[Paul Hartness](https://hashnode.com/@retryfix)

[Nov 4](https://hashnode.com/posts/stripe-webhooks-in-next-js-verify-deduplicate-and-process-each-event-once/6ae86d2557dd48491df9ec27/comment/6aeaf8570e75c729b805d936)

Storing first and reading current state from Stripe is the right call, and it matters most for anything that contacts the customer. If the sweeper picks up an invoice.payment\_failed event an hour late, the retry may already have succeeded. Checking the invoice status before sending a failed-payment email saves a confusing message to someone who has already paid.

[Redlio Labs](https://hashnode.com/@redliolabs)

[Nov 18](https://hashnode.com/posts/stripe-webhooks-in-next-js-verify-deduplicate-and-process-each-event-once/6ae86d2557dd48491df9ec27/comment/6aeaf8570e75c729b805d936#reply-6afd55b463ec96656f4425d0)

Thanks Paul, that's a sharper version of the point than the post makes. Anything that emails or charges the customer should re-read the current invoice or subscription from Stripe right before acting, not trust the event payload. A late payment\_failed is exactly the case where the payload is true but stale.
