What is an idempotency key?
Primer supports a request idempotency mechanism for our Payments API. This optional feature enables you to safely retry a request without risking the user being charged or refunded multiple times. This is particularly useful when an API call fails due to the request being invalid, due to a network issue, or if Primer is momentarily unavailable. If this is the case, make another request with the same idempotency key:-
If a request with the same idempotency key has already been successfully processed by Primer, the new request will be ignored. A
409
error will be returned with anerrorId
set toIdempotencyKeyAlreadyExists
. - Otherwise, Primer will attempt to process the new request.
How to use an idempotency key
To make an idempotent request, generate an idempotency key and pass it to the headerX-Idempotency-Key
.
orderId
for the idempotency key as multiple payment attempts and refunds can be made for a single order.