Guides
Webhooks

Retries

When Pay4Fun tries to redeliver a webhook, how many times, and how to test failures and duplicates in Mimicr.

Pay4Fun redelivers the webhook on a temporary failure (timeout, URL down, 5xx error), with a limited number of attempts. Once they run out, the notification is not resent. The documentation doesn't say how many attempts or how far apart; the numbers below are Mimicr's.

The policy in Mimicr

AttemptWhen
1When the event happens
21 minute later
35 minutes after the previous one
415 minutes after the previous one
51 hour after the previous one
Your server's responseResult
Any 2xxDelivered (success)
5xx, a 10 s timeout or a network errorNew attempt, up to the fifth; then failed
4xx (or 3xx)Ends at once, no new attempt (failed)

Notifications of intents without a URL get the skipped status.

Follow them

bash
curl --url 'https://api.mimicr.dev/v1/pay4fun/deliveries?status=pending,failed' \
  --header 'Authorization: Bearer mk_...'

Each delivery has attempts, max_attempts, next_attempt_at, last_status_code, last_duration_ms, last_error, last_response and the body sent.

Test without waiting

  • Move the sandbox clock forward to make the next attempts due: npx mimicr clock pay4fun +1h.
  • Resend a delivery now: POST https://api.mimicr.dev/v1/pay4fun/deliveries/{id}/resend. A manual resend is a single attempt.
  • Make the first attempt fail with chaos: webhookFailRate on deposit or payment.
  • Get the same notification twice: webhookDuplicateRate.
bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/pay4fun/chaos/deposit \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "enabled": true, "webhookFailRate": 100, "webhookDuplicateRate": 50 }'

Good practices

  • Answer 2xx as soon as you store the notification and process it afterwards.
  • Make the handler idempotent by id + status.
  • Don't rely only on the webhook: if it doesn't arrive, look the intent up by externalId (deposit or payment).