Repository navigation
feat(free): admin reset of one person, Stripe included - #519
Merged
Merged
Conversation
POST /admin/people/:githubId/reset {confirmLogin}: cancels every
subscription of the person's Stripe customers, refunds every succeeded
charge in full, deletes the customers, then deletes the person like
/delete does plus their payments, customers, paid_checkouts,
refund_requests and card trials. A Stripe error stops it before any
data is deleted (502 with what was done); safe to run again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
POST /admin/people/:githubId/reset {confirmLogin}resets one test person on dl.new so they look like they never existed, Stripe included. It is meant for demo recordings, where the same GitHub account has to sign up and pay again many times.For every account of the person (their own people row and the dl.new account their GitHub identity points at), the steps run in this order:
Stripe (new
services/free/src/person-reset.ts, inside the Worker with the Worker's secret key). Customers are collected from the account's billing,customers, their claimedpaid_checkouts, and the customer of eachpaymentsinvoice or Checkout Session. Then:reset-refund-<charge>-<amount_refunded>);An already canceled subscription,
charge_already_refunded, andNo such customer/ 404 all count as done.Data: the existing delete (auth, account objects, Directory), with no
active_subscriptionrefusal. The money rows go too:payments,customers,paid_checkouts,refund_requests, and the cardtrialsof those subscriptions. This reusesdeletePerson(app.ts) andDirectoryObject.deletePersonthrough a newreset/moneyoption. The plain/deletebehaves exactly as before.One config-log line:
person_reset:<id>:<login>. It records the Stripe counts and the removed rows.Response:
{reset: true, githubId, login, stripe: {subscriptionsCanceled, refunds, refundedCents, customersDeleted}, removed: {"<object>.<table>": n}}.Guards
confirmLoginmust match, same as delete: 400invalid_requestwhen it is missing, 400login_mismatchwhen it is wrong, 404 when the person doesn't exist.is_adminfor anyone in ADMIN_GITHUB_IDS.billing_errorwitherror.stripeshowing what was done so far. Running it again finishes the job.Tests
services/free/test/reset-person.test.tscovers:already refundedandNo such customererrors;The whole services/free suite passes (1488 tests), and
tsc -p services/tsconfig.jsonis clean.Note
A legacy dl Pro subscription (
metadata.github_id) that gets canceled here can send itscustomer.subscription.deletedwebhook after the rows are gone. That would write back acanceledbilling and subscription mirror row. dl.new plan webhooks find their account throughcustomers, which is deleted, so they write nothing.🤖 Generated with Claude Code