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
+53 -1
View File
@@ -14,6 +14,7 @@ import {
addWorkspaceMember,
createExpiredUser,
createProject,
createSubscribedUser,
createUser,
createVideo,
createWorkspace,
@@ -338,8 +339,10 @@ describe('POST /api/projects', () => {
expect(stored.allowDownloads).toBe(false);
});
// Subscribed rather than the default trial user: three projects is past the
// trial's ceiling, and this test is about slugs, not about billing.
it('gives two projects with the same name distinct slugs', async () => {
const owner = await createUser();
const owner = await createSubscribedUser();
const workspace = await createWorkspace({ ownerId: owner.id });
signedInAs(owner);
@@ -355,6 +358,55 @@ describe('POST /api/projects', () => {
expect(slugs.sort()).toEqual(['same-name', 'same-name-1', 'same-name-2']);
});
it('refuses a second project while the owner is on a free trial', async () => {
const owner = await createUser();
const workspace = await createWorkspace({ ownerId: owner.id });
await createProject({ ownerId: owner.id, workspaceId: workspace.id, name: 'First' });
signedInAs(owner);
const response = await callRoute(
createProjectRoute,
apiRequest('/api/projects', { body: { name: 'Second', workspaceId: workspace.id } })
);
expect(response.status).toBe(403);
expect(await db.project.count()).toBe(1);
});
it('lets a paying owner past that ceiling', async () => {
const owner = await createSubscribedUser();
const workspace = await createWorkspace({ ownerId: owner.id });
await createProject({ ownerId: owner.id, workspaceId: workspace.id, name: 'First' });
signedInAs(owner);
const response = await callRoute(
createProjectRoute,
apiRequest('/api/projects', { body: { name: 'Second', workspaceId: workspace.id } })
);
expect(response.status).toBe(201);
expect(await db.project.count()).toBe(2);
});
// The ceiling belongs to the account being billed, so a workspace admin cannot
// spend somebody else's trial allowance either.
it('counts the ceiling against the workspace owner, not the caller', async () => {
const owner = await createUser();
const workspace = await createWorkspace({ ownerId: owner.id });
await createProject({ ownerId: owner.id, workspaceId: workspace.id, name: 'First' });
const admin = await createUser();
await addWorkspaceMember({ workspaceId: workspace.id, userId: admin.id, role: 'ADMIN' });
signedInAs(admin);
const response = await callRoute(
createProjectRoute,
apiRequest('/api/projects', { body: { name: 'Second', workspaceId: workspace.id } })
);
expect(response.status).toBe(403);
expect(await db.project.count()).toBe(1);
});
it('honours an explicit PUBLIC visibility', async () => {
const owner = await createUser();
const workspace = await createWorkspace({ ownerId: owner.id });