A Timeout Is Not a Failed Payment

https://hackernoon.imgix.net/images/mEbusncmDZdtm9Y1oAsjGZesYCp2-8r83exx.jpeg

A wallet transfer request times out. The payment service has no confirmation that the debit succeeded.

The obvious response is to retry. But a timeout tells us only that a response did not arrive in time. It does not tell us whether the account service received the request, whether it is still processing it, or whether it completed the debit and lost the response on the way back.

Those cases can look identical to the caller. Treating every timeout as a failure can cause a second debit. Treating it as success can tell a customer that money moved when it did not.

A timeout is an unknown outcome, not proof of failure.

Start with a stable transaction ID

Every logical transfer needs an identity that stays the same across retries. The caller should generate a transaction ID once, then reuse it if the request times out.

type TransferRequest struct {...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more