Backend Development 10 min read

Preventing Duplicate Payments in E‑commerce: Process, Problems, and Solutions

This article explains the typical e‑commerce payment flow, analyzes why duplicate payments occur due to missing locks, drop‑offs, and multi‑channel issues, and presents practical backend techniques such as distributed locking, result caching, payment‑stream cancellation, refund handling, active polling, and client‑side pull/push strategies to reliably prevent repeated payments.

Architect
Architect
Architect
Preventing Duplicate Payments in E‑commerce: Process, Problems, and Solutions

Online payment is familiar to most users, and this article discusses how to prevent duplicate order payments by examining the entire payment process and its pitfalls.

The e‑commerce payment flow includes order creation/checkout, 3.申请支付 (apply for payment), initiating payment with third‑party services, wallet payment on different clients ( APP端 , WAP端 , PC端 ), receiving the payment callback, and synchronizing the order status from “unpaid” to “ready for shipment”.

Duplicate payments can happen when the same payment is initiated multiple times (e.g., scanning two QR codes on PC), when callbacks are missed causing “drop‑off” issues (external or internal), and when users switch between payment channels, leading to multiple successful transactions.

To prevent these problems, the article recommends locking the order at the application level—typically using a Redis distributed lock—so that both 3.申请支付 and 5.支付回调 are serialized. It also suggests caching successful payment results, cancelling in‑progress payment streams marked as 支付中 , and refunding already‑paid streams when a new payment is attempted. Active polling (timed tasks or delayed messages) and retry mechanisms are advised to avoid external drop‑offs, while a combination of synchronous calls and asynchronous message notifications ensures internal consistency. Client‑side state synchronization can be achieved through pull (periodic polling) or push (WebSocket or push services) methods.

Finally, the article emphasizes keeping the payment experience within the client (avoiding external jumps) and provides references for deeper architectural details.

Backende-commercecachingdistributed lockpaymentpollingduplicate payment
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.