E-commerce11 min read

Idempotent payment webhooks to avoid double charges in 2026

Mohamed Bah·Fondateur, Kolonell
August 25, 2026
Share:
Idempotent payment webhooks to avoid double charges in 2026

Idempotent payment webhooks to avoid double charges in 2026

E-commerce

The verdict in three sentences

Payment providers replay a webhook if they don't get your 200 in time: it is by design, and it means the same event will arrive several times. Without protection, each replay can create a second order, a second email, a second stock deduction — even a double credit. The safeguard is idempotency: a unique key (event_id) guaranteeing an event is processed only once, no matter how many replays.

Application-level dedup vs database constraint

Two strategies exist. Application-level deduplication checks in memory/cache whether the ID was already seen; the database constraint puts a unique index on event_id and lets the database reject the duplicate. The second is safest because it withstands concurrent processing.

StrategyConcurrency reliabilityComplexityVerdict
In-memory dedupLowLowInsufficient alone
Cache dedup (Redis)MediumMediumOK with TTL
Unique DB constraintHighLowRecommended
Cache + DB constraintVery highMediumIdeal at high volume

2026 idempotency parameters

The idempotency key is the event_id provided by Wave/Paystack. You store it with a TTL, and on receiving a duplicate you return 200 without reprocessing. Goal: never depend on timing luck.

Parameter2026 valueRole
Idempotency keyevent_idUnique event identifier
StorageDedicated table + unique indexGuaranteed duplicate rejection
TTL72 hCovers the replay window
Response on duplicate200 (OK)Stop the replays
Share of replays0.5 to 2 % of webhooksReal observed volume
DB transactionInsert + processing atomicAll or nothing
Provider replay windowup to 72 hAlign the TTL to it

Best practice: wrap the key insertion and the business processing in a single transaction. If the insert violates the constraint (duplicate), roll back and return 200 — no side effects.

A referral program to fund this work

These engineering topics look technical, but they sell: any merchant who has ever shipped twice or credited a customer twice understands the value. At Kolonell, our business-referral (apporteur d'affaires) program pays anyone who refers a project — you don't need to be a developer, just to know of a need.

Need a professional website?

Kolonell builds websites that attract clients, optimized for the Sénégalese market. Free quote in 2 minutes.

PoleSale commissionRecurring
Showcase15 %+ 5 % recurring
E-commerce12 %+ 5 % recurring
Marketplace10 %
Institutional8 %

Example: an e-commerce Growth project at 2,000,000 FCFA earns you 12 % = 240,000 FCFA on the sale, plus 5 % on recurring maintenance. Become a referrer by messaging us on WhatsApp.

Mini case study

Rokhaya, who runs an online shop in Dakar, hit a network spike: 3 replayed webhooks out of 400 payments. Without idempotency, that created 3 duplicate orders, 3 extra parcels prepared and 45,000 FCFA of stock tied up (average basket 15,000 FCFA). After adding a unique constraint on event_id with a 72 h TTL, subsequent replays return 200 without recreating anything: zero duplicates in the following months.

FAQ

What is an idempotency key? It is a unique identifier per event (event_id) guaranteeing a replayed webhook produces exactly the same result as the first pass: no duplicates.

Why a DB constraint rather than a cache? The unique constraint withstands concurrent processing: if two replays arrive at once, the database accepts only one. A cache alone can let a race condition slip through.

Which TTL should I choose? 72 h, aligned to the window during which the provider may replay an event. Beyond that, the key can expire with no risk of a further replay.

What should I return on a duplicate? A 200 (OK), without reprocessing. Returning anything else would push the provider to replay again, worsening the problem.

What share of webhooks are replays? In practice 0.5 to 2 %, mostly during latency spikes or network outages. It is rare but enough to cause costly duplicates without idempotency.

Let's talk about your project. We make your webhooks idempotent (DB constraint, TTL, atomic transaction), and you can also become a Kolonell business referrer. WhatsApp +221 77 596 93 33.

Tags:#idempotence webhook#eviter double paiement#cle idempotence#dedup webhook#double charge#fiabilite paiement#architecture paiement
Share:

Mohamed Bah

Fondateur, Kolonell

Passionate about digital and entrepreneurship in Africa, Mohamed has been helping Sénégalese businesses with their digital transformation since 2020. Founder of Kolonell, he believes every SME deserves a professional and accessible online présence.