Commit 75c7aaf
authored
fix(billing): resume a pending top-up as a top-up, not a subscription (#14715)
## Description
Billing status can return an in-flight billing operation
(`pending_billing_op_id` + `action_url`) so a client that lost its local
reference can resume the payment — a reload, a cleared browser, a
different device. The recovery path in `useWorkspaceBilling` assumed
that operation was always a subscription and passed a hardcoded
`'subscription'`.
That assumption is a latent bug regardless of what the server sends
today: any non-subscription operation surfaced there takes the wrong
branch throughout.
- `isSettingUp` turns true, so `SubscriptionPanelContentWorkspace`
replaces the whole panel with a "setting up your subscription" spinner —
hiding the user's actual plan for as long as the operation is pending
- `topupActionOperation` requires `type === 'topup'`, so the top-up
dialog's own recovery prompt never matches
- `handleSuccess` runs `reconcileSubscriptionSuccess()` instead of
`fetchStatus()` + `fetchBalance()`, so credits just purchased never
appear
- the toast and telemetry describe a subscription checkout
Uses the operation type when the API reports one, falling back to
`'subscription'` when it does not — so this is inert against a server
that never sends the field, and correct the moment one does.
**Status:** the server side does not populate a top-up here yet. This is
the client half, landing first because it is safe in isolation; without
it, a server that starts reporting top-ups would drive the wrong UI.
Treat it as removing a hardcoded assumption, not as shipping a
user-visible fix on its own.
## Checklist
- [x] Test added — `recovers a pending top-up as a top-up, not a
subscription`, confirmed to fail without the fix
- [x] `pnpm test:unit` (72 passed in the touched suite), `pnpm
typecheck`, `pnpm lint`, `pnpm format`
## Follow-up (not in this PR)
`billingOperationStore` gives a top-up 120s to discover an
authentication URL (`TIMEOUT_MS`) while a subscription gets 5min
(`SUBSCRIPTION_ACTION_DISCOVERY_TIMEOUT_MS`). Only bites when the
payment page is slow to appear, so it is kept separate.1 parent b1861ab commit 75c7aaf
3 files changed
Lines changed: 23 additions & 1 deletion
File tree
- src/platform/workspace
- api
- composables
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
294 | 315 | | |
295 | 316 | | |
296 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
0 commit comments