· Engineering notes

Webhook retry testing for fintech APIs

Provider webhooks are at-least-once. An Idempotency-Key on your payment POST does not stop a retried payment.succeeded from double-provisioning if your consumer is not deduped. Test the retry matrix on the webhook path.

Idempotent POST is not a safe consumer

You may already test payment idempotency keys - keep that suite (idempotency and race conditions in payment APIs). Webhooks are a second door: the provider retries on timeout, 5xx, or connection reset. Your endpoint must acknowledge only after side effects are safely recorded, or accept duplicates without a second charge / entitlement.

Map risks with the OWASP API checklist; this post is the webhook slice for fintech-style surfaces. Product context: fintech & payment API testing.

Artifact: retry / duplicate matrix

CaseWhat you sendExpect
First deliveryValid signature, new event_id2xx; side effect once; row stored with event_id
Provider retrySame body + same event_id, minutes later2xx; no second side effect
Replay attack / staleValid old payload outside tolerance window4xx; no side effect
Bad signatureTampered body or wrong secret4xx; no side effect
Out-of-orderpayment.failed after payment.succeeded for same payment_idDocumented rule (ignore or compensate); never silent double state
Burst retriesN duplicates in <1s (provider impatient)Still one side effect; watch locks/unique constraints

Consumer checks you can automate

# Pseudocode  -  adapt to your stack
# 1) Verify signature before parsing business fields
# 2) INSERT event_id INTO webhook_receipts ON CONFLICT DO NOTHING RETURNING id
# 3) If conflict: return 200 without running provision()
# 4) Else: provision(); return 200

# Manual replay (staging):
curl -sS -X POST https://staging.example.com/webhooks/payments \
  -H "Content-Type: application/json" \
  -H "X-Signature: $SIG" \
  --data-binary @event.json
# Repeat with identical event.json  -  assert entitlements count unchanged

Assert uniqueness at the database (UNIQUE(event_id)) even if the app layer races. For burst behaviour against your edge, the Lab rate-limit check is optional triage - it does not replace consumer dedupe tests.

Evidence pack for the ticket

## Webhook retry evidence
Provider event type: payment.succeeded
event_id: evt_...
First request: timestamp, HTTP status, response body hash
Retry request: timestamp, HTTP status, response body hash
DB: webhook_receipts row count for event_id = 1
Side effect: entitlements / ledger rows for payment_id (before/after counts)
Signature failure case: status + no row inserted
Owner / date / environment: staging

Ship the matrix as automated tests where the provider offers a "resend" or you control a stub. Do not rely on production luck.

When the consumer is wrong, API testing under API testing is the engagement shape - not a generic "QA hire" discussion.

If you want the three webhook paths most likely to double-charge or double-provision on your stack named, book a free 20-min test audit.

Ingress throttle: rate limits on webhooks and cloud cost.