fix(billing): unstub checkout / invoices / cancel — upgrade flow now works#20
Merged
Merged
Conversation
…works 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>
mastermanas805
added a commit
that referenced
this pull request
May 11, 2026
…nt (#23) InstaNode-dev/api PR #15 just landed — the agent API now serves GET /api/v1/billing as the aggregated subscription-state endpoint the dashboard had been fixturing. This commit drops the fixture path. fetchBilling() now calls the real endpoint and maps the response into the dashboard's existing BillingDetails shape (status, current_period_end, payment_last4, payment_network — every field the agent API can populate is now live; the ones the agent API doesn't expose yet stay undefined and render as "—" in the UI). Fallback: on 503 (Razorpay unconfigured in local dev), still falls back to FIXTURE_BILLING so the BillingPage doesn't break for developers without RAZORPAY_KEY_ID set. Any other error propagates so production failures aren't silently swallowed. Closes the partial-fixture comment block I left in PR #20. Verified: npm run build clean (116 HTML + 116 .md), 26/26 markdown renderer tests pass, Playwright auth/navigation/resources specs all green. Co-authored-by: Claude Opus 4.7 (1M context) <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.
The dashboard's billing functions were marked [FIXTURE] even though the agent-API endpoints exist. Clicking 'Upgrade to Pro' was sending customers to a stub URL.
This PR unstubs createCheckout, listInvoices, and the cancel handler. All three now hit real agent-API endpoints. fetchBilling stays partial-fixture (plan tier is real; renewal date + payment method are FIXTURE_BILLING) because no GET /api/v1/billing aggregator endpoint exists yet — flagged as follow-up in the api/index.ts comment.
Verified: build clean, 26/26 tests pass, security scan clean.
Next session candidate: kill dashboard-api (the frontend never reaches it; ~3000 lines of dead code).