diff --git a/src/composables/__mocks__/useFeatureFlags.ts b/src/composables/__mocks__/useFeatureFlags.ts
index 1471de61b2f..9e21223fe43 100644
--- a/src/composables/__mocks__/useFeatureFlags.ts
+++ b/src/composables/__mocks__/useFeatureFlags.ts
@@ -43,7 +43,6 @@ const defaultFlags: FeatureFlags = {
billingSdkTopupRailEnabled: false,
billingSdkSubscriptionEnabled: false,
unifiedBillingSettingsEnabled: false,
- autoTopUpEnabled: false,
billingSdkSubscriptionRailEnabled: false,
v1PaymentRecovery: false,
signupTurnstileMode: 'off',
diff --git a/src/composables/useFeatureFlags.test.ts b/src/composables/useFeatureFlags.test.ts
index 503f90b021d..db8be790058 100644
--- a/src/composables/useFeatureFlags.test.ts
+++ b/src/composables/useFeatureFlags.test.ts
@@ -391,8 +391,7 @@ describe('useFeatureFlags', () => {
{
flag: 'unifiedBillingSettingsEnabled' as const,
offCloudTrue: true
- },
- { flag: 'autoTopUpEnabled' as const, offCloudTrue: false }
+ }
])('$flag', ({ flag, offCloudTrue }) => {
afterEach(() => {
vi.mocked(distributionTypes).isCloud = false
diff --git a/src/composables/useFeatureFlags.ts b/src/composables/useFeatureFlags.ts
index 41071d0d28d..4194ff272d7 100644
--- a/src/composables/useFeatureFlags.ts
+++ b/src/composables/useFeatureFlags.ts
@@ -349,14 +349,6 @@ export function useFeatureFlags() {
remoteConfig.value.unified_billing_settings
)
},
- get autoTopUpEnabled() {
- if (!isCloud) return false
-
- return resolveStrictBooleanFlag(
- ServerFeatureFlag.AUTO_TOP_UP_ENABLED,
- remoteConfig.value.auto_top_up_enabled
- )
- },
get v1PaymentRecovery() {
return resolveAuthGatedFlag(
ServerFeatureFlag.V1_PAYMENT_RECOVERY,
@@ -447,7 +439,6 @@ export function startFeatureFlagTelemetry() {
flags.billingSdkSubscriptionEnabled,
[ServerFeatureFlag.UNIFIED_BILLING_SETTINGS]:
flags.unifiedBillingSettingsEnabled,
- [ServerFeatureFlag.AUTO_TOP_UP_ENABLED]: flags.autoTopUpEnabled,
[ServerFeatureFlag.V1_PAYMENT_RECOVERY]: flags.v1PaymentRecovery,
[ServerFeatureFlag.SIGNUP_TURNSTILE]: flags.signupTurnstileMode,
[ServerFeatureFlag.SUPPORTS_MODEL_TYPE_TAGS]: flags.supportsModelTypeTags,
diff --git a/src/locales/en/main.json b/src/locales/en/main.json
index 0eb266ad8e2..948b25f7973 100644
--- a/src/locales/en/main.json
+++ b/src/locales/en/main.json
@@ -3017,6 +3017,10 @@
"verifyTitle": "Verify your payment",
"startOver": "Start over",
"viewPricing": "View pricing details",
+ "autoTopUp": {
+ "prompt": "Running low on credits? Turn on auto top-up.",
+ "setUp": "Set up"
+ },
"youPay": "Amount (USD)",
"youGet": "Credits",
"buyCredits": "Continue to payment",
diff --git a/src/platform/billing/components/TopUpAutoTopUpCard.test.ts b/src/platform/billing/components/TopUpAutoTopUpCard.test.ts
new file mode 100644
index 00000000000..582490e9638
--- /dev/null
+++ b/src/platform/billing/components/TopUpAutoTopUpCard.test.ts
@@ -0,0 +1,127 @@
+import type { AutoTopUpSetup } from '@comfyorg/ingest-types'
+import { render, screen } from '@testing-library/vue'
+import userEvent from '@testing-library/user-event'
+import { describe, expect, it, vi } from 'vitest'
+import { computed } from 'vue'
+import { createI18n } from 'vue-i18n'
+
+import enMessages from '@/locales/en/main.json'
+import { useTelemetry } from '@/platform/telemetry'
+import {
+ autoTopUpCardState,
+ loadedAutoTopUp
+} from '@/platform/billing/composables/__mocks__/useBillingAutoTopUpCard'
+import {
+ autoTopUpEnabledFact,
+ canManageAutoTopUpFact
+} from '@/platform/billing/composables/__mocks__/useBillingCapabilities'
+import { useBillingAutoTopUpCard } from '@/platform/billing/composables/useBillingAutoTopUpCard'
+import { useBillingCapabilities } from '@/platform/billing/composables/useBillingCapabilities'
+
+import TopUpAutoTopUpCard from './TopUpAutoTopUpCard.vue'
+
+vi.mock(import('@/platform/billing/composables/useBillingCapabilities'))
+vi.mock(import('@/platform/billing/composables/useBillingAutoTopUpCard'))
+vi.mock(import('@/platform/telemetry'))
+vi.mock(import('@/platform/workspace/utils/platformLink'), () => ({
+ platformLink: (path: string, correlationId?: string) =>
+ `https://platform.test${path}?correlation_id=${correlationId}`
+}))
+
+const PROMPT = 'Running low on credits? Turn on auto top-up.'
+
+type Served = {
+ enabled: boolean
+ canManage: boolean
+ setup: AutoTopUpSetup | null
+ card: ReturnType | { kind: 'loading' | 'unavailable' }
+}
+
+const shown: Served = {
+ enabled: true,
+ canManage: true,
+ setup: { state: 'ready' },
+ card: loadedAutoTopUp('off')
+}
+
+function renderCard(served: Partial = {}) {
+ const { enabled, canManage, setup, card } = { ...shown, ...served }
+ const capabilities = useBillingCapabilities()
+ capabilities.autoTopUpEnabled = autoTopUpEnabledFact(enabled)
+ capabilities.canManageAutoTopUp = canManageAutoTopUpFact(canManage)
+ capabilities.autoTopUpSetup = computed(() => setup)
+ autoTopUpCardState.value = card
+ render(TopUpAutoTopUpCard, {
+ global: {
+ plugins: [
+ createI18n({
+ legacy: false,
+ locale: 'en',
+ messages: { en: enMessages }
+ })
+ ]
+ }
+ })
+}
+
+describe('TopUpAutoTopUpCard', () => {
+ it('offers a manager with auto top-up off to set it up on the billing site', () => {
+ renderCard()
+
+ expect(screen.getByText(PROMPT)).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Set up' })).toHaveAttribute(
+ 'href',
+ expect.stringContaining('https://platform.test/profile/billing')
+ )
+ })
+
+ it.for<{ name: string } & Partial>([
+ { name: 'auto top-up is not served', enabled: false },
+ { name: 'the viewer cannot manage it', canManage: false },
+ { name: 'no setup is served', setup: null },
+ {
+ name: 'setup is unavailable',
+ setup: { state: 'unavailable', reason: 'workspace_blocked' }
+ },
+ {
+ name: 'setup is frozen by a past-due payment',
+ setup: { state: 'frozen', reason: 'payment_past_due' }
+ },
+ { name: 'auto top-up is already on', card: loadedAutoTopUp('on') },
+ { name: 'auto top-up has failed', card: loadedAutoTopUp('failed') },
+ { name: 'the status is still loading', card: { kind: 'loading' } },
+ { name: 'the status read failed', card: { kind: 'unavailable' } }
+ ])('shows nothing when $name', ({ name: _, ...served }) => {
+ renderCard(served)
+
+ expect(screen.queryByText(PROMPT)).toBeNull()
+ })
+
+ it('stays shown while setup is frozen for another reason', () => {
+ renderCard({ setup: { state: 'frozen', reason: 'billing_paused' } })
+
+ expect(screen.getByText(PROMPT)).toBeInTheDocument()
+ })
+
+ it('reads the auto top-up status only when the served facts allow setup', () => {
+ renderCard({ canManage: false })
+ expect(useBillingAutoTopUpCard().ensureRead).not.toHaveBeenCalled()
+
+ renderCard()
+ expect(useBillingAutoTopUpCard().ensureRead).toHaveBeenCalledOnce()
+ })
+
+ it('reports the hand-off to the billing site', async () => {
+ renderCard()
+
+ await userEvent.click(screen.getByRole('link', { name: 'Set up' }))
+
+ expect(useTelemetry()?.trackBillingEvent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ operation: 'platform_handoff',
+ target: 'auto_top_up',
+ action: 'turn_on'
+ })
+ )
+ })
+})
diff --git a/src/platform/billing/components/TopUpAutoTopUpCard.vue b/src/platform/billing/components/TopUpAutoTopUpCard.vue
new file mode 100644
index 00000000000..6053b42dfdf
--- /dev/null
+++ b/src/platform/billing/components/TopUpAutoTopUpCard.vue
@@ -0,0 +1,63 @@
+
+
+
+ {{ $t('credits.topUp.autoTopUp.prompt') }}
+
+
+
+
+
+
diff --git a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.test.ts b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.test.ts
index 720fd98dd6b..164befb3876 100644
--- a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.test.ts
+++ b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.test.ts
@@ -7,6 +7,15 @@ import { createI18n } from 'vue-i18n'
import enMessages from '@/locales/en/main.json'
import { useToast } from '@/components/ui/toast/toastStore'
+import {
+ autoTopUpCardState,
+ loadedAutoTopUp
+} from '@/platform/billing/composables/__mocks__/useBillingAutoTopUpCard'
+import {
+ autoTopUpEnabledFact,
+ canManageAutoTopUpFact
+} from '@/platform/billing/composables/__mocks__/useBillingCapabilities'
+import { useBillingCapabilities } from '@/platform/billing/composables/useBillingCapabilities'
import { useBillingContext } from '@/platform/billing/composables/useBillingContext'
import { useBillingRouting } from '@/platform/billing/composables/useBillingRouting'
import { useSubscription } from '@/platform/billing/subscription/composables/useSubscription'
@@ -26,6 +35,8 @@ vi.mock(import('@/platform/billing/composables/useBillingContext'))
vi.mock(import('@/platform/billing/composables/useBillingCapabilities'))
+vi.mock(import('@/platform/billing/composables/useBillingAutoTopUpCard'))
+
vi.mock(import('@/platform/distribution/types'), () => ({
isCloud: true,
isDesktop: false
@@ -68,7 +79,8 @@ const i18n = createI18n({
contactUs: 'Contact us',
viewPricing: 'View pricing',
insufficientWorkflowMessage: 'Insufficient credits',
- buyCredits: 'Continue to payment'
+ buyCredits: 'Continue to payment',
+ autoTopUp: enMessages.credits.topUp.autoTopUp
}
}
}
@@ -237,6 +249,26 @@ describe('TopUpCreditsDialogContentLegacy', () => {
}
)
+ it('offers auto top-up set-up above Continue to payment when every served fact allows it', () => {
+ const capabilities = useBillingCapabilities()
+ capabilities.autoTopUpEnabled = autoTopUpEnabledFact(true)
+ capabilities.canManageAutoTopUp = canManageAutoTopUpFact(true)
+ capabilities.autoTopUpSetup = computed(() => ({ state: 'ready' as const }))
+ autoTopUpCardState.value = loadedAutoTopUp('off')
+
+ renderDialog()
+
+ const setUp = screen.getByRole('link', { name: 'Set up' })
+ expect(
+ screen.getByText('Running low on credits? Turn on auto top-up.')
+ ).toBeInTheDocument()
+ expect(
+ setUp.compareDocumentPosition(
+ screen.getByRole('button', { name: 'Continue to payment' })
+ ) & Node.DOCUMENT_POSITION_FOLLOWING
+ ).toBeTruthy()
+ })
+
it('shows Plan & Credits after a successful Cloud purchase', async () => {
renderDialog()
await clickBuyCredits()
diff --git a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue
index b615a39fa35..28cdf61a9c9 100644
--- a/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue
+++ b/src/platform/billing/components/TopUpCreditsDialogContentLegacy.vue
@@ -138,15 +138,18 @@
-
+
+
+
+
{
})
}
+ describe('the auto top-up card', () => {
+ const AUTO_TOP_UP_PROMPT = 'Running low on credits? Turn on auto top-up.'
+
+ beforeEach(() => {
+ const capabilities = useBillingCapabilities()
+ capabilities.autoTopUpEnabled = autoTopUpEnabledFact(true)
+ capabilities.canManageAutoTopUp = canManageAutoTopUpFact(true)
+ capabilities.autoTopUpSetup = computed(() => ({
+ state: 'ready' as const
+ }))
+ autoTopUpCardState.value = loadedAutoTopUp('off')
+ })
+
+ it('sits above Add credits on the amount step', () => {
+ renderDialog()
+
+ const setUp = screen.getByRole('link', { name: 'Set up' })
+ expect(screen.getByText(AUTO_TOP_UP_PROMPT)).toBeInTheDocument()
+ expect(
+ setUp.compareDocumentPosition(
+ screen.getByRole('button', { name: 'Add credits' })
+ ) & Node.DOCUMENT_POSITION_FOLLOWING
+ ).toBeTruthy()
+ })
+
+ it('is gone on the payment step', async () => {
+ renderDialog()
+
+ await clickAddCredits()
+
+ expect(
+ screen.getByRole('button', { name: 'Pay $50.00' })
+ ).toBeInTheDocument()
+ expect(screen.queryByText(AUTO_TOP_UP_PROMPT)).not.toBeInTheDocument()
+ })
+
+ it('gives way to the payment processing notice', async () => {
+ vi.mocked(useFeatureFlags().flags).unifiedBillingSettingsEnabled = true
+ serveProcessingCheckout(2500)
+ renderDialog()
+
+ await screen.findByRole('status')
+ expect(screen.queryByText(AUTO_TOP_UP_PROMPT)).not.toBeInTheDocument()
+ })
+ })
+
describe('a top-up payment still processing', () => {
it('keeps add credits available and names the served amount', async () => {
vi.mocked(useFeatureFlags().flags).unifiedBillingSettingsEnabled = true
diff --git a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue
index 48bccf2e777..9c39afbb8c5 100644
--- a/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue
+++ b/src/platform/billing/components/TopUpCreditsDialogContentWorkspace.vue
@@ -363,6 +363,10 @@
{{ $t('credits.topUp.paymentProcessingBody') }}
+