SShortSingh.
Back to feed

Handling payment API timeouts without double charges or duplicate orders

0
·4 views

When a customer clicks Pay and the server times out waiting for the payment provider, the charge may already have succeeded. The author recommends showing a 'checking your payment' status page and keeping the attempt pending until the outcome is confirmed. Each payment attempt should be saved with a provider idempotency key before the charge request is sent, so retries reuse the same attempt. Webhook and reconciliation handlers should update the attempt from pending to succeeded in one conditional database operation, recording processed event IDs and queuing fulfillment work. Testing should simulate a successful charge with a dropped connection, retried requests, and duplicate webhooks to confirm the customer is charged once and fulfillment happens once.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

AiryNight Keeps Nighttime Bedroom Audio On-Device Rather Than Uploading It to the Cloud

The developers of AiryNight, a sleep-tracking app, analyze nighttime audio entirely on the phone instead of sending bedroom recordings to a server. They argue that continuous overnight recordings capture private household sounds that could be exposed by a breach, subpoena, or ownership change even after deletion promises. The app classifies probable snoring with an on-device model and produces a morning summary with a comparative per-hour score, with recordings excluded from backups and deletable at any time. The company acknowledges that purchases are verified through Apple or Google and that optional anonymous usage statistics may be sent, while stating that audio, journal entries, and night results do not leave the device. The app runs on Android 8 or later and iOS 15 or later, with the iOS version about 27.8 MB.

0
ProgrammingDEV Community ·

Java Security Review: Common High-Risk Sinks and Pitfalls in XML, Deserialization and Queries

A security article explains that the most dangerous Java vulnerabilities often hide in ordinary-looking code, where untrusted data flows into sensitive operations called sinks. It notes that default XML parsers in Java enable external entity resolution, exposing applications to file disclosure, server-side request forgery, and denial of service, and that the JDK version alone does not fix this. The author recommends explicitly disabling doctype declarations and external DTD and schema access, configuring these features before the builder is created. The piece also warns that native deserialization with ObjectInputStream and permissive polymorphic typing in Jackson can enable remote code execution, and advises restricting allowed classes with filters or validators. Finally, it highlights a subtle injection risk in dynamic sorting within Spring Data JPA, where unvalidated property names can bypass safeguards.

0
ProgrammingDEV Community ·

Founder Builds Pipeline That Automates Social Media Posting for His SaaS

A founder describes how he stopped manually writing social media posts for his SaaS product by building Bravio, a pipeline that automates the process. The system first reads the company's website to create a brand profile covering products, offers, and tone of voice. Post topics are drawn from real search questions and product features rather than generic tip lists. Content is produced in varied formats such as reels, images, and carousels, adapted automatically to each platform's length and hashtag norms. Finally, posts are scheduled across connected accounts, with comment-keyword DMs driving clicks to the product.

0
ProgrammingDEV Community ·

Unbounded Node.js In-Memory Cache Pushes Memory From 3.4 MB to 200 MB Under Load

A developer ran a Node.js service that cached HTTP responses in a plain Map with no size limit. Load testing with 4,000 requests, each using a unique URL, drove resident memory from 3.4 MB to 200.1 MB with no plateau, since the Map kept every entry reachable. The developer fixed the problem by capping the cache size and evicting the oldest entries, which kept memory flat at 13.6 MB under the same traffic and throughput. The write-up argues that unbounded in-memory caches are a memory leak that often only surfaces in production. It recommends a hard size limit with an eviction policy such as LRU, a TTL for stale data, and load testing with unique keys before shipping.