Repository navigation
[backport cloud/1.55] FE-2767 fix(billing-web): confirm scheduled plan changes without a card form - #18787
Conversation
🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since fa2519e77478c572ccb79c99d5074305745758ee
Full docs: ADR-DEVEX-LINT-0015 🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight This candidate changes nothing the matrix measures, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 📦 Bundle Size
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## cloud/1.55 #18787 +/- ##
=============================================
Coverage ? 84.60%
=============================================
Files ? 2329
Lines ? 131954
Branches ? 35585
=============================================
Hits ? 111642
Misses ? 19964
Partials ? 348
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…rd form (#18684) ## Summary `CheckoutView.vue` always mounted `StripePaymentForm`, so any plan change on an existing subscription that doesn't need a new card (a scheduled/duration change, or any upgrade/downgrade — Stripe charges the subscription's saved default method server-side) showed "The payment form isn't available right now" with "Pay and subscribe" disabled, blocking the customer entirely. ## Why A customer on a subscribed Team workspace could not complete a scheduled plan change on billing-web at all. The page rendered a payment form that could never succeed, with no way to confirm a change that in fact required no payment today. ## Root cause Live testing on testcloud/testbilling: a subscribed Team workspace (yearly, `team_700` stop) changing to monthly hands off to billing-web's `/v1/checkout?...&team_credit_stop_id=team_700`. `POST /api/billing/preview-subscribe` returns `transition_type: "duration_change"`, `is_immediate: false`, $0 due today, and no `payment_method_configuration_id`. `CheckoutView.vue` mounted `StripePaymentForm` unconditionally; that component hard-fails (`failElementInit()`, `packages/account-ui/src/billing/stripe/StripePaymentForm.vue:217`) whenever `paymentMethodConfigurationId` is empty. The Cloud app already solves this correctly: `src/platform/workspace/composables/useSubscriptionCheckout.ts`'s `subscribeAcceptsSavedMethod()` and its accompanying comment state that "the transition workflows charge the subscription's existing default method and reject a payment-method selection outright" — any `transition_type` other than `'new_subscription'` skips card capture and confirms straight against the saved method. `SubscriptionTransitionPreviewWorkspace.vue` (confirm-only) vs `SubscriptionAddPaymentPreviewWorkspace.vue` (card capture) branch on exactly that field. ## How `CheckoutView.vue` now branches on `preview.transition_type === 'new_subscription'` (`needsPaymentMethod`), the same signal the Cloud app already ships, read straight off the required, non-optional `transition_type` field — no guessing from `payment_method_configuration_id`'s presence, which is ambiguous (see Backend dependency below). When a card is needed, the existing `StripePaymentForm` path is unchanged, including the 3DS/result flow. When it isn't, a plain confirm form calls the same `checkout.subscribe`/`subscribeRequest`, just without a `confirmation_token` — `zSubscribeRequest.confirmation_token` is already optional, so no new command was needed. Test default fixtures (`previewOf()` in `fakeBillingClient.ts`, the e2e `scenario.preview`) moved from `transition_type: 'upgrade'` to `'new_subscription'`, since that's what most existing tests actually exercise (card entry). Tests that specifically cover a transition now set `transition_type` explicitly. Added table-driven coverage (`it.for`) for upgrade/downgrade/duration_change confirming without a card form, and an e2e case in `checkout.spec.ts`. `subscription.spec.ts`'s "choosing a plan... continues to checkout" test previously asserted the exact bug ("The payment form isn't available right now" was the *expected* outcome for an upgrade) — updated to assert the fixed confirm-only UI instead. ## Backend dependency Separately, on testcloud a brand-new subscription (`transition_type: "new_subscription"`, `is_immediate: true`, real cost) can *also* come back with no `payment_method_configuration_id`, because `services/ingest/server/implementation/billing.go` only calls `attachPaymentMethodConfiguration` when the per-user `embedded_checked_enabled` PostHog flag is on. billing-web always renders the embedded Stripe form (it has no non-embedded fallback the way the Cloud app might), so a user outside that flag still hits "payment form isn't available" on a genuine new-subscription checkout. This PR doesn't work around that on the frontend — the server needs to attach the payment method configuration for billing-web requests unconditionally (or expose an explicit flag), independent of `embedded_checked_enabled`. ## Changes - **What**: `CheckoutView.vue` renders a confirm-only path (summary + button, no Stripe form) when the preview's `transition_type` isn't `new_subscription`; `subscribeRequest`/`confirm` accept an optional `confirmationToken`. - **Dependencies**: none. ## Review Focus The `transition_type` condition and whether it should live in `account-ui` instead (kept in `CheckoutView.vue` per ADR-PACKAGES-ACCOUNT-UI-0034 — it's not Stripe-provider-bound, so nothing in the ADR forces promotion, and the change stays minimal). The Backend dependency note above — flagging it, not fixing it here. ## AS IS / TO BE | AS IS | TO BE | | --- | --- | | <img width="780" alt="AS IS" src="https://github.com/user-attachments/assets/8abf59a9-5b8f-411a-a9c0-c3dad42610c2" /> | <img width="780" alt="TO BE" src="https://github.com/user-attachments/assets/3311d71d-ec5b-4606-92ef-8988442bd543" /> | Personal Workspace with an active `team_per_credit_annual` / `team_700` subscription, opening `/v1/checkout?product=comfyui&return_to=comfyui_workspace&plan=team_per_credit_monthly&team_credit_stop_id=team_700` against testcloud. `POST /api/billing/preview-subscribe` returns `transition_type: "duration_change"`, `is_immediate: false`, `cost_today_cents: 0`. - AS IS: https://testbilling.comfy.org (main build). The payment section never renders a card form and "Pay and subscribe" stays disabled (still disabled after 30s, no Stripe frame mounted). The preview now carries a `payment_method_configuration_id`, so the "payment form isn't available" copy from the original report did not show on this run, but the customer is still blocked. - TO BE: this branch on http://localhost:5174. Confirm-only form: summary plus an enabled "Pay and subscribe", no card form. The button was not clicked, so the subscription was not changed. - Fixes #ISSUE_NUMBER <!-- m2-dep-graph:start --> ## Plan position: Milestone 2 payment-test fixes Found in the live M2 run (testcloud → testbilling, Team per-credit checkout). None of these PRs depends on another to merge. Solid arrows gate a milestone step; dotted ones are nice-to-have. | PR | Defect | Dependency | |---|---|---| | [D5 cloud#10518](Comfy-Org/cloud#10518) | test-v2 billing-worker uses the wrong Stripe key; every confirm fails `parameter_missing client_secret` | Blocker on test only (config). Unblocks the live re-run. | | [D4 cloud#10514](Comfy-Org/cloud#10514) | preview-subscribe attaches `payment_method_configuration_id` only when `embedded_checked_enabled` is on | Required before widening `hosted_billing_destination` past the flag cohort. | | **[D3 FE #18684](#18684) (this PR)** | billing-web asks for a card on plan changes that need none | Independent. Shares e2e fixtures with #18687. | | [D6 FE #18687](#18687) | failed-payment UI ignores `recovery_action` / `retryable` | Independent. Shares e2e fixtures with #18684. | | [D8 FE #18686](#18686) | Stripe Element labels invisible in dark theme | Independent (cosmetic). | | [D7 FE #18685](#18685) | billing-web font URL broken (`/fonts/inter-*.woff2`) | Independent (cosmetic). | ```mermaid flowchart LR c10518["D5 cloud#10518<br/>test-v2 Stripe key"] c10514["D4 cloud#10514<br/>always attach pmc id"] f18684["D3 #18684<br/>no card for plan change"] f18687["D6 #18687<br/>recovery_action UI"] f18686["D8 #18686<br/>dark-theme labels"] f18685["D7 #18685<br/>fonts"] RERUN(["M2 live payment re-run<br/>testcloud → testbilling"]) ROLLOUT(["Widen hosted_billing_destination<br/>beyond flag cohort"]) c10518 --> RERUN c10514 --> ROLLOUT f18684 --> ROLLOUT f18687 --> ROLLOUT f18686 -.-> ROLLOUT f18685 -.-> ROLLOUT RERUN --> ROLLOUT f18684 <-. "shared e2e fixtures:<br/>second to merge pulls main" .-> f18687 style f18684 fill:#f9d71c,stroke:#333,stroke-width:3px,color:#000 ``` <!-- m2-dep-graph:end -->
579dcf3 to
baa42f2
Compare
christian-byrne
left a comment
There was a problem hiding this comment.
Verified rather than rubber-stamped: the changed-file list matches the original PR exactly, and the diff contains no conflict markers. Required checks on this branch are lint-and-format, test and e2e-status; any other red check here is advisory and does not gate the merge.
Backport of #18684 to
cloud/1.55Automatically created by backport workflow.