Menu

1 / 2

Never mark a crypto order paid twice: confirmations, reorgs and out-of-order webhooks

DEV Community: backend·Coldtill·about 18 hours ago
#exkT7IOY
#devtobackend#devto#dev#payment#coldtill
Reading 0:00
15s threshold

A classic crypto checkout bug goes like this. A webhook comes in, the shop marks the order paid, a retry of the same webhook arrives four seconds later, and a second fulfilment job goes into the queue. It's easy to write, easy to miss in testing, and it's a good reason to think properly about what "paid" means when the money moves on a blockchain.

Card payments trained most of us to treat a payment as a single yes/no event. On-chain payments are messier. A transfer is seen, then it gathers confirmations, and once in a while the block it landed in disappears. Customers send too little, or too much, or pay again an hour after the invoice expired. Your webhook receiver has to make sense of all of that, often out of order.

This post is about the order-system side of that problem.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.