#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Raise free monthly credits to 1,000 and show live allowances (#8028)
ConnorYoh77894c8eb740
diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkProperties.java b/app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkProperties.javaindex 996a6287b6..ca27d94920 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkProperties.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/accountlink/AccountLinkProperties.java@@ -38,7 +38,7 @@ public class AccountLinkProperties {* Units granted each month while unlinked. Matches the SaaS default policy, so linking raises* the allowance rather than introducing one. 0 means billable work needs a link.*/- private long freeTierUnits = 500;+ private long freeTierUnits = 1000;/** Phase 2 usage metering + daily sync. */private final Metering metering = new Metering();diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/EnterpriseProcessingHttpIntegrationTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/EnterpriseProcessingHttpIntegrationTest.javaindex 57b7dc4495..7bd6491887 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/EnterpriseProcessingHttpIntegrationTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/EnterpriseProcessingHttpIntegrationTest.java@@ -86,7 +86,7 @@ import stirling.software.proprietary.service.ua.PdfUaValidationService;})class EnterpriseProcessingHttpIntegrationTest {- private static final long SPENT_GRANT = 500;+ private static final long SPENT_GRANT = new AccountLinkProperties().getFreeTierUnits();private static final int PAGES = 26;private static final long PDF_UNITS = 2;private static final String BOUNDARY = "enterprise-processing-test";diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/FreeTierUsageServiceDbTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/FreeTierUsageServiceDbTest.javaindex 9814c472ff..8f113e44a1 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/FreeTierUsageServiceDbTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/accountlink/FreeTierUsageServiceDbTest.java@@ -42,16 +42,18 @@ class FreeTierUsageServiceDbTest {@Testvoid firstAccrualAnchorsThePeriodAndSpendsTheGrant() {- FreeTierUsageService service = service(500);+ FreeTierUsageService service =+ new FreeTierUsageService(+ periods, counters, signatures, new AccountLinkProperties(), now::get);service.accrue(BillingCategory.API, 30, null);FreeTierUsageService.FreeTierBalance balance = service.balance();assertThat(balance.periodStart()).isEqualTo(T0);assertThat(balance.periodEnd()).isEqualTo(T0.plusMonths(1));- assertThat(balance.grantUnits()).isEqualTo(500);+ assertThat(balance.grantUnits()).isEqualTo(1000);assertThat(balance.usedUnits()).isEqualTo(30);- assertThat(balance.remainingUnits()).isEqualTo(470);+ assertThat(balance.remainingUnits()).isEqualTo(970);}@Testdiff --git a/app/saas/src/main/java/stirling/software/saas/payg/api/PaygWalletController.java b/app/saas/src/main/java/stirling/software/saas/payg/api/PaygWalletController.javaindex 08ab0fcf70..203213dadd 100644--- a/app/saas/src/main/java/stirling/software/saas/payg/api/PaygWalletController.java+++ b/app/saas/src/main/java/stirling/software/saas/payg/api/PaygWalletController.java@@ -99,7 +99,7 @@ public class PaygWalletController {* membership — shouldn't happen post-migration). Teams always get the live {@code* pricing_policy.free_tier_units} grant via {@link TeamBillingService}.*/- private static final int FREE_TIER_LIMIT_UNITS_FALLBACK = 500;+ private static final int FREE_TIER_LIMIT_UNITS_FALLBACK = 1000;private static final DateTimeFormatter ISO_DATE = DateTimeFormatter.ISO_LOCAL_DATE;diff --git a/app/saas/src/test/java/stirling/software/saas/payg/api/PaygWalletControllerTest.java b/app/saas/src/test/java/stirling/software/saas/payg/api/PaygWalletControllerTest.javaindex cd9156ef07..4905cc18eb 100644--- a/app/saas/src/test/java/stirling/software/saas/payg/api/PaygWalletControllerTest.java+++ b/app/saas/src/test/java/stirling/software/saas/payg/api/PaygWalletControllerTest.java@@ -442,6 +442,8 @@ class PaygWalletControllerTest {assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK);assertThat(resp.getBody().status()).isEqualTo("free");+ assertThat(resp.getBody().freeAllowance()).isEqualTo(1000);+ assertThat(resp.getBody().freeRemaining()).isEqualTo(1000);assertThat(resp.getBody().members()).isEmpty();// Entitlement service must not be queried for a teamless user (avoids null-key NPE).verifyNoInteractions(entitlementService);diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.tomlindex a3ea9f036c..d544e94506 100644--- a/frontend/editor/public/locales/en-US/translation.toml+++ b/frontend/editor/public/locales/en-US/translation.toml@@ -6408,7 +6408,7 @@ noKey = "VITE_STRIPE_PUBLISHABLE_KEY is unset. Real iframe mounts here once conftitle = "Stripe Embedded Checkout (mock mode)"[payg.confirm]-body = "Your team can now run automation, AI, and API operations beyond your 500 free PDFs."+bodyWithAllowance = "Your team can now run automation, AI, and API operations beyond your {{limit}} free PDFs."capValue = "{{symbol}}{{amount}} / month"noCap = "No cap"note = "You can change your cap, cancel, or open the Stripe customer portal any time from this page."@@ -6435,7 +6435,7 @@ benefit3Body = "call any Stirling endpoint programmatically"benefit3Title = "API access"button = "Turn on Processor →"reassurance = "No minimum · Set a $0 cap to test · Cancel anytime"-subtitle = "Keep going past your 500 free PDFs with automation, AI, and the API. Set a monthly ceiling, so you stay in control."+subtitleWithAllowance = "Keep going past your {{limit}} free PDFs with automation, AI, and the API. Set a monthly ceiling, so you stay in control."title = "Turn on the Processor plan"[payg.free.editor]@@ -6513,7 +6513,7 @@ leader = "Team owner"member = "Member"[payg.signupRequired]-body = "Stirling PDF gives every signed-up account 500 free operations a month, enough to keep most workflows humming without paying a cent. You're currently using Stirling as a guest, which doesn't include billable tools like AI, automations, or hosted processing."+bodyMonthlyAllowance = "Stirling PDF gives every signed-up account a free monthly allowance for operations. You're currently using Stirling as a guest, which doesn't include billable tools like AI, automations, or hosted processing."cancel = "Not now"cta = "Sign up free"subtext = "Creating an account is free and takes a few seconds. No credit card required."@@ -6574,7 +6574,7 @@ apiBody = "programmatic access to any Stirling endpoint"apiTitle = "API calls"automationBody = "chained tools or scheduled runs that don't need clicks"automationTitle = "Automation pipelines"-footnote = "Manual tools (viewing, editing, merging, splitting, watermarking, compressing, manual OCR) are always free, even past 500. The distinction is the type of work, not where you click."+footnoteUnlimited = "Manual tools (viewing, editing, merging, splitting, watermarking, compressing, manual OCR) are always free, even after your included credits are used. The distinction is the type of work, not where you click."title = "What we count toward billing"[payg.upgrade.promise]@@ -7335,7 +7335,7 @@ start = "Connect Stirling account"step = "Step {{current}} of {{total}}"[portal.accountLink.connect.benefits]-creditsDetail = "500 free per month"+creditsDetailMonthly = "Free monthly allowance"creditsLabel = "Credits"processorDetail = "Pipelines, policies, sources and audit"processorLabel = "Processor"diff --git a/frontend/editor/src/cloud/components/shared/config/configSections/PaygFree.tsx b/frontend/editor/src/cloud/components/shared/config/configSections/PaygFree.tsxindex c6e25f9247..257738175b 100644--- a/frontend/editor/src/cloud/components/shared/config/configSections/PaygFree.tsx+++ b/frontend/editor/src/cloud/components/shared/config/configSections/PaygFree.tsx@@ -114,7 +114,7 @@ function ProcessorCard({ snap, isLeader, onTurnOn }: ProcessorCardProps) {</h3><p className="paygf-cta__subtitle">{t(- "payg.free.cta.subtitle",+ "payg.free.cta.subtitleWithAllowance","Keep going past your {{limit}} free PDFs with automation, AI, and the API. Set a monthly ceiling, so you stay in control.",{ limit: snap.billableLimit.toLocaleString() },)}@@ -219,6 +219,8 @@ function PaygFreeLeaderInner({ onUpgraded }: PaygFreeLeaderProps = {}) {const { wallet } = useWallet();const [upgradeOpen, setUpgradeOpen] = useState(false);+ if (!snap) return null;+return (<div className="payg"><Stack gap="md">@@ -263,6 +265,8 @@ function PaygFreeMemberInner() {const { t } = useTranslation();const snap = useFreeSnapshot();+ if (!snap) return null;+return (<div className="payg"><Stack gap="md">diff --git a/frontend/editor/src/cloud/components/shared/config/configSections/UpgradeModal.tsx b/frontend/editor/src/cloud/components/shared/config/configSections/UpgradeModal.tsxindex 87a0964c78..bc55e53cfc 100644--- a/frontend/editor/src/cloud/components/shared/config/configSections/UpgradeModal.tsx+++ b/frontend/editor/src/cloud/components/shared/config/configSections/UpgradeModal.tsx@@ -375,8 +375,8 @@ function CapStep({</ul><div style={{ marginTop: 8, fontStyle: "italic" }}>{t(- "payg.upgrade.help.footnote",- "Manual tools — viewing, editing, merging, splitting, signing, watermarking, compressing, manual OCR — are always free, even past 500. The distinction is the type of work, not where you click.",+ "payg.upgrade.help.footnoteUnlimited",+ "Manual tools — viewing, editing, merging, splitting, signing, watermarking, compressing, manual OCR — are always free, even after your included credits are used. The distinction is the type of work, not where you click.",)}</div></div>@@ -455,7 +455,7 @@ function ConfirmationStep({</h3><p className="upm-confirm__body">{t(- "payg.confirm.body",+ "payg.confirm.bodyWithAllowance","Your team can now process documents with automation, AI, and the API beyond your {{limit}} free PDFs.",{ limit: freeLimit.toLocaleString() },)}diff --git a/frontend/editor/src/cloud/components/shared/config/configSections/usageMeters.tsx b/frontend/editor/src/cloud/components/shared/config/configSections/usageMeters.tsxindex cf66712693..7347260bda 100644--- a/frontend/editor/src/cloud/components/shared/config/configSections/usageMeters.tsx+++ b/frontend/editor/src/cloud/components/shared/config/configSections/usageMeters.tsx@@ -25,11 +25,9 @@ export interface FreeSnapshot {}/**- * Derive the free-grant snapshot from a wallet. Null (not yet loaded) yields a- * zeroed view over the default 500 grant, the brief first-paint placeholder.+ * Derive usage from the wallet's current allowance and remaining balance.*/-export function freeSnapshotFromWallet(wallet: Wallet | null): FreeSnapshot {- if (!wallet) return { billableUsed: 0, billableLimit: 500 };+export function freeSnapshotFromWallet(wallet: Wallet): FreeSnapshot {return {billableUsed: Math.max(0, wallet.freeAllowance - wallet.freeRemaining),billableLimit: wallet.freeAllowance,@@ -37,16 +35,19 @@ export function freeSnapshotFromWallet(wallet: Wallet | null): FreeSnapshot {}/**- * Read the free-grant snapshot from the live wallet. Falls back to a zeroed- * view over the default grant until the wallet loads.+ * Returns null until the live wallet supplies the team's allowance.*/-export function useFreeSnapshot(): FreeSnapshot {+export function useFreeSnapshot(): FreeSnapshot | null {const { wallet } = useWallet();- return useMemo(() => freeSnapshotFromWallet(wallet), [wallet]);+ return useMemo(+ () => (wallet ? freeSnapshotFromWallet(wallet) : null),+ [wallet],+ );}-export function FreeMeterPanel({ snap }: { snap: FreeSnapshot }) {+export function FreeMeterPanel({ snap }: { snap: FreeSnapshot | null }) {const { t } = useTranslation();+ if (!snap) return null;const remaining = Math.max(0, snap.billableLimit - snap.billableUsed);const { state, pct } = remainingMeter(remaining, snap.billableLimit);const stateLabel =diff --git a/frontend/editor/src/portal/components/account-link/connect/ConnectBenefitsSlide.tsx b/frontend/editor/src/portal/components/account-link/connect/ConnectBenefitsSlide.tsxindex a0258f7802..95b122369b 100644--- a/frontend/editor/src/portal/components/account-link/connect/ConnectBenefitsSlide.tsx+++ b/frontend/editor/src/portal/components/account-link/connect/ConnectBenefitsSlide.tsx@@ -4,10 +4,6 @@ import "@portal/components/account-link/connect/connect.css";/*** Processor is one row naming its parts rather than four competing ones, and credits come last:* first, and the screen reads as a price list.- *- * <p>TODO(#7712): the credits row promises a monthly allowance the billing model does not grant —- * {@code freeGrantUnits} is a one-time lifetime pool — so either the grant becomes recurring or the- * copy drops "per month" before this reaches customers.*/export function ConnectBenefitsSlide() {const { t } = useTranslation();@@ -36,8 +32,8 @@ export function ConnectBenefitsSlide() {key: "credits",label: t("portal.accountLink.connect.benefits.creditsLabel", "Credits"),detail: t(- "portal.accountLink.connect.benefits.creditsDetail",- "500 free per month",+ "portal.accountLink.connect.benefits.creditsDetailMonthly",+ "Free monthly allowance",),},];diff --git a/frontend/editor/src/saas/components/SignupRequiredBootstrap.tsx b/frontend/editor/src/saas/components/SignupRequiredBootstrap.tsxindex 25f4187cfe..1dbe97801e 100644--- a/frontend/editor/src/saas/components/SignupRequiredBootstrap.tsx+++ b/frontend/editor/src/saas/components/SignupRequiredBootstrap.tsx@@ -11,7 +11,7 @@ import type { PaygSignupRequiredDetail } from "@app/services/paygErrorIntercepto* Bootstrap that listens for {@code payg:signupRequired} (dispatched by* the {@code apiClient} response interceptor when an anonymous user hits* a billable endpoint and the server returns {@code 401 SIGNUP_REQUIRED})- * and opens a Mantine modal explaining the free 500-op/month allowance+ * and opens a Mantine modal explaining the free monthly allowance* with a "Sign up free" CTA.** <h2>Why an event bus instead of direct render</h2>@@ -92,8 +92,8 @@ export default function SignupRequiredBootstrap() {<Stack gap="md"><Text>{t(- "payg.signupRequired.body",- "Stirling PDF gives every signed-up account 500 free operations a month, enough to keep most workflows humming without paying a cent. You're currently using Stirling as a guest, which doesn't include billable tools like AI, automations, or hosted processing.",+ "payg.signupRequired.bodyMonthlyAllowance",+ "Stirling PDF gives every signed-up account a free monthly allowance for operations. You're currently using Stirling as a guest, which doesn't include billable tools like AI, automations, or hosted processing.",)}</Text><Text size="sm" c="dimmed">diff --git a/frontend/editor/src/saas/components/shared/usageMeters.test.tsx b/frontend/editor/src/saas/components/shared/usageMeters.test.tsxnew file mode 100644index 0000000000..7dbb1b2cd7--- /dev/null+++ b/frontend/editor/src/saas/components/shared/usageMeters.test.tsx@@ -0,0 +1,67 @@+import { describe, expect, it, vi } from "vitest";+import { render, screen } from "@testing-library/react";+import { freeWallet } from "@app/billing/walletFixtures";++const useWalletMock = vi.hoisted(() => vi.fn());++vi.mock("@app/hooks/useWallet", () => ({+ useWallet: useWalletMock,+}));++vi.mock("react-i18next", () => ({+ useTranslation: () => ({+ t: (key: string, fallback?: string, values?: Record<string, unknown>) =>+ (fallback ?? key).replace(/\{\{(\w+)\}\}/g, (_, name) =>+ String(values?.[name] ?? ""),+ ),+ }),+}));++import {+ FreeMeterPanel,+ useFreeSnapshot,+} from "@app/components/shared/config/configSections/usageMeters";++function LiveMeter() {+ return <FreeMeterPanel snap={useFreeSnapshot()} />;+}++describe("live free allowance meter", () => {+ it("waits for the wallet and reflects allowance changes", () => {+ useWalletMock.mockReturnValue({ wallet: null });+ const { container, rerender } = render(<LiveMeter />);+ expect(container).toBeEmptyDOMElement();++ useWalletMock.mockReturnValue({+ wallet: { ...freeWallet, freeAllowance: 1700, freeRemaining: 1425 },+ });+ rerender(<LiveMeter />);+ expect(screen.getByText((1425).toLocaleString())).toBeInTheDocument();+ expect(+ screen.getByText(+ `of ${(1700).toLocaleString()} free PDFs left this month`,+ ),+ ).toBeInTheDocument();++ useWalletMock.mockReturnValue({+ wallet: { ...freeWallet, freeAllowance: 2300, freeRemaining: 2025 },+ });+ rerender(<LiveMeter />);+ expect(screen.getByText((2025).toLocaleString())).toBeInTheDocument();+ expect(+ screen.getByText(+ `of ${(2300).toLocaleString()} free PDFs left this month`,+ ),+ ).toBeInTheDocument();+ });++ it("preserves a real zero allowance", () => {+ useWalletMock.mockReturnValue({+ wallet: { ...freeWallet, freeAllowance: 0, freeRemaining: 0 },+ });+ render(<LiveMeter />);+ expect(+ screen.getByText("of 0 free PDFs left this month"),+ ).toBeInTheDocument();+ });+});diff --git a/frontend/editor/src/saas/hooks/walletDevPreview.ts b/frontend/editor/src/saas/hooks/walletDevPreview.tsindex 1104d6b36c..75201da07d 100644--- a/frontend/editor/src/saas/hooks/walletDevPreview.ts+++ b/frontend/editor/src/saas/hooks/walletDevPreview.ts@@ -53,13 +53,10 @@ function buildDevPreviewWallet(role: WalletRole): Wallet {billingPeriodStart: isoDay(periodStart),billingPeriodEnd: isoDay(periodEnd),billableUsed: 62,- billableLimit: subscribed ? 1250 : 500,+ billableLimit: subscribed ? 1250 : 1000,freeUserAllowance: 5,- freeAllowance: 500,- // One-time grant: a free team has used 62 of 500 (438 left); the dev- // subscribed team is shown with its grant fully spent (kept across the- // subscribe — it just no longer gates them).- freeRemaining: subscribed ? 0 : 438,+ freeAllowance: 1000,+ freeRemaining: subscribed ? 0 : 938,// Free teams also carry a rate now — the backend resolves it from the// default policy's USD Price so the upgrade-flow cap estimate ("≈ N paid// PDFs/month") can render before subscribing. Mirror that here.diff --git a/testing/compose/payg/saas-seed.sql b/testing/compose/payg/saas-seed.sqlindex d3dacdbfdd..df2e70eaca 100644--- a/testing/compose/payg/saas-seed.sql+++ b/testing/compose/payg/saas-seed.sql@@ -16,8 +16,8 @@-- NOTE: free_tier_units is supplied explicitly because the cucumber harness-- disables Flyway (see docker-compose-saas.yml). Hibernate's DDL emits NOT-- NULL without a SQL DEFAULT (the JPA field default `= 0L` is JVM-side only),--- so the column would otherwise reject this INSERT. 500 matches the launch--- free tier, now granted per billing period rather than once per team.+-- so the column would otherwise reject this INSERT. 1000 matches the default+-- free tier granted per billing period.-- (Named free_tier_units_per_cycle here until the rename in V19; the harness-- builds its schema from Hibernate, so the old name made the INSERT fail.)INSERT INTO stirling_pdf.pricing_policy (@@ -27,7 +27,7 @@ INSERT INTO stirling_pdf.pricing_policy ()SELECT'v1-cucumber', CURRENT_TIMESTAMP, 25, 5242880,- 1, 1000, 500, TRUE,+ 1, 1000, 1000, TRUE,'Cucumber test default policy', 'system',CURRENT_TIMESTAMPWHERE NOT EXISTS (