SShortSingh.
Back to feed

Double Charges Stem From Server Retries, Not Just Button Taps

0
·5 views

A client reported that customers were being charged twice after pressing the Pay button in a Flutter app. The duplicate charges occurred because a network hang led the user to tap again, sending two requests to the charge endpoint that both succeeded. Disabling the button after one tap only prevents repeated taps and does not handle retries, timeouts, or unreliable networks. The recommended fix is an idempotency key: the client generates one UUID per payment intent and sends it in a header, and the server stores that key with its result so repeat requests return the stored outcome instead of charging again. The author suggests keeping keys for at least the longest retry window, such as 24 hours, and applying this pattern to any create-type endpoint that a frontend might retry.

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 ·

LLM Tool Calling and MCP: Structured Function Calls and a Common Protocol for AI Tools

The article explains how LLMs such as those served through ChatGroq indicate which tool should be invoked, using LangChain for structured tool calling within a manual loop. It notes that only SELECT queries are permitted in production, with updates possible under human-in-the-loop oversight but carrying risk. The Model Context Protocol (MCP) is presented as a common standard, likened to USB for AI tools, where an MCP client decides which exposed method to call. Unlike individual API endpoints, MCP bundles multiple operations into a single exposed interface that an agent-like client selects from. The author also mentions Pydantic for data validation, SQLite as a file-based database, and Qwen models for local testing.

0
ProgrammingDEV Community ·

SaaS Startups Should Prioritize Churn Analytics Over Customer Acquisition

A common trap in early-stage SaaS is celebrating rising sign-ups while ignoring customer retention. The article uses a hypothetical project-management startup, FlowDesk, to show how new customer growth of 75% over six months coincided with only a 14% rise in total customers. Monthly churn climbed from 4% to 14%, offsetting the new sign-ups and flattening the customer base. Key metrics such as LTV, CAC, and the LTV:CAC ratio fell steadily, dropping below 1x by June, meaning each new customer was losing money over their lifetime. The author argues that retention should be diagnosed before spending more on acquisition, since marketing cannot fix a leaking customer base.

0
ProgrammingDEV Community ·

Vibe coding : le vrai défi n'est pas le code mais la mémoire du projet

Un lead tech fullstack expérimenté raconte avoir refondu le site d'une association de concerts nantaise en testant trois outils de Spec-Driven Development. Le premier essai avec Junie a avancé lentement, faute de fil conducteur entre des sessions espacées et de priorisation des tâches restantes. Le deuxième, avec BMad, offrait un brainstorming solide et une reprise facilitée grâce aux story files, mais se révélait trop lourd et coûteux en tokens pour un développeur solo. Le troisième, avec Superpower et une stack Astro, visait à réduire le périmètre au seul site web, avec des démos HTML utiles pour valider les designs. L'auteur souligne que la dérive des spécifications reste le principal écueil à maîtriser.

0
ProgrammingDEV Community ·

Do Android Privacy Vaults Need Accounts? A Local-First Argument

The article argues that a private photo vault on Android does not always need a user account, since accounts add dependencies like email identity, extra passwords, and server reliance. It notes that a local vault can verify access through a PIN, biometrics, or device-level protection without knowing who the user is. The author acknowledges the trade-off: without an online account, no server can automatically recover data, so backups become more important. The piece presents accounts as useful for sync and cross-device access but suited to different problems. It also promotes Xsilent, which says it works without an account and keeps protected files on the device.