Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Idempotency Middleware Laravel Package

bluebeetle/idempotency-middleware

Laravel middleware for idempotent API endpoints that detects duplicate requests by idempotency key and replays the original response. Makes retried POST, payment, and webhook calls safe from double processing with minimal setup.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Retry-safe write endpoints. Idempotency middleware lets clients safely retry non-idempotent POST/PATCH requests (checkout, order creation, payment authorization, refunds) without producing duplicate side effects. This directly de-risks any roadmap item involving money movement, inventory decrement, or one-time provisioning.
  • Mobile / flaky-network reliability. Mobile and offline-first clients retry aggressively on timeout. This package is the cheapest way to make "user tapped Pay twice" or "request timed out, client resubmitted" a non-incident.
  • Webhook ingestion hardening. Inbound webhooks from PSPs and third-party APIs are delivered at-least-once. Middleware-level idempotency keys give you a first line of defense before business logic runs.
  • Build vs. buy (vs. borrow). The alternative is a bespoke middleware: an idempotency-key header contract, a persistent key store with TTL, request fingerprinting, and response replay. That's roughly 1–2 engineering weeks plus ongoing ownership. This package collapses the decision to "evaluate and vendor" rather than "staff a project."
  • Partner/API contract decisions. If you expose a public or partner API, idempotency-key support is increasingly an expectation in API reviews. Adopting it now avoids a breaking contract change later.
  • Roadmap sequencing signal. Low maturity (3 stars, 0 dependents) means this is a capability reference, not a platform commitment. Use it to justify scoping idempotency into the reliability workstream, not to close the workstream.

When to Consider This Package

Consider it when all of the following hold:

  • The service is Laravel/PHP and write traffic flows through HTTP middleware (not primarily queue jobs or gRPC).
  • You have at least one non-idempotent endpoint with real cost to duplication — charges, credits, emails, provisioning, ticket creation.
  • You need response replay semantics (returning the original response for a repeated key), not just deduplication of work.
  • Your team is comfortable owning the code: vendoring/forking, pinning a version, and adding test coverage. Treat it as a starting implementation, not a supported dependency.
  • Traffic is modest or single-region, and a database-backed key store with TTL is acceptable.

Look elsewhere or build in-house when:

  • Scale or concurrency demands atomic guarantees — high-throughput endpoints need a store with compare-and-set semantics (e.g., Redis with SET NX, or a unique constraint plus a request-state machine), and in-flight duplicate requests must be handled, not just completed ones.
  • Maturity and support matter. With 3 stars and 0 dependents, bus factor is effectively one. There is no community to catch regressions, no CVE response, no upgrade path. If your org requires vendor-like assurance, this fails procurement.
  • You need idempotency beyond HTTP — queue consumers, scheduled jobs, or internal service-to-service calls. A middleware package won't cover those; you need a service-level idempotency layer.
  • Your stack is polyglot. A single Laravel-only implementation creates inconsistent guarantees across services; standardize the contract and store instead.
  • You already have a gateway (API gateway, service mesh, PSP SDK) providing idempotency. Don't double-implement.

How to Pitch It (Stakeholders)

To executives: Duplicate charges and duplicate orders are among the most expensive bugs a product can ship — they cost refunds, support hours, and trust. This package is a small, MIT-licensed middleware that makes write endpoints safe to retry, which is the standard defense. The evaluation cost is a few engineering hours; the alternative is a one-to-two-week internal build. Recommend a time-boxed spike, not a commitment: pilot it on one payment-adjacent endpoint, measure, then decide.

To engineering leadership: It's a credible reference implementation of the idempotency-key pattern for Laravel — header contract, key persistence, response replay. But it is a single-maintainer, near-zero-adoption package. Adopt it the way you'd adopt sample code: read the source, fork it into our namespace, pin it, and add integration tests covering concurrent duplicates, key expiry, and fingerprint mismatches. Budget roughly one day of hardening, not zero. If the spike exposes gaps around in-flight request locking or store atomicity, that's our signal to build the thin internal version instead — and we'll have the design already validated by the spike.

One-line summary: Cheap insurance against duplicate side effects, priced correctly at free — but we take on the maintenance, so pilot it narrowly and fork it before it touches money.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core