#deefdragon
1 messages · Page 1 of 1 (latest)
hello! To explain a bit more - Idempotency keys are useful for preventing double charges in cases of poor network conditions only. They allow for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. For example, if a request to create a charge does not respond due to a network connection error, the request can be retried with the same idempotency key to guarantee that no more than one charge is created - if you're using Stripe's SDK, this can be configured automatically e.g. https://github.com/stripe/stripe-node#network-retries
To prevent double charges, you would want to look into as an example : preventing double clicking e.g. maybe a user clicked the button twice while a page was loading and it leads to making two API requests. You would want to use approaches like the disabled HTML attribute [2] to prevent such occurrences.
There could be other reasons why double charges occur, but it's usually a implementation issue
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled