How to Prevent Duplicate Payments and Order Expiration in Payment Systems
This article examines common payment system anomalies such as duplicate charges and order expiration, explains how asynchronous and synchronous payment flows contribute to these issues, and provides both pre‑payment and post‑payment strategies—including UI improvements, return URLs, status checks, and automated refunds—to prevent and resolve them.
Duplicate Payment Exception
Duplicate payment occurs in asynchronous payment channels such as online banking, WeChat Pay, and Alipay, where the same order may be charged twice.
These channels rely on asynchronous notifications to determine the payment result.
Solution
Pre‑payment measures include directing the payment page to jump directly to the third‑party bank page without opening a new window, and using the return_url parameter to receive a synchronous redirect after payment.
When a user uses the browser back button, the system should query the order status before showing the payment page again.
Another pre‑payment approach is to display a confirmation popup asking whether the user has already completed the payment.
Post‑payment handling can be done by launching an internal refund: a scheduled task scans for payment orders with multiple successful channel records and refunds the duplicate.
Order Expiration Exception
This scenario appears in e‑commerce and flash‑sale contexts where an order expires before the asynchronous payment notification arrives, resulting in a successful charge but a failed or closed order.
Solution
Send the order’s remaining validity period to the payment channel using the payment‑valid‑time field so the payment will be automatically closed after expiration.
Alternatively, trigger an internal refund via a scheduled task when a closed order is found to have a successful payment.
Summary
A mind‑map summarises the possible payment system anomalies and their mitigations.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
