Commit dd4d67f
fix(billing): unstub checkout / invoices / cancel — upgrade flow now works (#20)
Before this commit the dashboard's billing surface had three
fixture-only API functions despite the real agent-API endpoints
existing and working:
createCheckout() → returned https://rzp.io/p/stub-${plan}
(a 404 — no real Razorpay session was
created). Clicking "Upgrade to Pro"
took customers to a broken URL.
listInvoices() → returned FIXTURE_INVOICES regardless of
the team's actual subscription.
handleCancel() → console.log('not yet wired')
After:
createCheckout(plan) → POST /api/v1/billing/checkout on the
agent API. Receives a real
razorpay-hosted short_url and
subscription_id. BillingPage redirects
window.location to short_url so the
customer completes payment on Razorpay,
which fires the subscription.activated
webhook back to /razorpay/webhook on the
agent API and the team tier elevates
via models.UpdatePlanTier +
ElevateResourceTiersByTeam.
listInvoices() → GET /api/v1/billing/invoices on the
agent API. Falls back to fixtures only
on 503 (billing_not_configured) so
local-dev without Razorpay keys still
shows usable data.
cancelSubscription() → POST /api/v1/billing/cancel on the
agent API. handleCancel re-reads the
billing card and surfaces a notice that
the downgrade is in flight pending
Razorpay's async subscription.cancelled
webhook.
fetchBilling() stays partial-fixture: the plan TIER is real (from
/api/v1/whoami via fetchMe), but the next-renewal-date and
payment-method fields are still FIXTURE_BILLING because the agent
API doesn't yet expose a GET /api/v1/billing endpoint that
aggregates this. Open follow-up: add that endpoint to the agent
API, then drop FIXTURE_BILLING from this file entirely.
Verified locally:
npm run build → 116 HTML + 116 .md mirrors, no errors
npm test → 26/26 markdown renderer tests pass
Security scan on the diff: zero secrets, zero cluster
hostnames, zero customer identifiers
This is the smaller of the two paths I offered:
✓ ship the billing unstub now (this PR)
⏳ kill dashboard-api as a separate session (~3000 lines of
dead code in the dashboard-api repo since the frontend talks
directly to the agent API)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 93ee96b commit dd4d67f
2 files changed
Lines changed: 66 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
401 | 422 | | |
402 | 423 | | |
403 | 424 | | |
404 | | - | |
| 425 | + | |
405 | 426 | | |
406 | | - | |
| 427 | + | |
407 | 428 | | |
408 | 429 | | |
409 | 430 | | |
| 431 | + | |
| 432 | + | |
410 | 433 | | |
411 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
412 | 445 | | |
413 | 446 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
419 | 460 | | |
420 | 461 | | |
421 | 462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | | - | |
124 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
| |||
0 commit comments