feat(billing): let people try the product before handing over a card

The trial now starts inside the product, at email verification, and Stripe
grants none at all: checkout creates a subscription that bills immediately.
Verifying an address is what buys the seven days, which is also the cheapest
abuse control there is.

An unexpired trial is treated as an entitlement the account already holds, so a
Stripe sync can add access but never retracts a trial that has not run out. That
matters most for the abandoned checkout: the resulting incomplete subscription
carries no trial_end, and writing it through would have erased the days the
account still had and locked it out.

Unpaid accounts are bounded by what they can cost us rather than by what they
can do: one workspace, one project, 3 GiB of direct uploads. YouTube imports,
share links, guests, comments and approvals stay unlimited, because those are
the parts worth trying and they cost nothing. isPaidTier() is the new seam;
hasBillingAccess() answers a different question now that access no longer
implies a card.

Signup CTAs, the pricing card, the comparison pages, the terms and the refund
policy all said the trial converts to a paid plan by itself. It no longer does,
so they say what happens instead. Settings and a banner name both dates that
matter: when the trial ends, and the fifteen days after that during which
nothing is deleted.

/admin/growth compares the two funnels on signup to paid within a fixed 30 day
window, not trial to paid. Dropping the card requirement multiplies trials, so
the old ratio can fall while more people actually pay, and reading it that way
would retire the change for the wrong reason.
This commit is contained in:
yusufipk
2026-08-05 19:40:36 +03:00
parent b8d68a9196
commit 39e81042bb
34 changed files with 1541 additions and 134 deletions
+21 -2
View File
@@ -21,6 +21,7 @@ import {
addWorkspaceMember,
createExpiredUser,
createProject,
createSubscribedUser,
createUser,
createVideo,
createWorkspace,
@@ -145,8 +146,10 @@ describe('POST /api/workspaces', () => {
expect(stored.ownerId).toBe(user.id);
});
// Subscribed rather than the default trial user: three workspaces is past the
// trial's ceiling, and this test is about slugs, not about billing.
it('gives same-named workspaces distinct slugs', async () => {
const user = await createUser();
const user = await createSubscribedUser();
signedInAs(user);
for (let index = 0; index < 3; index += 1) {
@@ -221,8 +224,10 @@ describe('POST /api/workspaces', () => {
expect(await db.workspace.count()).toBe(1);
});
// The name has always promised a subscriber; it used to be handed a trial user,
// which passed only because nothing distinguished the two.
it('lets a subscribed user create any number of workspaces', async () => {
const user = await createUser();
const user = await createSubscribedUser();
await createWorkspace({ ownerId: user.id });
await createWorkspace({ ownerId: user.id });
signedInAs(user);
@@ -236,6 +241,20 @@ describe('POST /api/workspaces', () => {
expect(await db.workspace.count()).toBe(3);
});
it('refuses a second workspace while the owner is on a free trial', async () => {
const user = await createUser();
await createWorkspace({ ownerId: user.id });
signedInAs(user);
const response = await callRoute(
createWorkspaceRoute,
apiRequest('/api/workspaces', { body: { name: 'Second' } })
);
expect(response.status).toBe(403);
expect(await db.workspace.count()).toBe(1);
});
it('lets a self-hosted instance with billing disabled create freely', async () => {
vi.stubEnv('OPENFRAME_ENABLE_STRIPE', 'false');
const expired = await createExpiredUser();