Repository navigation
feat(billing): configurable org auto top-up threshold and $5,000 amount - #7612
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe only change since the previous review is a correct Files Reviewed (2 files)
Incremental scope: only the two files above changed within the PR since Previous Review Summary (commit f4468b9)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit f4468b9)Status: No Issues Found | Recommendation: Merge Executive SummaryReviewed the configurable org auto top-up threshold feature end to end (DB column + migration Files Reviewed (16 files)
Notes: the Reviewed by deepseek-v4.1-flash · Input: 52.4K · Output: 9.2K · Cached: 574.8K Review guidance: REVIEW.md from base branch |
|
re-assigning to @iscekic who is going to run with this. |
…hold toggle paths
…threshold # Conflicts: # packages/db/src/migrations/meta/0281_snapshot.json # packages/db/src/migrations/meta/_journal.json
Summary
Organization automatic top up always fired when the balance dropped below a fixed $50. A customer asked for this to be configurable.
Implementation:
auto_top_up_configs.threshold_cents— new nullable integer column (migration0281, additive only).NULLmeans the default org threshold; personal configs ignore it.autoTopUp.ts— the org trigger check still short-circuits with no DB read when the balance is at or above the maximum option ($500). Below that, it does one read of the org's configured threshold. The post-lock re-check uses the threshold returned by the lock query.getConfigreturnsthresholdCents;toggleandchangePaymentMethodaccept it and fall back to the saved config, not hard-coded defaults; newupdateThresholdmutation;updateAmountapplies the validation rule.thresholdCentsthrough PaymentIntent metadata and theorg-auto-topup-setupwebhook persists it. The product description shows the chosen trigger balance.Verification
getConfigdata and screenshotted them with Playwright (below): $5,000 option, threshold dropdown, invalid amount options disabled, inline error and disabled enable button for an invalid combination.stripe listenforwarding webhooks):threshold_cents = 50000and credited the org.invoice.paidcredited it and released the lock.updateAmountbelow the threshold returnsBAD_REQUEST;updateThresholdwith an unsupported value fails input validation.threshold_cents = 50000.0282aftermainadded its own0281; regenerated withdrizzle-kit generate(same singleADD COLUMN).autoTopUp.test.ts,organization-auto-top-up-router.test.ts,stripe/index.test.ts.apps/webtypecheck,oxlintandoxfmton changed files.Visual Changes
Before: the settings row read "Automatically top up [amount] when balance drops below $50." with only amounts $100 / $500 / $1,000, and the dialog had a single amount dropdown.
Reviewer Notes
organizations.autoTopUp.updateThresholdmutation. It only changes when an already-configured automatic top up triggers. It does not create a charge itself.services/kilo-mcp/catalog.jsonis regenerated by thekilo-mcp-catalogworkflow.thresholdCentsmetadata. The webhook stores the $50 default for those, which matches current behavior.