mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
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:
@@ -1,16 +1,20 @@
|
||||
import { Header } from '@/components/layout';
|
||||
import { Header, TrialBanner } from '@/components/layout';
|
||||
import { auth } from '@/lib/auth';
|
||||
import { hasAppNavigationAccess } from '@/lib/route-access';
|
||||
import { getTrialNotice } from '@/lib/billing';
|
||||
|
||||
export default async function DashboardLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await auth();
|
||||
const showAppNavigation = session?.user?.id
|
||||
? await hasAppNavigationAccess(session.user.id)
|
||||
: false;
|
||||
const userId = session?.user?.id;
|
||||
const [showAppNavigation, trialNotice] = await Promise.all([
|
||||
userId ? hasAppNavigationAccess(userId) : false,
|
||||
userId ? getTrialNotice(userId) : null,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className="relative flex min-h-screen flex-col">
|
||||
<Header user={session?.user ?? null} showAppNavigation={showAppNavigation} />
|
||||
{trialNotice ? <TrialBanner notice={trialNotice} /> : null}
|
||||
<main className="flex-1">{children}</main>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ interface BillingOverview {
|
||||
hasRecoverableSubscription: boolean;
|
||||
hasActiveTrial: boolean;
|
||||
hasBillingAccess: boolean;
|
||||
isTrialEligible: boolean;
|
||||
isPaid: boolean;
|
||||
priceId: string | null;
|
||||
currentPeriodEnd: string | null;
|
||||
cancelAtPeriodEnd: boolean;
|
||||
@@ -365,14 +365,17 @@ export default function SettingsPage({ billingOnly = false }: { billingOnly?: bo
|
||||
) : (
|
||||
<>
|
||||
{!billing.subscription.hasActiveSubscription &&
|
||||
!billing.subscription.hasActiveTrial &&
|
||||
billing.subscription.isTrialEligible &&
|
||||
billing.checkoutAvailable ? (
|
||||
billing.subscription.hasActiveTrial &&
|
||||
billing.subscription.trialEndsAt ? (
|
||||
<div className="rounded-md border border-primary/30 bg-primary/5 p-4 space-y-2">
|
||||
<p className="text-sm font-semibold">Start your 7-day free trial</p>
|
||||
<p className="text-sm font-semibold">
|
||||
Your free trial runs until{' '}
|
||||
{new Date(billing.subscription.trialEndsAt).toLocaleDateString()}
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Get full access to all features — no charge until the trial ends. Cancel
|
||||
anytime.
|
||||
Every feature is on and no card is on file. The trial covers one workspace and
|
||||
one project. Subscribing starts your paid month straight away, so there is no
|
||||
reason to do it before you are ready.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -388,10 +391,8 @@ export default function SettingsPage({ billingOnly = false }: { billingOnly?: bo
|
||||
: 'Subscription canceled. Access remains active until the end of the current billing period.'
|
||||
: 'Paid account with workspace creation unlocked.'
|
||||
: billing.subscription.hasActiveTrial
|
||||
? 'Trial access is active.'
|
||||
: billing.subscription.isTrialEligible
|
||||
? "You haven't started your free trial yet."
|
||||
: 'Billing access has ended.'}
|
||||
? 'Free trial, no card required.'
|
||||
: 'Billing access has ended.'}
|
||||
</p>
|
||||
</div>
|
||||
<Badge
|
||||
@@ -433,13 +434,15 @@ export default function SettingsPage({ billingOnly = false }: { billingOnly?: bo
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{/* Deliberately not conditioned on `billingAccessEndedAt`: an account that
|
||||
only ever had the cardless trial never gets one written, and it is exactly
|
||||
that account which most needs to be told its work is still recoverable. */}
|
||||
{!billing.subscription.hasBillingAccess &&
|
||||
billing.subscription.billingAccessEndedAt &&
|
||||
billing.subscription.storageCleanupEligibleAt ? (
|
||||
<p className="text-sm text-amber-700 dark:text-amber-400">
|
||||
Stored media cleanup is scheduled after{' '}
|
||||
{new Date(billing.subscription.storageCleanupEligibleAt).toLocaleDateString()}{' '}
|
||||
unless billing is restored first.
|
||||
Nothing has been deleted. Your projects and media are kept until{' '}
|
||||
{new Date(billing.subscription.storageCleanupEligibleAt).toLocaleDateString()};
|
||||
subscribe before then and everything is where you left it.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
@@ -479,8 +482,6 @@ export default function SettingsPage({ billingOnly = false }: { billingOnly?: bo
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
Redirecting...
|
||||
</>
|
||||
) : billing.subscription.isTrialEligible ? (
|
||||
'Start Free Trial'
|
||||
) : (
|
||||
'Upgrade with Stripe'
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user