Idempotency Keys: How PayPal and Stripe Prevent Duplicate Payment

Talha Şahin
4 min readFeb 10, 2024

Have you ever tried to make a failed payment again and suspected that you payed twice? Payment Service providers such as PayPal or Stripe use a method to handle multiple requests for same payment: Idempotency Keys. Let’s increase our domain knowledge by examining this method together!

The Essence of Idempotency in Payment Systems

Idempotency is a crucial safeguard in digital payment systems, ensuring that transactions are executed just once, no matter how many times a request is sent. Its role is vital in handling the complexities of online payments, from accidental multiple clicks the “pay” button to retrying payment request failed due to network issues. This principle prevents customers from being charged multiple times for the same purchase.

Idempotency Keys

At the heart of idempotency lies the use of unique idempotency keys for each transaction request. When a client initiates a transaction, the payment system requires an idempotency key to be included in the request. This key, often a universally unique identifier (UUID) or a similarly robust random string, is generated by the client. It acts as a transaction fingerprint, allowing the payment system to recognize if the same request is submitted multiple times.

--

--

Talha Şahin

Hello! I am Talha Şahin, a Software Engineer at ING Nederland. Technology is my biggest curiosity and passion.