Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(billing): show mobile-app subscribers their plan, not Free (#2535) (#2541)
Chad Pihababd2f042852
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex 90d1d819d..d9dcc311e 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -132,7 +132,7 @@ import {} from "../stores/settingsStore";import { useWorkspaceStore } from "../stores/workspaceStore";import { highestPlan } from "../lib/usageStore";-import { decideProPlanCardCta } from "../lib/upsell";+import { decideProPlanCardCta, resolveAccountPlan, storeSubscriptionsUrl } from "../lib/upsell";import {canChangeCloudBackupPreference,effectiveAudioRetentionDays,@@ -1876,10 +1876,29 @@ export default function SettingsPage({isSignedIn,planStateKnown,isPersonallySubscribed: usage?.isPersonallySubscribed ?? false,+ isStoreBilled: Boolean(usage?.storeBilling),plan: usage?.plan ?? "free",isTrial: usage?.isTrial ?? false,isWorkspaceCovered,});+ const storeBilling = usage?.storeBilling ?? null;+ const accountPlan = resolveAccountPlan({+ isTrial: usage?.isTrial ?? false,+ isPastDue: usage?.isPastDue ?? false,+ isPersonallySubscribed: usage?.isPersonallySubscribed ?? false,+ storeBilling,+ isWorkspaceCovered,+ hasPeriodEnd: Boolean(usage?.currentPeriodEnd),+ hasCoveringWorkspaceNames: coveringWorkspaceNames.length > 0,+ });+ const storeUrl = storeBilling?.store ? storeSubscriptionsUrl(storeBilling.store) : null;+ const periodEndDate = usage?.currentPeriodEnd+ ? new Date(usage.currentPeriodEnd).toLocaleDateString(i18n.language, {+ month: "short",+ day: "numeric",+ year: "numeric",+ })+ : null;const [isSigningOut, setIsSigningOut] = useState(false);const [isDeletingAccount, setIsDeletingAccount] = useState(false);const [isDeleteAccountDialogOpen, setIsDeleteAccountDialogOpen] = useState(false);@@ -2390,11 +2409,11 @@ export default function SettingsPage({<SettingsPanelRow><SettingsRowlabel={- usage.isTrial+ accountPlan.row === "trial"? t("settingsPage.account.planLabels.trial")- : usage.isPastDue+ : accountPlan.row === "pastDue"? t("settingsPage.account.planLabels.free")- : usage.isPersonallySubscribed+ : accountPlan.row === "personal" || accountPlan.row === "store"? usage.plan === "business"? t("settingsPage.account.planLabels.business"): t("settingsPage.account.planLabels.pro")@@ -2402,45 +2421,44 @@ export default function SettingsPage({t("settingsPage.account.planLabels.free"))}description={- usage.isTrial+ accountPlan.description === "trial"? t("settingsPage.account.planDescriptions.trial", {days: usage.trialDaysLeft,})- : usage.isPastDue+ : accountPlan.description === "pastDue"? t("settingsPage.account.planDescriptions.pastDue", {used: usage.wordsUsed.toLocaleString(i18n.language),limit: usage.limit.toLocaleString(i18n.language),})- : usage.isPersonallySubscribed- ? usage.currentPeriodEnd- ? t("settingsPage.account.planDescriptions.nextBilling", {- date: new Date(usage.currentPeriodEnd).toLocaleDateString(- i18n.language,- { month: "short", day: "numeric", year: "numeric" }- ),- })- : t("settingsPage.account.planDescriptions.unlimited")- : coveringWorkspaceNames.length > 0- ? t("settingsPage.unifiedBilling.providedBy", {- workspaces: coveringWorkspaceNames.join(", "),+ : accountPlan.description === "storePaymentIssue"+ ? t("settingsPage.account.planDescriptions.storePaymentIssue")+ : accountPlan.description === "accessUntil"+ ? t("settingsPage.account.planDescriptions.accessUntil", {+ date: periodEndDate,})- : // usage.limit is -1 once subscribed, which the- // free-usage copy would print as "-1 words".- isWorkspaceCovered- ? t("settingsPage.account.planDescriptions.unlimited")- : t("settingsPage.account.planDescriptions.freeUsage", {- used: usage.wordsUsed.toLocaleString(i18n.language),- limit: usage.limit.toLocaleString(i18n.language),+ : accountPlan.description === "nextBilling"+ ? t("settingsPage.account.planDescriptions.nextBilling", {+ date: periodEndDate,})+ : accountPlan.description === "unlimited"+ ? t("settingsPage.account.planDescriptions.unlimited")+ : accountPlan.description === "providedBy"+ ? t("settingsPage.unifiedBilling.providedBy", {+ workspaces: coveringWorkspaceNames.join(", "),+ })+ : t("settingsPage.account.planDescriptions.freeUsage", {+ used: usage.wordsUsed.toLocaleString(i18n.language),+ limit: usage.limit.toLocaleString(i18n.language),+ })}>- {usage.isTrial ? (+ {accountPlan.row === "trial" ? (<Badge variant="info">{t("settingsPage.account.badges.trial")}</Badge>- ) : usage.isPastDue ? (+ ) : accountPlan.row === "pastDue" ? (<Badge variant="destructive">{t("settingsPage.account.badges.pastDue")}</Badge>- ) : usage.isPersonallySubscribed ? (+ ) : accountPlan.row === "personal" || accountPlan.row === "store" ? (<Badge variant="success">{usage.plan === "business"? t("settingsPage.account.badges.business")@@ -2499,7 +2517,7 @@ export default function SettingsPage({)}<SettingsPanelRow>- {usage.isPastDue ? (+ {accountPlan.action === "updatePayment" ? (<ButtononClick={() => void openBillingPortal()}disabled={isOpeningBilling}@@ -2515,7 +2533,22 @@ export default function SettingsPage({t("settingsPage.account.billing.updatePaymentMethod"))}</Button>- ) : usage.isPersonallySubscribed && !usage.isTrial ? (+ ) : accountPlan.action === "manageInStore" && storeUrl ? (+ <Button+ onClick={() => void window.electronAPI?.openExternal?.(storeUrl)}+ variant="outline"+ size="sm"+ className="w-full"+ >+ {storeBilling?.store === "play_store"+ ? t("settingsPage.account.billing.manageInGooglePlay")+ : t("settingsPage.account.billing.manageInAppStore")}+ </Button>+ ) : accountPlan.action === "storeNote" ? (+ <p className="text-xs text-muted-foreground">+ {t("settingsPage.account.billing.managedInMobileStore")}+ </p>+ ) : accountPlan.action === "manageBilling" ? (<ButtononClick={() => void openBillingPortal()}variant="outline"@@ -2527,7 +2560,7 @@ export default function SettingsPage({? t("settingsPage.account.billing.opening"): t("settingsPage.account.billing.manageBilling")}</Button>- ) : isWorkspaceCovered ? null : (+ ) : accountPlan.action === "none" ? null : (<ButtononClick={async () => {setCheckoutTier("plan-upgrade");@@ -2569,6 +2602,7 @@ export default function SettingsPage({"rounded-md p-2.5 flex flex-col",planStateKnown &&!usage?.isPersonallySubscribed &&+ !storeBilling &&!usage?.isTrial &&!isWorkspaceCovered? "border-2 border-primary/30 bg-primary/3 dark:border-primary/20 dark:bg-primary/5"@@ -2631,7 +2665,7 @@ export default function SettingsPage({? t("settingsPage.account.billing.opening"): t("settingsPage.account.pricing.downgrade")}</Button>- ) : planStateKnown && !isWorkspaceCovered ? (+ ) : planStateKnown && !isWorkspaceCovered && !storeBilling ? (<div className="mt-2 text-center"><span className="text-[9px] font-medium text-primary/70">{t("settingsPage.account.pricing.currentPlan")}@@ -2643,7 +2677,8 @@ export default function SettingsPage({<divclassName={cn("rounded-md border-2 p-2.5 flex flex-col",- usage?.isPersonallySubscribed && usage?.plan === "pro"+ (usage?.isPersonallySubscribed || (storeBilling && !isWorkspaceCovered)) &&+ usage?.plan === "pro"? "border-primary/40 bg-primary/5 dark:border-primary/30 dark:bg-primary/8": "border-primary/20 bg-primary/2 dark:border-primary/15 dark:bg-primary/3")}diff --git a/src/hooks/useUsage.ts b/src/hooks/useUsage.tsindex 13475d83b..1dc081bf0 100644--- a/src/hooks/useUsage.ts+++ b/src/hooks/useUsage.ts@@ -7,8 +7,10 @@ import {loadUsage,retryUsage,setUsageAccount,+ storeBillingOf,subscribeUsage,watchForUpgrade,+ type StoreBilling,type UsageResponse,type UsageState,} from "../lib/usageStore";@@ -36,6 +38,8 @@ export interface UseUsageResult {limit: number;isSubscribed: boolean;isPersonallySubscribed: boolean;+ /** Set when the plan was bought in the mobile app; manage it in the store, never through Stripe. */+ storeBilling: StoreBilling | null;entitledWorkspaceIds: string[];isTrial: boolean;trialDaysLeft: number | null;@@ -244,6 +248,7 @@ export function useUsage(): UseUsageResult | null {limit,isSubscribed,isPersonallySubscribed: data?.entitlementSources.personal ?? false,+ storeBilling: data ? storeBillingOf(data) : null,entitledWorkspaceIds: data?.entitlementSources.workspaceIds ?? [],isTrial,trialDaysLeft: data?.trialDaysLeft ?? null,diff --git a/src/lib/upsell.ts b/src/lib/upsell.tsindex b2456fdf9..007012a02 100644--- a/src/lib/upsell.ts+++ b/src/lib/upsell.ts@@ -1,3 +1,5 @@+import type { ProviderStore, StoreBilling } from "./usageStore.ts";+export type UpsellDecision = "show" | "hide" | "unknown";export interface UpsellInput {@@ -31,6 +33,8 @@ export interface ProPlanCardInput {/** Signed out, or usage.status === "success". */planStateKnown: boolean;isPersonallySubscribed: boolean;+ /** Bought in the mobile app: any Stripe checkout or plan switch would bill twice. */+ isStoreBilled: boolean;plan: string;isTrial: boolean;/** SettingsPage's usage-payload predicate — not the workspace store. */@@ -38,6 +42,9 @@ export interface ProPlanCardInput {}export function decideProPlanCardCta(i: ProPlanCardInput): ProPlanCardCta {+ // A workspace seat outranks a store plan, as it does in the account row.+ if (i.isStoreBilled && !i.isWorkspaceCovered)+ return i.plan === "business" ? "none" : "currentPlan";if ((i.isPersonallySubscribed && i.plan === "pro" && !i.isTrial) || i.isTrial)return "currentPlan";if (i.isPersonallySubscribed && i.plan === "business") return "downgradeToPro";@@ -46,3 +53,93 @@ export function decideProPlanCardCta(i: ProPlanCardInput): ProPlanCardCta {if (i.isWorkspaceCovered) return "coveredByWorkspace"; // the regression fixreturn "checkout";}++/** Which plan the account row shows, in precedence order. */+export type AccountPlanRow = "trial" | "pastDue" | "personal" | "store" | "workspaceOrFree";++/** The account row's description text. */+export type AccountPlanDescription =+ | "trial"+ | "pastDue"+ | "storePaymentIssue"+ | "accessUntil"+ | "nextBilling"+ | "unlimited"+ | "providedBy"+ | "freeUsage";++/** The account row's billing button. `storeNote` is store billing on an API that doesn't name the store. */+export type AccountPlanAction =+ "updatePayment" | "manageBilling" | "manageInStore" | "storeNote" | "upgrade" | "none";++export interface AccountPlanInput {+ isTrial: boolean;+ /** Stripe past due only (`isPastDueUsage`). */+ isPastDue: boolean;+ isPersonallySubscribed: boolean;+ storeBilling: StoreBilling | null;+ isWorkspaceCovered: boolean;+ hasPeriodEnd: boolean;+ /** The workspace store has loaded the covering workspaces, so their names can be shown. */+ hasCoveringWorkspaceNames: boolean;+}++export function resolveAccountPlan(i: AccountPlanInput): {+ row: AccountPlanRow;+ description: AccountPlanDescription;+ action: AccountPlanAction;+} {+ // A workspace seat outranks a store plan for the row, but the store still+ // bills, so the button stays on the store.+ const row: AccountPlanRow = i.isTrial+ ? "trial"+ : i.isPastDue+ ? "pastDue"+ : i.isPersonallySubscribed+ ? "personal"+ : i.storeBilling && !i.isWorkspaceCovered+ ? "store"+ : "workspaceOrFree";+ const storeStatus = row === "store" ? i.storeBilling?.status : undefined;+ const description: AccountPlanDescription =+ row === "trial" || row === "pastDue"+ ? row+ : row === "workspaceOrFree"+ ? i.hasCoveringWorkspaceNames+ ? "providedBy"+ : // usage.limit is -1 once subscribed, which the free-usage copy+ // would print as "-1 words".+ i.isWorkspaceCovered+ ? "unlimited"+ : "freeUsage"+ : storeStatus === "past_due"+ ? "storePaymentIssue"+ : !i.hasPeriodEnd+ ? "unlimited"+ : // A canceled store subscription stays entitled until the period+ // it was paid for ends.+ storeStatus === "canceled"+ ? "accessUntil"+ : "nextBilling";+ const action: AccountPlanAction = i.isPastDue+ ? "updatePayment"+ : i.storeBilling+ ? i.storeBilling.store+ ? "manageInStore"+ : "storeNote"+ : i.isPersonallySubscribed && !i.isTrial+ ? "manageBilling"+ : i.isWorkspaceCovered+ ? "none"+ : "upgrade";+ return { row, description, action };+}++const STORE_SUBSCRIPTIONS_URL: Record<ProviderStore, string> = {+ app_store: "https://apps.apple.com/account/subscriptions",+ play_store: "https://play.google.com/store/account/subscriptions",+};++export function storeSubscriptionsUrl(store: ProviderStore): string {+ return STORE_SUBSCRIPTIONS_URL[store];+}diff --git a/src/lib/usageStore.ts b/src/lib/usageStore.tsindex 9ff622fd3..a2acccadb 100644--- a/src/lib/usageStore.ts+++ b/src/lib/usageStore.ts@@ -16,6 +16,15 @@ export function highestPlan(plans: string[]): string {);}+export type ProviderStore = "app_store" | "play_store";++/** A subscription bought in the mobile app, billed and managed by the store. */+export interface StoreBilling {+ /** `null` when the API predates `providerStore`. */+ store: ProviderStore | null;+ status: string;+}+export interface UsageData {wordsUsed: number;wordsRemaining: number;@@ -30,6 +39,8 @@ export interface UsageData {resetAt: string;entitlementSources: {personal: boolean;+ provider: boolean;+ providerStore: ProviderStore | null;workspaceIds: string[];};}@@ -49,6 +60,8 @@ export interface UsageResponse {resetAt?: string;entitlementSources?: {personal: boolean;+ provider?: boolean;+ providerStore?: string | null;workspaceIds: string[];};}@@ -121,17 +134,43 @@ export function normalizeUsage(response: UsageResponse): UsageData {resetAt: response.resetAt ?? "rolling",// Pre-unified-billing API builds have no entitlementSources; infer a// personal source from the plan so those clients keep working.- entitlementSources: response.entitlementSources ?? {- personal:- response.isTrial === true ||- (PAID_PLANS.has(plan) && ["active", "trialing"].includes(subscriptionStatus)),- workspaceIds: [],- },+ entitlementSources: response.entitlementSources+ ? {+ personal: response.entitlementSources.personal,+ provider: response.entitlementSources.provider ?? false,+ providerStore: toProviderStore(response.entitlementSources.providerStore),+ workspaceIds: response.entitlementSources.workspaceIds,+ }+ : {+ personal:+ response.isTrial === true ||+ (PAID_PLANS.has(plan) && ["active", "trialing"].includes(subscriptionStatus)),+ provider: false,+ providerStore: null,+ workspaceIds: [],+ },};}+function toProviderStore(value: string | null | undefined): ProviderStore | null {+ return value === "app_store" || value === "play_store" ? value : null;+}++/**+ * The API reports the store subscription's plan and status only when no Stripe+ * subscription entitles the account, so a Stripe subscriber is never store-billed.+ */+export function storeBillingOf(data: UsageData): StoreBilling | null {+ const { personal, provider, providerStore } = data.entitlementSources;+ if (personal || !provider) return null;+ return { store: providerStore, status: data.subscriptionStatus };+}++/** Stripe past due only: the store runs its own billing retry and tells the user itself. */export function isPastDueUsage(data: UsageData): boolean {- return PAID_PLANS.has(data.plan) && data.subscriptionStatus === "past_due";+ return (+ PAID_PLANS.has(data.plan) && data.subscriptionStatus === "past_due" && !storeBillingOf(data)+ );}export function setUsageAccount(accountId: string | null): void {diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.jsonindex 2881aee62..e7574d1d7 100644--- a/src/locales/ar/translation.json+++ b/src/locales/ar/translation.json@@ -3200,7 +3200,10 @@"opening": "جاري الفتح...","updatePaymentMethod": "تحديث طريقة الدفع","contactOwnerTitle": "اتصل بمالك مساحة العمل الخاصة بك",- "contactOwnerDescription": "يمكن لمالك مساحة العمل فقط تحديث الفوترة لمساحة العمل هذه."+ "contactOwnerDescription": "يمكن لمالك مساحة العمل فقط تحديث الفوترة لمساحة العمل هذه.",+ "manageInAppStore": "الإدارة في App Store",+ "manageInGooglePlay": "الإدارة في Google Play",+ "managedInMobileStore": "تتم الفوترة عبر متجر التطبيقات على هاتفك. أدِر الاشتراك من هاتفك."},"checkout": {"couldNotOpenDescription": "واجهنا مشكلة في فتح صفحة الدفع. يرجى المحاولة مرة أخرى.",@@ -3224,7 +3227,9 @@"nextBilling": "الفوترة القادمة: {{date}}","pastDue": "{{used}} من {{limit}} كلمة مجانية هذا الأسبوع - قم بتحديث الدفع لاستعادة Pro","trial": "عدد الأيام المتبقية: {{days}} - تفريغ غير محدود",- "unlimited": "غير محدود"+ "unlimited": "غير محدود",+ "accessUntil": "الوصول حتى {{date}}",+ "storePaymentIssue": "تعذّر على متجر التطبيقات تجديد هذا الاشتراك. حدّث طريقة الدفع هناك للاحتفاظ بخطتك."},"planLabels": {"free": "مجاني",diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 3d1334b62..30210b283 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -1866,7 +1866,10 @@"opening": "Wird geöffnet...","updatePaymentMethod": "Zahlungsmethode aktualisieren","contactOwnerTitle": "Wenden Sie sich an den Workspace-Inhaber",- "contactOwnerDescription": "Nur der Workspace-Inhaber kann die Abrechnung für diesen Workspace ändern."+ "contactOwnerDescription": "Nur der Workspace-Inhaber kann die Abrechnung für diesen Workspace ändern.",+ "manageInAppStore": "Im App Store verwalten",+ "manageInGooglePlay": "In Google Play verwalten",+ "managedInMobileStore": "Abrechnung über den App-Store Ihres Smartphones. Verwalten Sie das Abo auf Ihrem Smartphone."},"checkout": {"couldNotOpenDescription": "Die Checkout-Seite konnte nicht geöffnet werden. Bitte versuchen Sie es erneut.",@@ -1890,7 +1893,9 @@"nextBilling": "Nächste Abrechnung: {{date}}","pastDue": "{{used}} / {{limit}} kostenlose Wörter diese Woche – Zahlung aktualisieren, um Pro wiederherzustellen","trial": "Noch {{days}} Tage – unbegrenzte Transkriptionen",- "unlimited": "Unbegrenzt"+ "unlimited": "Unbegrenzt",+ "accessUntil": "Zugang bis {{date}}",+ "storePaymentIssue": "Ihr App-Store konnte dieses Abo nicht verlängern. Aktualisieren Sie dort Ihre Zahlungsmethode, um Ihren Tarif zu behalten."},"planLabels": {"free": "Kostenlos",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex eba84257c..44483ce61 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -1866,7 +1866,10 @@"opening": "Opening...","updatePaymentMethod": "Update Payment Method","contactOwnerTitle": "Contact your workspace owner",- "contactOwnerDescription": "Only the workspace owner can update billing for this workspace."+ "contactOwnerDescription": "Only the workspace owner can update billing for this workspace.",+ "manageInAppStore": "Manage in App Store",+ "manageInGooglePlay": "Manage in Google Play",+ "managedInMobileStore": "Billed through your phone's app store. Manage it from your phone."},"checkout": {"couldNotOpenDescription": "We had trouble opening the checkout page. Please try again.",@@ -1890,7 +1893,9 @@"nextBilling": "Next billing: {{date}}","pastDue": "{{used}} / {{limit}} free words this week - update payment to restore Pro","trial": "{{days}} days remaining - unlimited transcriptions",- "unlimited": "Unlimited"+ "unlimited": "Unlimited",+ "accessUntil": "Access until {{date}}",+ "storePaymentIssue": "Your app store couldn't renew this subscription. Update your payment method there to keep your plan."},"planLabels": {"free": "Free",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex d39f8c21a..300363df2 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -1624,7 +1624,10 @@"opening": "Abriendo...","updatePaymentMethod": "Actualizar método de pago","contactOwnerTitle": "Contacta al propietario del espacio de trabajo",- "contactOwnerDescription": "Solo el propietario del espacio de trabajo puede actualizar su facturación."+ "contactOwnerDescription": "Solo el propietario del espacio de trabajo puede actualizar su facturación.",+ "manageInAppStore": "Gestionar en App Store",+ "manageInGooglePlay": "Gestionar en Google Play",+ "managedInMobileStore": "Se factura a través de la tienda de aplicaciones de tu teléfono. Gestiónala desde tu teléfono."},"checkout": {"couldNotOpenDescription": "Tuvimos problemas al abrir la página de pago. Inténtalo de nuevo.",@@ -1648,7 +1651,9 @@"nextBilling": "Próxima facturación: {{date}}","pastDue": "{{used}} / {{limit}} palabras gratis esta semana: actualiza el pago para restaurar Pro","trial": "{{days}} días restantes: transcripciones ilimitadas",- "unlimited": "Ilimitado"+ "unlimited": "Ilimitado",+ "accessUntil": "Acceso hasta el {{date}}",+ "storePaymentIssue": "Tu tienda de aplicaciones no pudo renovar esta suscripción. Actualiza allí tu método de pago para conservar tu plan."},"planLabels": {"free": "Gratis",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex e8fd6a8f7..d6ae24630 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -1866,7 +1866,10 @@"opening": "Ouverture...","updatePaymentMethod": "Mettre à jour le moyen de paiement","contactOwnerTitle": "Contactez le propriétaire de l'espace de travail",- "contactOwnerDescription": "Seul le propriétaire de l'espace de travail peut modifier sa facturation."+ "contactOwnerDescription": "Seul le propriétaire de l'espace de travail peut modifier sa facturation.",+ "manageInAppStore": "Gérer dans l'App Store",+ "manageInGooglePlay": "Gérer dans Google Play",+ "managedInMobileStore": "Facturé via la boutique d'applications de votre téléphone. Gérez-le depuis votre téléphone."},"checkout": {"couldNotOpenDescription": "Nous avons eu un problème pour ouvrir la page de paiement. Veuillez réessayer.",@@ -1890,7 +1893,9 @@"nextBilling": "Prochaine facturation : {{date}}","pastDue": "{{used}} / {{limit}} mots gratuits cette semaine - mettez à jour le paiement pour restaurer Pro","trial": "{{days}} jours restants - transcriptions illimitées",- "unlimited": "Illimité"+ "unlimited": "Illimité",+ "accessUntil": "Accès jusqu'au {{date}}",+ "storePaymentIssue": "Votre boutique d'applications n'a pas pu renouveler cet abonnement. Mettez-y à jour votre moyen de paiement pour conserver votre forfait."},"planLabels": {"free": "Gratuit",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 185ca2e41..b98ac9bb4 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -1571,7 +1571,10 @@"opening": "Apertura...","updatePaymentMethod": "Aggiorna metodo di pagamento","contactOwnerTitle": "Contatta il proprietario dell'area di lavoro",- "contactOwnerDescription": "Solo il proprietario dell'area di lavoro può aggiornarne la fatturazione."+ "contactOwnerDescription": "Solo il proprietario dell'area di lavoro può aggiornarne la fatturazione.",+ "manageInAppStore": "Gestisci nell'App Store",+ "manageInGooglePlay": "Gestisci su Google Play",+ "managedInMobileStore": "Addebitato tramite lo store di app del tuo telefono. Gestiscilo dal telefono."},"checkout": {"couldNotOpenDescription": "Si è verificato un problema nell'apertura della pagina di pagamento. Riprova.",@@ -1595,7 +1598,9 @@"nextBilling": "Prossima fatturazione: {{date}}","pastDue": "{{used}} / {{limit}} parole gratuite questa settimana — aggiorna il pagamento per ripristinare Pro","trial": "{{days}} giorni rimanenti — trascrizioni illimitate",- "unlimited": "Illimitato"+ "unlimited": "Illimitato",+ "accessUntil": "Accesso fino al {{date}}",+ "storePaymentIssue": "Lo store di app non è riuscito a rinnovare questo abbonamento. Aggiorna lì il metodo di pagamento per mantenere il tuo piano."},"planLabels": {"free": "Gratuito",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 9eeae436f..5e1e586ca 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -1571,7 +1571,10 @@"opening": "開いています...","updatePaymentMethod": "お支払い方法を更新","contactOwnerTitle": "ワークスペースのオーナーにご連絡ください",- "contactOwnerDescription": "このワークスペースの請求を更新できるのはオーナーのみです。"+ "contactOwnerDescription": "このワークスペースの請求を更新できるのはオーナーのみです。",+ "manageInAppStore": "App Store で管理",+ "manageInGooglePlay": "Google Play で管理",+ "managedInMobileStore": "スマートフォンのアプリストアで請求されています。スマートフォンから管理してください。"},"checkout": {"couldNotOpenDescription": "購入ページを開く際に問題が発生しました。もう一度お試しください。",@@ -1595,7 +1598,9 @@"nextBilling": "次の請求日: {{date}}","pastDue": "今週 {{used}} / {{limit}} 無料ワード使用済み - お支払い方法を更新して Pro を復元","trial": "残り {{days}} 日 - 無制限の文字起こし",- "unlimited": "無制限"+ "unlimited": "無制限",+ "accessUntil": "{{date}} まで利用可能",+ "storePaymentIssue": "アプリストアでこのサブスクリプションを更新できませんでした。プランを継続するには、ストアでお支払い方法を更新してください。"},"planLabels": {"free": "無料",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex aeab8e421..89321d2d9 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -1550,7 +1550,10 @@"opening": "Abrindo...","updatePaymentMethod": "Atualizar forma de pagamento","contactOwnerTitle": "Fale com o proprietário do workspace",- "contactOwnerDescription": "Apenas o proprietário do workspace pode atualizar a cobrança dele."+ "contactOwnerDescription": "Apenas o proprietário do workspace pode atualizar a cobrança dele.",+ "manageInAppStore": "Gerenciar na App Store",+ "manageInGooglePlay": "Gerenciar no Google Play",+ "managedInMobileStore": "Cobrado pela loja de apps do seu celular. Gerencie pelo celular."},"checkout": {"couldNotOpenDescription": "Tivemos dificuldade em abrir a página de checkout. Tente novamente.",@@ -1574,7 +1577,9 @@"nextBilling": "Próxima cobrança: {{date}}","pastDue": "{{used}} / {{limit}} palavras gratuitas esta semana — atualize o pagamento para restaurar o Pro","trial": "{{days}} dias restantes — transcrições ilimitadas",- "unlimited": "Ilimitado"+ "unlimited": "Ilimitado",+ "accessUntil": "Acesso até {{date}}",+ "storePaymentIssue": "A loja de apps não conseguiu renovar esta assinatura. Atualize lá sua forma de pagamento para manter seu plano."},"planLabels": {"free": "Gratuito",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 1bf15801e..e6bbdf148 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -1575,7 +1575,10 @@"opening": "Открытие...","updatePaymentMethod": "Обновить способ оплаты","contactOwnerTitle": "Обратитесь к владельцу рабочего пространства",- "contactOwnerDescription": "Только владелец рабочего пространства может изменить его оплату."+ "contactOwnerDescription": "Только владелец рабочего пространства может изменить его оплату.",+ "manageInAppStore": "Управлять в App Store",+ "manageInGooglePlay": "Управлять в Google Play",+ "managedInMobileStore": "Оплата через магазин приложений на телефоне. Управляйте подпиской с телефона."},"checkout": {"couldNotOpenDescription": "Не удалось открыть страницу оформления. Попробуйте ещё раз.",@@ -1599,7 +1602,9 @@"nextBilling": "Следующее списание: {{date}}","pastDue": "{{used}} / {{limit}} бесплатных слов на этой неделе — обновите платёж для восстановления Pro","trial": "Осталось {{days}} дней — безлимитные транскрипции",- "unlimited": "Без ограничений"+ "unlimited": "Без ограничений",+ "accessUntil": "Доступ до {{date}}",+ "storePaymentIssue": "Магазин приложений не смог продлить эту подписку. Обновите там способ оплаты, чтобы сохранить тариф."},"planLabels": {"free": "Бесплатный",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 48bdb296f..cd74d7741 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -1571,7 +1571,10 @@"opening": "正在打开...","updatePaymentMethod": "更新支付方式","contactOwnerTitle": "请联系工作区所有者",- "contactOwnerDescription": "只有工作区所有者才能更新该工作区的账单。"+ "contactOwnerDescription": "只有工作区所有者才能更新该工作区的账单。",+ "manageInAppStore": "在 App Store 中管理",+ "manageInGooglePlay": "在 Google Play 中管理",+ "managedInMobileStore": "通过手机应用商店计费。请在手机上管理订阅。"},"checkout": {"couldNotOpenDescription": "打开结账页面时出错,请重试。",@@ -1595,7 +1598,9 @@"nextBilling": "下次扣费:{{date}}","pastDue": "本周 {{used}} / {{limit}} 免费词数——更新支付方式以恢复 Pro","trial": "剩余 {{days}} 天——无限转录",- "unlimited": "无限制"+ "unlimited": "无限制",+ "accessUntil": "可使用至 {{date}}",+ "storePaymentIssue": "应用商店未能续订此订阅。请在应用商店中更新付款方式以继续使用当前套餐。"},"planLabels": {"free": "免费版",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 7c3e6441c..300120a9e 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -1571,7 +1571,10 @@"opening": "開啟中...","updatePaymentMethod": "更新付款方式","contactOwnerTitle": "請聯絡工作區擁有者",- "contactOwnerDescription": "只有工作區擁有者才能更新該工作區的帳單。"+ "contactOwnerDescription": "只有工作區擁有者才能更新該工作區的帳單。",+ "manageInAppStore": "在 App Store 中管理",+ "manageInGooglePlay": "在 Google Play 中管理",+ "managedInMobileStore": "透過手機的應用程式商店計費。請在手機上管理訂閱。"},"checkout": {"couldNotOpenDescription": "開啟結帳頁面時發生問題。請再試一次。",@@ -1595,7 +1598,9 @@"nextBilling": "下次扣款日:{{date}}","pastDue": "本週 {{used}} / {{limit}} 免費字數——更新付款方式以恢復 Pro","trial": "剩餘 {{days}} 天——無限轉錄",- "unlimited": "無限"+ "unlimited": "無限",+ "accessUntil": "可使用至 {{date}}",+ "storePaymentIssue": "應用程式商店無法續訂此訂閱。請在商店中更新付款方式以繼續使用目前方案。"},"planLabels": {"free": "免費",diff --git a/test/lib/upsell.test.js b/test/lib/upsell.test.jsindex 82402f7b0..188db29e7 100644--- a/test/lib/upsell.test.js+++ b/test/lib/upsell.test.js@@ -1,7 +1,12 @@const test = require("node:test");const assert = require("node:assert/strict");-const { decideUpsell, decideProPlanCardCta } = require("../../src/lib/upsell.ts");+const {+ decideUpsell,+ decideProPlanCardCta,+ resolveAccountPlan,+ storeSubscriptionsUrl,+} = require("../../src/lib/upsell.ts");test("the upgrade CTA survives sign-out and is withheld while entitlement is unknown", () => {const decide = (overrides) =>@@ -27,6 +32,7 @@ test("a workspace-covered member is never offered a personal Pro checkout", () =isSignedIn: true,planStateKnown: true,isPersonallySubscribed: false,+ isStoreBilled: false,plan: "free",isTrial: false,isWorkspaceCovered: false,@@ -45,6 +51,7 @@ test("a personal subscription keeps its manage and switch paths (double-payer)",isSignedIn: true,planStateKnown: true,isPersonallySubscribed: true,+ isStoreBilled: false,plan: "pro",isTrial: false,isWorkspaceCovered: false,@@ -57,6 +64,7 @@ test("a personal subscription keeps its manage and switch paths (double-payer)",isSignedIn: true,planStateKnown: true,isPersonallySubscribed: true,+ isStoreBilled: false,plan: "business",isTrial: false,isWorkspaceCovered: false,@@ -71,6 +79,7 @@ test("no checkout renders while the entitlement is unknown", () => {isSignedIn: true,planStateKnown: false,isPersonallySubscribed: false,+ isStoreBilled: false,plan: "free",isTrial: false,isWorkspaceCovered: false,@@ -85,6 +94,7 @@ test("trial reads as the current plan, not an upsell target", () => {isSignedIn: true,planStateKnown: true,isPersonallySubscribed: false,+ isStoreBilled: false,plan: "free",isTrial: true,isWorkspaceCovered: false,@@ -99,6 +109,7 @@ test("a signed-out user is routed to onboarding, not a checkout", () => {isSignedIn: false,planStateKnown: true,isPersonallySubscribed: false,+ isStoreBilled: false,plan: "free",isTrial: false,isWorkspaceCovered: false,@@ -106,3 +117,143 @@ test("a signed-out user is routed to onboarding, not a checkout", () => {"signUp");});++test("a mobile-app subscriber is never offered a Stripe checkout or switch (#2535)", () => {+ const decide = (o) =>+ decideProPlanCardCta({+ isSignedIn: true,+ planStateKnown: true,+ isPersonallySubscribed: false,+ isStoreBilled: true,+ plan: "pro",+ isTrial: false,+ isWorkspaceCovered: false,+ ...o,+ });+ assert.equal(decide({}), "currentPlan");+ assert.equal(decide({ isTrial: true }), "currentPlan");+ // Stripe's switch-plan can't move a store subscription to Pro.+ assert.equal(decide({ plan: "business" }), "none");+ // A workspace seat outranks the store plan, as in the account row.+ assert.equal(decide({ isWorkspaceCovered: true }), "coveredByWorkspace");+ assert.equal(decide({ isWorkspaceCovered: true, plan: "business" }), "coveredByWorkspace");+});++const resolve = (o) =>+ resolveAccountPlan({+ isTrial: false,+ isPastDue: false,+ isPersonallySubscribed: false,+ storeBilling: null,+ isWorkspaceCovered: false,+ hasPeriodEnd: true,+ hasCoveringWorkspaceNames: false,+ ...o,+ });+const appStore = (status = "active") => ({ store: "app_store", status });++test("the account row shows a mobile-app plan and sends billing to the store (#2535)", () => {+ assert.deepEqual(resolve({ storeBilling: appStore() }), {+ row: "store",+ description: "nextBilling",+ action: "manageInStore",+ });+ assert.deepEqual(resolve({ storeBilling: appStore("past_due") }), {+ row: "store",+ description: "storePaymentIssue",+ action: "manageInStore",+ });+ // Still entitled until the paid period ends, but it won't renew.+ assert.deepEqual(resolve({ storeBilling: appStore("canceled") }), {+ row: "store",+ description: "accessUntil",+ action: "manageInStore",+ });+ // A non-expiring purchase has no period end.+ assert.deepEqual(resolve({ storeBilling: appStore(), hasPeriodEnd: false }), {+ row: "store",+ description: "unlimited",+ action: "manageInStore",+ });+ // A store trial is still a trial, but upgrading through Stripe would bill twice.+ assert.deepEqual(resolve({ isTrial: true, storeBilling: appStore("trialing") }), {+ row: "trial",+ description: "trial",+ action: "manageInStore",+ });+ // An API that doesn't name the store gets a note, never a guessed link.+ assert.deepEqual(resolve({ storeBilling: { store: null, status: "active" } }), {+ row: "store",+ description: "nextBilling",+ action: "storeNote",+ });+});++test("a workspace seat outranks a store plan in the row, but the store keeps the button", () => {+ assert.deepEqual(+ resolve({+ storeBilling: appStore(),+ isWorkspaceCovered: true,+ hasCoveringWorkspaceNames: true,+ }),+ { row: "workspaceOrFree", description: "providedBy", action: "manageInStore" }+ );+ // Before the workspace store loads there are no names to show yet.+ assert.deepEqual(resolve({ storeBilling: appStore("past_due"), isWorkspaceCovered: true }), {+ row: "workspaceOrFree",+ description: "unlimited",+ action: "manageInStore",+ });+});++test("the account row keeps its existing Stripe, workspace and free paths", () => {+ assert.deepEqual(resolve({ isPersonallySubscribed: true }), {+ row: "personal",+ description: "nextBilling",+ action: "manageBilling",+ });+ assert.deepEqual(resolve({ isPersonallySubscribed: true, hasPeriodEnd: false }), {+ row: "personal",+ description: "unlimited",+ action: "manageBilling",+ });+ assert.deepEqual(resolve({ isPersonallySubscribed: true, isTrial: true }), {+ row: "trial",+ description: "trial",+ action: "upgrade",+ });+ assert.deepEqual(resolve({ isPastDue: true }), {+ row: "pastDue",+ description: "pastDue",+ action: "updatePayment",+ });+ // A trial outranks past due in the row; the recovery button still shows.+ assert.deepEqual(resolve({ isTrial: true, isPastDue: true }), {+ row: "trial",+ description: "trial",+ action: "updatePayment",+ });+ assert.deepEqual(resolve({ isWorkspaceCovered: true, hasCoveringWorkspaceNames: true }), {+ row: "workspaceOrFree",+ description: "providedBy",+ action: "none",+ });+ assert.deepEqual(resolve({ isWorkspaceCovered: true }), {+ row: "workspaceOrFree",+ description: "unlimited",+ action: "none",+ });+ assert.deepEqual(resolve({}), {+ row: "workspaceOrFree",+ description: "freeUsage",+ action: "upgrade",+ });+});++test("each store links to its own subscriptions page", () => {+ assert.equal(storeSubscriptionsUrl("app_store"), "https://apps.apple.com/account/subscriptions");+ assert.equal(+ storeSubscriptionsUrl("play_store"),+ "https://play.google.com/store/account/subscriptions"+ );+});diff --git a/test/lib/usageStore.test.js b/test/lib/usageStore.test.jsindex 97a287592..280a6827e 100644--- a/test/lib/usageStore.test.js+++ b/test/lib/usageStore.test.js@@ -17,6 +17,7 @@ global.window = {const {getUsageState,isPastDueUsage,+ storeBillingOf,loadUsage,normalizeUsage,retryUsage,@@ -45,7 +46,12 @@ const flush = () => new Promise((resolve) => setImmediate(resolve));test("an old response shape still resolves a personal entitlement", () => {const legacy = normalizeUsage({ plan: "business", status: "active", isSubscribed: true });- assert.deepEqual(legacy.entitlementSources, { personal: true, workspaceIds: [] });+ assert.deepEqual(legacy.entitlementSources, {+ personal: true,+ provider: false,+ providerStore: null,+ workspaceIds: [],+ });assert.equal(legacy.isSubscribed, true);const trial = normalizeUsage({ plan: "free", status: "active", isTrial: true });@@ -70,7 +76,76 @@ test("an explicit entitlementSources block wins over the inferred one", () => {isSubscribed: true,entitlementSources: { personal: false, workspaceIds: ["ws-1"] },});- assert.deepEqual(migrated.entitlementSources, { personal: false, workspaceIds: ["ws-1"] });+ assert.deepEqual(migrated.entitlementSources, {+ personal: false,+ provider: false,+ providerStore: null,+ workspaceIds: ["ws-1"],+ });+});++const appStoreUsage = (overrides = {}) =>+ normalizeUsage({+ plan: "pro",+ status: "active",+ isSubscribed: true,+ entitlementSources: {+ personal: false,+ provider: true,+ providerStore: "app_store",+ workspaceIds: [],+ },+ ...overrides,+ });++test("a plan bought in the mobile app is store-billed, not free (#2535)", () => {+ assert.deepEqual(storeBillingOf(appStoreUsage()), { store: "app_store", status: "active" });+ assert.deepEqual(storeBillingOf(appStoreUsage({ status: "canceled" })), {+ store: "app_store",+ status: "canceled",+ });+});++test("an API without providerStore still reports store billing, with the store unknown", () => {+ const usage = normalizeUsage({+ plan: "pro",+ status: "active",+ isSubscribed: true,+ entitlementSources: { personal: false, provider: true, workspaceIds: [] },+ });+ assert.deepEqual(storeBillingOf(usage), { store: null, status: "active" });+ // An unrecognised store is not linked to either store's page.+ const other = appStoreUsage({+ entitlementSources: {+ personal: false,+ provider: true,+ providerStore: "superwall",+ workspaceIds: [],+ },+ });+ assert.equal(storeBillingOf(other).store, null);+});++test("a Stripe subscription outranks a store one, matching the plan the API reports", () => {+ const both = normalizeUsage({+ plan: "pro",+ status: "active",+ isSubscribed: true,+ entitlementSources: {+ personal: true,+ provider: true,+ providerStore: "app_store",+ workspaceIds: [],+ },+ });+ assert.equal(storeBillingOf(both), null);+ assert.equal(storeBillingOf(normalizeUsage({ plan: "pro", status: "active" })), null);+});++test("a store billing retry is not a Stripe past due", () => {+ // The store runs its own retry; the Stripe recovery banner would open a+ // portal with no subscription in it.+ assert.equal(isPastDueUsage(appStoreUsage({ status: "past_due" })), false);});test("past due is only derived from a paid plan", () => {