
Billing Doctor
io.github.lazytitan30由 GitHub 账号 lazytitan30 发布v0.1.1更新于 Oct 24, 2026
Diagnose Google Play Billing incidents locally, with evidence. Not affiliated with Google.
概览
根据本地时间线文件诊断 Google Play Billing 故障,说明购买在哪里出错并引用 Google 的规则。
- 可以做什么
- Billing Doctor 用一个购买事件的 JSON 时间线对照十一组共 97 条规则进行检查,输出发现项,并附上依据的事件、机制、带日期的 Google 规则原文引用、置信度和下一步检查建议。其 MCP 工具为 diagnose_timeline、explain_subscription_state、decode_rtdn、redact_text、list_rules 和 get_rule。它还能校验时间线、解码 Pub/Sub RTDN 消息、解释 subscriptionsv2 资源,并从日志中脱敏令牌、邮箱和密钥。它只读取和报告,不会在 Google 侧做任何更改。
- 适用场景
- 当你自建 Google Play Billing 后端且订阅或购买出现异常时使用,例如已退款的用户仍保留权益,或同一条通知被应用两次。它适合根据日志、数据库记录、控制台配置和客服反馈排查具体事故,其退出码可用于 CI 门禁。
- 运行要求
- 需要 Node.js 20 或更高版本,通过 npx 或全局 npm 安装在本机运行。默认离线使用不需要账号、API 密钥或环境变量。可选的 --fetch 功能需要你自己的 Google 服务账号密钥文件,并在 Play 控制台拥有查看财务数据权限,还需要本地令牌映射文件。
安装
在 SourceWeft 中
- 打开 控制台中的 Billing Doctor,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Billing Doctor
Billing Doctor reads what happened to a Google Play purchase and tells you where it broke. It runs on your machine, calls nothing, changes nothing at Google, and shows its evidence. Not affiliated with Google.
It is for developers who run their own Google Play Billing backend, in Node, Python, PHP, Go or Java, with Capacitor, Flutter, React Native or native Android in front, and did not choose a subscription platform. It is the tool you run at 11 pm when a subscription broke.
Twenty seconds
The fixture below ships in the repository, so start from a checkout:
(The same fixtures ship inside the npm package: after npm install -g billing-doctor they are under $(npm root -g)/billing-doctor/fixtures/.)
Every finding carries the events it rests on, the mechanism, Google's rule quoted with a dated link, a confidence (certain, likely, possible) and the next thing to check. Exit code 1 means a high finding exists, so the command can gate CI.
What it does
You give it a timeline: one JSON file with what happened to one purchase, assembled from your logs, your database, the Cloud Console and the support ticket. The notifications Google sent, the API answers, what your backend wrote, what the user said. Tokens are pseudonyms; nothing real goes in the file.
It checks the timeline against 97 rules in eleven groups. Every one of them rests on a sentence from Google's own documentation, quoted verbatim with the URL and the date it was read:
billing-doctor rules lists them; billing-doctor rule B1 prints one in full.
Install
Node 20 or later.
Or run it without installing: npx billing-doctor <command>.
Commands
Exit codes: 0 nothing to report, 1 a high finding (or an input that could not be decoded), 2 a usage or file error.
The timeline
docs/timeline-format.md is the contract. Six event kinds: app (what the device reported), api (a call to the Play Developer API and its answer), ledger (what the backend wrote), rtdn (a notification as received), support (what the user said), console (releases and config changes). A policy block says what your backend is supposed to do, so a rule can tell your policy from a bug.
The fixtures/ folder holds one minimal timeline per rule, three realistic weeks, and five correct lifecycles that must produce nothing. They are the test suite and the best way to learn the format: fixtures/README.md.
With a coding agent
The same engine is an MCP server over stdio, so Claude Code, Codex, Gemini CLI or Cursor can call it while you fix the bug. Tools: diagnose_timeline, explain_subscription_state, decode_rtdn, redact_text, list_rules, get_rule.
Configure it as command npx, args ["-y", "billing-doctor", "mcp"]. For Claude Code, this repository is also a plugin (claude --plugin-dir . from a checkout, with the skill /billing-doctor:diagnose); for Gemini CLI, gemini extensions install https://github.com/lazytitan30/billing-doctor.
The Incident Kit
The free tool is complete on its own. The paid Incident Kit is a folder of files that makes the fix faster: a runbook entry per rule (the symptom as the user reports it, the mechanism, the fix, the regression test to add), a set of realistic incident timelines to replay against your own handler in CI, a TypeScript reference implementation of a verify endpoint, an RTDN handler and a reconciliation job, and checklists for the Play Console, Cloud setup, license testing and the Billing Library 8 and 9 migration. Drop the folder next to the tool as ./billing-doctor-kit (or set BILLING_DOCTOR_KIT) and billing-doctor rule G2 prints the runbook. There is no licence server and no phone-home; the kit is files.
billingdoctor.dev — one runbook page per rule, forty incident timelines, the reference backend, and the checklists.
What is in it, concretely:
Updates for twelve months, as a new download when Google's rules change or a rule is added.
The one optional network feature
diagnose --fetch reads purchases.subscriptionsv2.get for every token in a timeline with your own service-account key and appends Google's answers as api events, so a timeline built from logs gets Google's current view of each purchase. Off by default; nothing goes anywhere but Google.
The timeline keeps its pseudonyms: tokens.json maps tok_a1 to the real purchase token and stays on your machine; the appended events carry the pseudonym and the written file never contains a real token. The key needs the "View financial data" permission in the Play Console. Subscriptions only; one-time products are not fetched.
Privacy
No network calls by default. No telemetry, ever. Your logs never leave your machine. The one optional network feature above uses your own key and talks only to Google.
What it is not
Not an SDK, not a hosted service, not a subscription platform, not a dashboard, not legal or financial advice. It never acknowledges, consumes, refunds, revokes, cancels or defers anything. It does not diagnose Apple.
Where this comes from
The rules are Google's own documentation, turned into checks a machine can run. Every one of the 97 quotes a sentence Google published, with the page, the section and the date it was read, and all 97 live in one file (src/google/docs.ts) so a documentation change is a one-file diff with failing tests beside it. The sources are the Android developer site, the Play Developer API reference, the Play Console help centre and the Pub/Sub documentation.
Eight rules also carry a field observation from a live app, dated and marked as an observation, always beside Google's sentence and never in place of it. Those exist because documentation says what should happen and a support inbox says what does: a wrapper that never surfaces the response code, a plugin that returns the base plan id as the product id, a web fallback that resolves with nothing and looks like a sale.
Every rule has a fixture that proves it fires, and five correct lifecycles that must produce no findings at all; a false positive is a release blocker. When a rule misses an incident of yours, open an issue with a redacted timeline (good first incident); that is how the catalogue grows.
Contributing
npm test builds and runs everything; the runner needs Node 20.9 or newer for --test-concurrency, while the tool itself runs on 20.0 (checked there). One file runs alone: node --test tests/rules-B.test.js. A new rule needs its file in src/engine/rules, its Google fact in src/google/docs.ts (the only file with a Google fact, each dated), its fixture with an expected.json, and one line in src/engine/catalogue.ts. The five clean fixtures must stay at zero findings; a false positive is a release blocker.
Licence and trademarks
MIT. Google Play is a trademark of Google LLC. Billing Doctor is an independent project and is not affiliated with, endorsed by, or sponsored by Google.
来源:README.md,提交 bf7e594
工具
0版本历史
1- v0.1.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分