Two open-source projects on payment integrity:
exactly-once-webhooks: on Postgres, the payment write and its "done" record commit together, so a racing duplicate can't apply twice.
append-only-ledger: the DB refuses edits; fixes are reversal rows.
https://t.co/CHFp0zohJB
The payment bug I see most in fast-built SaaS isn't a double charge. It's "paid, but no access."
The app unlocks the account on the redirect back from checkout. The customer closes the tab first, so the redirect never lands. Stripe has the money; your database never heard.
Unlock on the webhook, not the redirect.
I'm looking for my next role or project and can start now: payments, integrations and security hardening (TypeScript, Python).
New since Saturday: exactly-once-webhooks 0.10.0, an open PR to postgres.js, reviews on postgres.js and svix.
https://t.co/CHFp0zohJB
Intros welcome.
If a record involves money, never edit it. Add to it.
Change the wrong number and the old value is gone: nobody can say what it was, when it changed, or why.
Leave the wrong entry and add one that reverses it. Now the history explains itself, and any balance can be rebuilt.
@boyney123@bot Watch for the signup webhook arriving twice. Key the bot's run on the event id, or you'll review two drafts for the same person, and the day review becomes auto-send, they get both.
Sunday in other people's Postgres code:
A transaction waiting for a connection couldn't be cancelled, so a timed-out request still ran. PR with tests is up in porsager/postgres.
Also reviewed a cursor fix. Before it, a dropped socket returned 20 of 100 rows and no error.
@sadkatwt The part that bites: the crash lands after the gateway charged but before your row says paid. Send the gateway that same key, so the retry gets the first charge back instead of a new one, and let the gateway's webhook mark the row paid.
A review of my payment-alert sample found it would post "Payment received: 0.00 USD", and that a name typed at checkout could ping the whole team channel.
Both fixed in this PR, each with a test that fails without the fix:
https://t.co/MkOwcb8c8B
@dexhorthy The copy that can't drift is the one CI runs. A reviewer found my README's install command was broken today. The fix wasn't better docs, it was a CI job that runs that exact command on every change. Claims that matter become tests; the rest stays one sentence.
@mattpocockuk I'd add a fifth: Claim. Says what the code does at runtime, can be wrong from day one. Action: turn it into a test, then delete it. Found one in my own code today: "holder rolled back, retry" over a path real Postgres never takes. The test caught it.
A slow app with zero errors is the hardest kind of broken.
Every request succeeds, and people still stare at a spinner.
Read the times, not the errors. Long wait, short work: requests are lining up behind something.
Errors say what failed. Timing says what's waiting.
Where do you draw the approval line for agents that act on real systems?
Mine: reads and drafts run on their own. Anything that writes outside the sandbox waits for a human yes. Anything that moves money or speaks for someone stays manual, no matter how many clean runs it has.
The middle cases are the hard part. Is updating a CRM field a write that needs a yes? What's your rule?
Founders taking payments: when a customer says they were charged twice, how fast can you answer "what happened" from your own records?
What made that a two-minute question for me: never edit a payment row, only add a correction next to it, and store the provider's event id on every one. The history answers instead of someone's memory.
Curious what others do when Stripe and your database disagree.
@mattzcarey@poteto First race I'd point this at: the same webhook delivered twice at the same instant, both copies passing the "have I seen this?" check. I have a test that fires five copies at once and expects one credit. A proof would beat my test.
@boyney123 Pick any of the three and the consumer still has to handle the same message arriving twice. Store the message id, check it before doing the work, and redelivery stops being scary.
@ConsciousRide Number 4 has a second half. Even when you check status before resending, the provider's own callbacks still show up late, twice, or out of order. I make that handler safe to run twice, so a repeat finds the ledger row that's already there and stops.
Two ways payments quietly go wrong: the same webhook gets processed twice, or someone edits a ledger row.
I published small open-source fixes for both, with tests:
https://t.co/sKbU1LGDCx
https://t.co/UgCy2cDfIu
@dexhorthy@badlogicgames Only test I fully trust is the one the agent didn't write: me, after the deploy, on the live site, doing exactly what the person who reported the bug was doing.
@alexmamyy Almost never zero reason in my experience. First thing I compare is what the sender says it sent against what actually arrived. Sent and arrived are two different facts, and the gap between them is usually where it broke.