Glossary

Idempotency

Idempotency means that sending the same request once or several times has the same effect on the server. In payments it stops a charge request repeated after a network drop or a double click from taking the money twice. It is usually implemented by attaching a unique idempotency key to each request.

RFC 9110, which defines HTTP semantics, calls a method idempotent when the intended effect of several identical requests is the same as that of a single one. PUT, DELETE and the safe methods qualify; POST, the usual method for creating a payment, does not. An API that creates payments with POST therefore has to recognise repeats itself.

The Idempotency-Key header, an Internet-Draft in the IETF, describes one way to do this: the client sends a unique key with each operation, and the server uses it to recognise retries instead of processing the request again. The draft treats reusing a key with a different payload as an error.

Example: a customer taps "Pay" in your mobile app. The request reaches the bank, but the connection drops before the reply arrives. The app resends the request with the same key; the server recognises it, starts no second charge and returns the result of the first one. Without the key, the customer's card could have been charged twice.

Lunixi SDKs can send payment requests with an idempotency key; usage is described on the developers page.

Sources

  1. IETF: RFC 9110: HTTP Semantics, Section 9.2.2 Idempotent Methods
  2. IETF: The Idempotency-Key HTTP Header Field (Internet-Draft)