mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-24 08:57:25 +00:00
feat(license): replace local auto-trial with Lemon Squeezy hosted trial flow (#755)
Fresh installs land on the Community tier. The 14-day Admiral trial is now issued by Lemon Squeezy via their hosted checkout: the user enters email + card, receives a license key by email, and pastes it into the existing Settings > License activation field. Backend changes: - LicenseService.initialize() no longer auto-creates a license_status='trial' row on first boot. It now only ensures an instance_id exists and starts periodic validation. - Drop the TRIAL_DURATION_DAYS constant. - Drop the status='trial' early-return in getVariant() so LS-issued trials resolve through the normal variant metadata path (variant_name / product_name). - Trial branches in getTier() and getLicenseInfo() are retained for future work that may detect trial state from Lemon Squeezy metadata; they are currently unreachable via the Sencho code paths. Frontend changes: - Settings > License surfaces a new "Try Admiral free for 14 days" CTA block with Start monthly trial and Start annual trial buttons that open Lemon Squeezy hosted checkout. The CTA is visible only when the user has no paid access and is not already on a trial. - Reserve the Admiral upgrade card for the Skipper-active upgrade path so unlicensed users see one Admiral path (the trial CTA) instead of two. - Pull the inline Lemon Squeezy checkout URLs into named module constants so the Skipper, Admiral monthly, and Admiral annual endpoints are defined in one place. Test changes: - license-service.test.ts covers the no-auto-trial startup path and updates the trial-variant test to reflect the metadata-driven resolution. - afterAll in the initialize() describe block calls destroy() so the 72-hour validation interval does not leak into sibling test files. Docs: - Rewrite the Free trial section in features/licensing.mdx to document the new LS checkout flow (email + card required, auto-converts on day 14 unless cancelled). - Add an operations/troubleshooting entry for cases where the trial license key email does not arrive.
This commit is contained in:
@@ -12,8 +12,16 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { apiFetch } from '@/lib/api';
|
||||
|
||||
// Lemon Squeezy hosted checkout URLs. Admiral monthly and annual include a built-in
|
||||
// 14-day trial (email + card required on LS checkout); users receive a license key
|
||||
// by email and paste it into the activate input below.
|
||||
const SKIPPER_CHECKOUT_URL = 'https://saelix.lemonsqueezy.com/checkout/buy/f75bfb65-443a-46a0-abb1-981e0ff4b382';
|
||||
const ADMIRAL_MONTHLY_CHECKOUT_URL = 'https://saelix.lemonsqueezy.com/checkout/buy/b049b824-176a-408d-a9d3-9365c979a61f';
|
||||
const ADMIRAL_ANNUAL_CHECKOUT_URL = 'https://saelix.lemonsqueezy.com/checkout/buy/3e595568-92d3-4edd-90f1-25650248dfa9';
|
||||
|
||||
function getTierDisplayName(tier?: string, variant?: string | null, status?: string): string {
|
||||
if (tier === 'paid' && variant === 'admiral' && status === 'active') return 'Sencho Admiral';
|
||||
if (tier === 'paid' && variant === 'admiral' && status === 'trial') return 'Sencho Admiral (Trial)';
|
||||
if (tier === 'paid') return 'Sencho Skipper';
|
||||
return 'Sencho Community';
|
||||
}
|
||||
@@ -44,7 +52,11 @@ export function LicenseSection() {
|
||||
|
||||
const isAdmiral = isPaid && license?.variant === 'admiral' && license?.status === 'active';
|
||||
const showSkipperCard = !isPaid || license?.status === 'trial';
|
||||
const showUpgradeCards = !isAdmiral && (showSkipperCard || (license?.variant === 'skipper' && license?.status === 'active'));
|
||||
// Trial CTA owns the Admiral path for unlicensed users; the Admiral upgrade card is reserved for the
|
||||
// Skipper-active upgrade path. Otherwise both would link to the same LS checkout for community users.
|
||||
const showTrialCta = license?.status !== 'active' && license?.status !== 'trial';
|
||||
const showAdmiralUpgradeCard = !isAdmiral && !showTrialCta;
|
||||
const showUpgradeCards = showSkipperCard || showAdmiralUpgradeCard;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -162,12 +174,42 @@ export function LicenseSection() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Upgrade Cards: show for community, trial, or active Skipper users */}
|
||||
{showTrialCta && (
|
||||
<div className="border border-glass-border rounded-lg p-4 space-y-3 bg-glass">
|
||||
<div className="flex items-center gap-2">
|
||||
<ShipWheel className="w-4 h-4 text-blue-500" />
|
||||
<span className="font-medium text-sm">Try Admiral free for 14 days</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Admiral unlocks Host Console, Scheduled Operations, LDAP / Active Directory, audit log, API tokens, and unlimited accounts. Starting a trial opens Lemon Squeezy checkout, which requires a card for verification; you can cancel any time before day 14.
|
||||
</p>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => window.open(ADMIRAL_MONTHLY_CHECKOUT_URL, '_blank')}
|
||||
>
|
||||
Start monthly trial
|
||||
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => window.open(ADMIRAL_ANNUAL_CHECKOUT_URL, '_blank')}
|
||||
>
|
||||
Start annual trial
|
||||
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-[11px] text-muted-foreground">
|
||||
After checkout, paste the license key from your email into the activate field below.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showUpgradeCards && (
|
||||
<div className="space-y-3">
|
||||
<Label className="text-base">Upgrade your plan</Label>
|
||||
<div className={`grid gap-3 ${showSkipperCard ? 'grid-cols-1 sm:grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{/* Skipper Card - only for Community users and trial users */}
|
||||
<div className={`grid gap-3 ${showSkipperCard && showAdmiralUpgradeCard ? 'grid-cols-1 sm:grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{showSkipperCard && (
|
||||
<div className="relative border border-glass-border rounded-lg p-4 space-y-3 bg-glass flex flex-col">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -187,7 +229,7 @@ export function LicenseSection() {
|
||||
<Button
|
||||
size="sm"
|
||||
className="w-full mt-auto"
|
||||
onClick={() => window.open('https://saelix.lemonsqueezy.com/checkout/buy/f75bfb65-443a-46a0-abb1-981e0ff4b382', '_blank')}
|
||||
onClick={() => window.open(SKIPPER_CHECKOUT_URL, '_blank')}
|
||||
>
|
||||
<Zap className="w-4 h-4 mr-2" />
|
||||
Get Skipper
|
||||
@@ -196,39 +238,40 @@ export function LicenseSection() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Admiral Card */}
|
||||
<div className="border border-glass-border rounded-lg p-4 space-y-3 bg-glass flex flex-col">
|
||||
<div className="flex items-center gap-2">
|
||||
<ShipWheel className="w-4 h-4 text-blue-500" />
|
||||
<span className="font-medium text-sm">Admiral</span>
|
||||
{showAdmiralUpgradeCard && (
|
||||
<div className="border border-glass-border rounded-lg p-4 space-y-3 bg-glass flex flex-col">
|
||||
<div className="flex items-center gap-2">
|
||||
<ShipWheel className="w-4 h-4 text-blue-500" />
|
||||
<span className="font-medium text-sm">Admiral</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">For teams managing shared infrastructure.</p>
|
||||
<ul className="space-y-1.5">
|
||||
{[
|
||||
...(license?.variant === 'skipper' ? ['Everything in Skipper'] : ['Everything in Community']),
|
||||
'Unlimited accounts & scoped RBAC',
|
||||
...(license?.variant !== 'skipper' ? ['Fleet View, webhooks & labels', 'Atomic deployments & backups'] : []),
|
||||
'LDAP/AD, audit log & host console',
|
||||
'API tokens & private registries',
|
||||
'Scheduled operations',
|
||||
].map((f) => (
|
||||
<li key={f} className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<Check className="w-3 h-3 shrink-0 text-success" />
|
||||
{f}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={showSkipperCard ? 'outline' : 'default'}
|
||||
className="w-full mt-auto"
|
||||
onClick={() => window.open(ADMIRAL_MONTHLY_CHECKOUT_URL, '_blank')}
|
||||
>
|
||||
<Zap className="w-4 h-4 mr-2" />
|
||||
Get Admiral
|
||||
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">For teams managing shared infrastructure.</p>
|
||||
<ul className="space-y-1.5">
|
||||
{[
|
||||
...(license?.variant === 'skipper' ? ['Everything in Skipper'] : ['Everything in Community']),
|
||||
'Unlimited accounts & scoped RBAC',
|
||||
...(license?.variant !== 'skipper' ? ['Fleet View, webhooks & labels', 'Atomic deployments & backups'] : []),
|
||||
'LDAP/AD, audit log & host console',
|
||||
'API tokens & private registries',
|
||||
'Scheduled operations',
|
||||
].map((f) => (
|
||||
<li key={f} className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<Check className="w-3 h-3 shrink-0 text-success" />
|
||||
{f}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={showSkipperCard ? 'outline' : 'default'}
|
||||
className="w-full mt-auto"
|
||||
onClick={() => window.open('https://saelix.lemonsqueezy.com/checkout/buy/b049b824-176a-408d-a9d3-9365c979a61f', '_blank')}
|
||||
>
|
||||
<Zap className="w-4 h-4 mr-2" />
|
||||
Get Admiral
|
||||
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user