Repository navigation
feat(payments): prune unpaid payments after two days and keep their count - #534
Merged
Merged
Conversation
rahXephonz
force-pushed
the
feat/prune-unpaid-payments
branch
from
October 27, 2026 02:29
ce90f4c to
0615330
Compare
…ount The chain worker deletes payments nobody paid (CREATED, CONFIRMED, EXPIRED) once they are EXPIRED_PAYMENT_RETENTION_DAYS past expiry (default 2, 0 turns it off), a batch of 100 an hour. Two days is beyond the watcher's 24 hours, so a late deposit is still found first. A payment with any sign of funds is never deleted: a deposit at its address, a clearing step past PAYMENT_PENDING, a provider reference or a provider funding. FAILED payments are kept. Each batch is one transaction that removes the child rows, the payment and writes the count to pruned_payment_counts, per merchant, creation day and rail. Analytics adds those counts back to checkouts, failed and expired and the per-network and per-asset performance, so deleting a payment does not change conversion or success rate. Migration 0072 adds pruned_payment_counts. The Postgres test for the pruner is opt-in like the rest of that suite.
…ongs to someone else The payment detail page answered a 404 with "No payment with that id belongs to this merchant". Since unpaid payments are now deleted two days after they expire, the same 404 also means that, so the message names both.
rahXephonz
force-pushed
the
feat/prune-unpaid-payments
branch
from
October 27, 2026 02:33
0615330 to
e982538
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #533 (
feat/small-payment-fee): migration 0072 follows 0071. Retarget tomainonce that merges.Why
Payments nobody pays (expired, or never confirmed by the buyer) pile up in the database and in the dashboard list, with no detail worth opening.
What
CREATED,CONFIRMED,EXPIRED) once they areEXPIRED_PAYMENT_RETENTION_DAYSpast expiry. Default2,0turns it off. 100 per hour.LateDepositServicefirst.PAYMENT_PENDING, a provider reference, or a provider funding.FAILEDpayments are kept.pruned_payment_counts(merchant, creation day, chain, asset).buildAnalyticsadds it to checkouts, failed and expired, and per-network and per-asset performance, and respects the chain and asset filters. Conversion and success rate do not move when a payment is pruned.Rollout
0072createspruned_payment_counts.Tests
bun run typecheckandbun testpass.packages/db/test/postgres.test.tshas a pruner test (prunes an unpaid payment and its children, keeps one with a deposit, counts both). It is opt-in like that suite and has not been run: it needs a_testdatabase.