Making a payment request safe to retry
In short After a network error, an app cannot know whether the payment went through, so retrying blindly can charge twice. An idempotency key lets the server recognise a retry and return the first result instead of charging again. The client has to create the key once, save it before sending, and let only one sender use it. idempotent-queue does this in the browser, Node and React Native, and is…
In the event of a network error, an application cannot determine whether a payment was successfully processed. Attempting to retry the payment blindly could result in double charges. To prevent this, an idempotency key is utilized, allowing the server to recognize repeat requests and return the outcome of the initial request. The client is responsible for generating a unique key, storing it before sending the payment request, and ensuring that only one sender uses it.
The idempotent-queue library facilitates this process across various platforms, including web and mobile applications, with extensive testing conducted using random crashes and lost responses.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to