Skip to main content

Idempotency

From the API's point of view, idempotency means that multiple requests are handled in the same way as single requests.

It means that upon receiving a repeated request with the same parameters, the Processing Service will return the result of the original request in response.

This behavior helps avoid undesirable repeated transactions. For example, if there are some network problems while making a payment and the connection is broken, you can safely repeat the required request an unlimited number of times.

GET requests are idempotent by default, since they have no unwanted consequences.

The Idempotence-Key header (or idempotence key) is used to ensure the idempotency of POST requests.

Example header:

Idempotence-Key: ps_1614589640890_3134                                                             

where ps_1614589640890_3134 is, for example, the result of executing this PHP code:

$prestashop_prefix = 'ps_';
$idempotence_key = $prestashop_prefix . time() . '_' . $prestashop_order_id;

The idempotency key must be unique within an individual account application ID. One application ID cannot be used in multiple stores, otherwise it may not be sufficient to use only the internal store order number as the idempotency key, because these numbers can be repeated in requests from other stores with the same application ID. In this example, the time of request initiation is also involved in the formation of the key, but other more elaborate variations are possible.