Idempotency means repeating the same request has the same effect as sending it once. In payments it is the difference between a timeout and a double charge.

Why it matters

Networks fail after the server has already committed. Without an idempotency key, a retry creates a second order or a second delivery. With one, the retry returns the original result — which is why the merchant order reference, not a random id, is the key.

How GaaPay handles it

merchant_order_ref is unique per app and doubles as the idempotency key: repeating it returns the same order. In-flight duplicates return 409 IDEMPOTENT_INFLIGHT rather than creating a second order. Webhooks are deduplicated by event_id.

Questions

Should I generate a new reference on retry?

No. Reuse the original reference; that is what makes the retry safe. A new reference is a new order.

Is the webhook idempotent?

Delivery is at-least-once, so your handler must be. Store event_id with a unique index and return 2xx on duplicates without repeating the work.

See it in a running checkout

The sandbox runs the same state machine: detected, confirmed, settled — and a webhook you can verify.

Open the sandbox