diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a506ea..f050535 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
## [Unreleased]
+## [0.8.0-alpha] - 2026-02-20
+
+### Added
+
+- **Renewal date and amount.** The dashboard and billing tab now show when your subscription renews and how much you'll be charged.
+- **Invoice preview when changing plans.** Before you switch plans, you can see exactly what your next invoice will be (including prorations).
+- **Pay now for open invoices.** Unpaid invoices show a clear "Pay now" button so you can settle them quickly.
+- **Enterprise contact.** The pricing page Enterprise plan now links to email us directly instead of checkout.
+- **Past due alert.** If your payment fails, a red banner appears with a link to update your payment method.
+- **Pageview usage bar.** Your billing card shows a color-coded bar so you can see at a glance how close you are to your limit (green, then amber, then red).
+
+### Changed
+
+- **Change plan flow.** Cleaner plan selector with Solo, Team, and Business options. Shows which plan you're on and a preview of your next invoice. If the preview can't be calculated, you'll see a friendly message instead of a blank screen.
+- **Billing tab layout.** Improved spacing, clearer headings, and better focus when using keyboard navigation.
+- **Pricing page layout.** Updated spacing and typography. Slider and billing toggle are more accessible.
+- **Billing Portal return.** After updating your payment method in Stripe's portal, you're taken back to the billing tab instead of the general settings page.
+
+### Fixed
+
+- **Theme toggle crash.** Fixed a crash that could occur when switching between light and dark mode on the pricing page and then opening organization settings.
+
## [0.7.0-alpha] - 2026-02-17
### Changed
@@ -82,7 +104,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
---
-[Unreleased]: https://github.com/ciphera-net/pulse/compare/v0.7.0-alpha...HEAD
+[Unreleased]: https://github.com/ciphera-net/pulse/compare/v0.8.0-alpha...HEAD
+[0.8.0-alpha]: https://github.com/ciphera-net/pulse/compare/v0.7.0-alpha...v0.8.0-alpha
[0.7.0-alpha]: https://github.com/ciphera-net/pulse/compare/v0.6.0-alpha...v0.7.0-alpha
[0.6.0-alpha]: https://github.com/ciphera-net/pulse/compare/v0.5.1-alpha...v0.6.0-alpha
[0.5.1-alpha]: https://github.com/ciphera-net/pulse/compare/v0.5.0-alpha...v0.5.1-alpha
diff --git a/app/page.tsx b/app/page.tsx
index 90eed1d..651227f 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -13,6 +13,7 @@ import { Button } from '@ciphera-net/ui'
import { BarChartIcon, LockIcon, ZapIcon, CheckCircleIcon, XIcon, GlobeIcon } from '@ciphera-net/ui'
import { toast } from '@ciphera-net/ui'
import { getAuthErrorMessage } from '@ciphera-net/ui'
+import { getSitesLimitForPlan } from '@/lib/plans'
function DashboardPreview() {
return (
@@ -337,10 +338,13 @@ export default function HomePage() {
Your Sites
Manage your analytics sites and view insights.
- {subscription?.plan_id === 'solo' && sites.length >= 1 ? (
+ {(() => {
+ const siteLimit = getSitesLimitForPlan(subscription?.plan_id)
+ const atLimit = siteLimit != null && sites.length >= siteLimit
+ return atLimit ? (
- Limit reached (1/1)
+ Limit reached ({sites.length}/{siteLimit})
@@ -348,7 +352,8 @@ export default function HomePage() {
- ) : (
+ ) : null
+ })() ?? (
Add New Site
@@ -385,15 +390,34 @@ export default function HomePage() {
return `${label} Plan`
})()}
- {(typeof subscription.sites_count === 'number' || (subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number')) && (
+ {(typeof subscription.sites_count === 'number' || (subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number') || (subscription.next_invoice_amount_due != null && subscription.next_invoice_currency && !subscription.cancel_at_period_end && (subscription.subscription_status === 'active' || subscription.subscription_status === 'trialing'))) && (
{typeof subscription.sites_count === 'number' && (
- Sites: {subscription.plan_id === 'solo' && subscription.sites_count > 0 ? `${subscription.sites_count}/1` : subscription.sites_count}
+ Sites: {(() => {
+ const limit = getSitesLimitForPlan(subscription.plan_id)
+ return limit != null && typeof subscription.sites_count === 'number' ? `${subscription.sites_count}/${limit}` : subscription.sites_count
+ })()}
)}
- {typeof subscription.sites_count === 'number' && subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number' && ' · '}
+ {typeof subscription.sites_count === 'number' && (subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number') && ' · '}
{subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number' && (
Pageviews: {subscription.pageview_usage.toLocaleString()}/{subscription.pageview_limit.toLocaleString()}
)}
+ {subscription.next_invoice_amount_due != null && subscription.next_invoice_currency && !subscription.cancel_at_period_end && (subscription.subscription_status === 'active' || subscription.subscription_status === 'trialing') && (
+
+ Renews {(() => {
+ const ts = subscription.next_invoice_period_end ?? subscription.current_period_end
+ const d = ts ? new Date(typeof ts === 'number' ? ts * 1000 : ts) : null
+ const dateStr = d && !Number.isNaN(d.getTime()) && d.getTime() !== 0
+ ? d.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })
+ : null
+ const amount = (subscription.next_invoice_amount_due / 100).toLocaleString('en-US', {
+ style: 'currency',
+ currency: subscription.next_invoice_currency.toUpperCase(),
+ })
+ return dateStr ? `${dateStr} for ${amount}` : amount
+ })()}
+
+ )}
)}
diff --git a/app/settings/page.tsx b/app/settings/page.tsx
index 030ef5c..012f348 100644
--- a/app/settings/page.tsx
+++ b/app/settings/page.tsx
@@ -1,6 +1,4 @@
-import { Suspense } from 'react'
import ProfileSettings from '@/components/settings/ProfileSettings'
-import CheckoutSuccessToast from '@/components/checkout/CheckoutSuccessToast'
export const metadata = {
title: 'Settings - Pulse',
@@ -10,9 +8,6 @@ export const metadata = {
export default function SettingsPage() {
return (
)
diff --git a/app/sites/new/page.tsx b/app/sites/new/page.tsx
index 8180b11..9d73e53 100644
--- a/app/sites/new/page.tsx
+++ b/app/sites/new/page.tsx
@@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation'
import Link from 'next/link'
import { createSite, listSites, getSite, type Site } from '@/lib/api/sites'
import { getSubscription } from '@/lib/api/billing'
+import { getSitesLimitForPlan } from '@/lib/plans'
import { trackSiteCreatedFromDashboard, trackSiteCreatedScriptCopied } from '@/lib/welcomeAnalytics'
import { toast } from '@ciphera-net/ui'
import { getAuthErrorMessage } from '@ciphera-net/ui'
@@ -57,9 +58,10 @@ export default function NewSitePage() {
getSubscription()
])
- if (subscription?.plan_id === 'solo' && sites.length >= 1) {
+ const siteLimit = subscription?.plan_id ? getSitesLimitForPlan(subscription.plan_id) : null
+ if (siteLimit != null && sites.length >= siteLimit) {
setAtLimit(true)
- toast.error('Solo plan limit reached (1 site). Please upgrade to add more sites.')
+ toast.error(`${subscription.plan_id} plan limit reached (${siteLimit} site${siteLimit === 1 ? '' : 's'}). Please upgrade to add more sites.`)
router.replace('/')
}
} catch (error) {
diff --git a/components/PricingSection.tsx b/components/PricingSection.tsx
index 04d8b1f..2624e72 100644
--- a/components/PricingSection.tsx
+++ b/components/PricingSection.tsx
@@ -219,10 +219,10 @@ export default function PricingSection() {
transition={{ duration: 0.5 }}
className="text-center mb-12"
>
-
+
Transparent Pricing
-
+
Scale with your traffic. No hidden fees.
@@ -232,11 +232,11 @@ export default function PricingSection() {
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.1 }}
- className="max-w-6xl mx-auto border border-neutral-200 dark:border-neutral-800 rounded-3xl bg-white/50 dark:bg-neutral-900/50 backdrop-blur-xl shadow-sm overflow-hidden mb-20"
+ className="max-w-6xl mx-auto border border-neutral-200 dark:border-neutral-800 rounded-2xl bg-white/50 dark:bg-neutral-900/50 backdrop-blur-xl shadow-sm overflow-hidden mb-20"
>
{/* Top Toolbar */}
-
+
10k
@@ -252,7 +252,9 @@ export default function PricingSection() {
step="1"
value={sliderIndex}
onChange={(e) => setSliderIndex(parseInt(e.target.value))}
- className="w-full h-2 bg-neutral-200 rounded-lg appearance-none cursor-pointer dark:bg-neutral-700 accent-brand-orange"
+ aria-label="Monthly pageview limit"
+ aria-valuetext={`${currentTraffic.label} pageviews per month`}
+ className="w-full h-2 bg-neutral-200 rounded-lg appearance-none cursor-pointer dark:bg-neutral-700 accent-brand-orange focus:outline-none focus:ring-2 focus:ring-brand-orange focus:ring-offset-2"
/>
@@ -260,10 +262,12 @@ export default function PricingSection() {
Get 1 month free with yearly
-
+
setIsYearly(false)}
- className={`min-w-[88px] px-4 py-2 rounded-lg text-sm font-medium transition-all ${
+ role="radio"
+ aria-checked={!isYearly}
+ className={`min-w-[88px] px-4 py-2 rounded-lg text-sm font-medium transition-all focus:outline-none focus:ring-2 focus:ring-brand-orange ${
!isYearly
? 'bg-white dark:bg-neutral-700 text-neutral-900 dark:text-white shadow-sm'
: 'text-neutral-500 hover:text-neutral-900 dark:hover:text-white'
@@ -273,7 +277,9 @@ export default function PricingSection() {
setIsYearly(true)}
- className={`min-w-[88px] px-4 py-2 rounded-lg text-sm font-medium transition-all ${
+ role="radio"
+ aria-checked={isYearly}
+ className={`min-w-[88px] px-4 py-2 rounded-lg text-sm font-medium transition-all focus:outline-none focus:ring-2 focus:ring-brand-orange ${
isYearly
? 'bg-white dark:bg-neutral-700 text-neutral-900 dark:text-white shadow-sm'
: 'text-neutral-500 hover:text-neutral-900 dark:hover:text-white'
@@ -292,7 +298,7 @@ export default function PricingSection() {
const isTeam = plan.id === 'team'
return (
-
+
{isTeam && (
<>
@@ -361,7 +367,7 @@ export default function PricingSection() {
})}
{/* Enterprise Section */}
-
+
Enterprise
For high volume sites and custom needs
@@ -370,9 +376,12 @@ export default function PricingSection() {
-
+
Contact us
-
+
{[
diff --git a/components/checkout/CheckoutSuccessToast.tsx b/components/checkout/CheckoutSuccessToast.tsx
deleted file mode 100644
index 4bd39ac..0000000
--- a/components/checkout/CheckoutSuccessToast.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-'use client'
-
-import { useEffect } from 'react'
-import { useSearchParams } from 'next/navigation'
-import { toast } from '@ciphera-net/ui'
-
-/**
- * Shows a success toast when redirected from Stripe Checkout with success=true,
- * then clears the query params from the URL.
- */
-export default function CheckoutSuccessToast() {
- const searchParams = useSearchParams()
-
- useEffect(() => {
- const success = searchParams.get('success')
- if (success === 'true') {
- toast.success('Thank you for subscribing! Your subscription is now active.')
- const url = new URL(window.location.href)
- url.searchParams.delete('success')
- url.searchParams.delete('session_id')
- window.history.replaceState({}, '', url.pathname + url.search)
- }
- }, [searchParams])
-
- return null
-}
diff --git a/components/settings/OrganizationSettings.tsx b/components/settings/OrganizationSettings.tsx
index 9a56c0f..0febe51 100644
--- a/components/settings/OrganizationSettings.tsx
+++ b/components/settings/OrganizationSettings.tsx
@@ -16,8 +16,8 @@ import {
OrganizationInvitation,
Organization
} from '@/lib/api/organization'
-import { getSubscription, createPortalSession, getInvoices, cancelSubscription, changePlan, createCheckoutSession, SubscriptionDetails, Invoice } from '@/lib/api/billing'
-import { TRAFFIC_TIERS, PLAN_ID_SOLO, getTierIndexForLimit, getLimitForTierIndex } from '@/lib/plans'
+import { getSubscription, createPortalSession, getInvoices, cancelSubscription, resumeSubscription, changePlan, previewInvoice, createCheckoutSession, SubscriptionDetails, Invoice, PreviewInvoiceResult } from '@/lib/api/billing'
+import { TRAFFIC_TIERS, PLAN_ID_SOLO, PLAN_ID_TEAM, PLAN_ID_BUSINESS, getTierIndexForLimit, getLimitForTierIndex, getSitesLimitForPlan } from '@/lib/plans'
import { getAuditLog, AuditLogEntry, GetAuditLogParams } from '@/lib/api/audit'
import { getNotificationSettings, updateNotificationSettings } from '@/lib/api/notification-settings'
import { toast } from '@ciphera-net/ui'
@@ -83,9 +83,13 @@ export default function OrganizationSettings() {
const [isRedirectingToPortal, setIsRedirectingToPortal] = useState(false)
const [cancelLoadingAction, setCancelLoadingAction] = useState<'period_end' | 'immediate' | null>(null)
const [showCancelPrompt, setShowCancelPrompt] = useState(false)
+ const [isResuming, setIsResuming] = useState(false)
const [showChangePlanModal, setShowChangePlanModal] = useState(false)
+ const [changePlanId, setChangePlanId] = useState(PLAN_ID_SOLO)
const [changePlanTierIndex, setChangePlanTierIndex] = useState(2)
const [changePlanYearly, setChangePlanYearly] = useState(false)
+ const [invoicePreview, setInvoicePreview] = useState(null)
+ const [isLoadingPreview, setIsLoadingPreview] = useState(false)
const [isChangingPlan, setIsChangingPlan] = useState(false)
const [invoices, setInvoices] = useState([])
const [isLoadingInvoices, setIsLoadingInvoices] = useState(false)
@@ -294,6 +298,25 @@ export default function OrganizationSettings() {
}
}, [activeTab, user?.role, handleTabChange])
+ const hasActiveSubscription = subscription?.subscription_status === 'active' || subscription?.subscription_status === 'trialing'
+
+ useEffect(() => {
+ if (!showChangePlanModal || !hasActiveSubscription) {
+ setInvoicePreview(null)
+ return
+ }
+ let cancelled = false
+ setIsLoadingPreview(true)
+ setInvoicePreview(null)
+ const interval = changePlanYearly ? 'year' : 'month'
+ const limit = getLimitForTierIndex(changePlanTierIndex)
+ previewInvoice({ plan_id: changePlanId, interval, limit })
+ .then((res) => { if (!cancelled) setInvoicePreview(res ?? null) })
+ .catch(() => { if (!cancelled) { setInvoicePreview(null) } })
+ .finally(() => { if (!cancelled) setIsLoadingPreview(false) })
+ return () => { cancelled = true }
+ }, [showChangePlanModal, hasActiveSubscription, changePlanId, changePlanTierIndex, changePlanYearly])
+
// If no org ID, we are in personal organization context, so don't show org settings
if (!currentOrgId) {
return (
@@ -328,30 +351,48 @@ export default function OrganizationSettings() {
}
}
+ const handleResumeSubscription = async () => {
+ setIsResuming(true)
+ try {
+ await resumeSubscription()
+ toast.success('Subscription will continue. Cancellation has been undone.')
+ loadSubscription()
+ } catch (error: any) {
+ toast.error(getAuthErrorMessage(error) || error.message || 'Failed to resume subscription')
+ } finally {
+ setIsResuming(false)
+ }
+ }
+
const openChangePlanModal = () => {
+ const currentPlan = subscription?.plan_id
+ if (currentPlan === PLAN_ID_TEAM || currentPlan === PLAN_ID_BUSINESS) {
+ setChangePlanId(currentPlan)
+ } else {
+ setChangePlanId(PLAN_ID_SOLO)
+ }
if (subscription?.pageview_limit != null && subscription.pageview_limit > 0) {
setChangePlanTierIndex(getTierIndexForLimit(subscription.pageview_limit))
} else {
setChangePlanTierIndex(2)
}
setChangePlanYearly(subscription?.billing_interval === 'year')
+ setInvoicePreview(null)
setShowChangePlanModal(true)
}
- const hasActiveSubscription = subscription?.subscription_status === 'active' || subscription?.subscription_status === 'trialing'
-
const handleChangePlanSubmit = async () => {
const interval = changePlanYearly ? 'year' : 'month'
const limit = getLimitForTierIndex(changePlanTierIndex)
setIsChangingPlan(true)
try {
if (hasActiveSubscription) {
- await changePlan({ plan_id: PLAN_ID_SOLO, interval, limit })
+ await changePlan({ plan_id: changePlanId, interval, limit })
toast.success('Plan updated. Changes may take a moment to reflect.')
setShowChangePlanModal(false)
loadSubscription()
} else {
- const { url } = await createCheckoutSession({ plan_id: PLAN_ID_SOLO, interval, limit })
+ const { url } = await createCheckoutSession({ plan_id: changePlanId, interval, limit })
if (url) window.location.href = url
else throw new Error('No checkout URL')
}
@@ -811,21 +852,55 @@ export default function OrganizationSettings() {
)}
+ {/* Past due notice */}
+ {subscription.subscription_status === 'past_due' && (
+
+
+
+ Payment past due
+
+
+ We couldn't charge your payment method. Please update your billing info to avoid service interruption.
+
+
+
+ Update payment method
+
+
+ )}
+
{/* Cancel-at-period-end notice */}
{subscription.cancel_at_period_end && (
-
-
- Your subscription will end on{' '}
-
- {(() => {
- const d = subscription.current_period_end ? new Date(subscription.current_period_end as string) : null
- return d && !Number.isNaN(d.getTime()) ? d.toLocaleDateString(undefined, { month: 'long', day: 'numeric', year: 'numeric' }) : '—'
- })()}
-
-
-
- You keep full access until then. Your data is retained for 30 days after. Use "Change plan" to resubscribe.
-
+
+
+
+ Your subscription will end on{' '}
+
+ {(() => {
+ const d = subscription.current_period_end ? new Date(subscription.current_period_end as string) : null
+ return d && !Number.isNaN(d.getTime()) ? d.toLocaleDateString(undefined, { month: 'long', day: 'numeric', year: 'numeric' }) : '—'
+ })()}
+
+
+
+ You keep full access until then. Your data is retained for 30 days after. Use "Change plan" to resubscribe.
+
+
+
+ Keep my subscription
+
)}
@@ -842,9 +917,11 @@ export default function OrganizationSettings() {
? 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300'
: subscription.subscription_status === 'trialing'
? 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300'
+ : subscription.subscription_status === 'past_due'
+ ? 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300'
: 'bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300'
}`}>
- {subscription.subscription_status === 'trialing' ? 'Trial' : (subscription.subscription_status || 'Free')}
+ {subscription.subscription_status === 'trialing' ? 'Trial' : subscription.subscription_status === 'past_due' ? 'Past Due' : (subscription.subscription_status || 'Free')}
{subscription.billing_interval && (
@@ -856,16 +933,33 @@ export default function OrganizationSettings() {
Change plan
+ {(subscription.business_name || (subscription.tax_ids && subscription.tax_ids.length > 0)) && (
+
+ {subscription.business_name && (
+
Billing for: {subscription.business_name}
+ )}
+ {subscription.tax_ids && subscription.tax_ids.length > 0 && (
+
+ Tax ID{subscription.tax_ids.length > 1 ? 's' : ''}:{' '}
+ {subscription.tax_ids.map((t) => {
+ const label = t.type === 'eu_vat' ? 'VAT' : t.type === 'us_ein' ? 'EIN' : t.type.replace(/_/g, ' ').toUpperCase()
+ return `${label} ${t.value}${t.country ? ` (${t.country})` : ''}`
+ }).join(', ')}
+
+ )}
+
+ )}
{/* Usage stats */}
-
+
Sites
{typeof subscription.sites_count === 'number'
- ? subscription.plan_id === 'solo'
- ? `${subscription.sites_count} / 1`
- : `${subscription.sites_count}`
+ ? (() => {
+ const limit = getSitesLimitForPlan(subscription.plan_id)
+ return limit != null ? `${subscription.sites_count} / ${limit}` : `${subscription.sites_count}`
+ })()
: '—'}
@@ -876,6 +970,22 @@ export default function OrganizationSettings() {
? `${subscription.pageview_usage.toLocaleString()} / ${subscription.pageview_limit.toLocaleString()}`
: '—'}
+ {subscription.pageview_limit > 0 && typeof subscription.pageview_usage === 'number' && (
+
+
= 1
+ ? 'bg-red-500'
+ : subscription.pageview_usage / subscription.pageview_limit >= 0.9
+ ? 'bg-red-400'
+ : subscription.pageview_usage / subscription.pageview_limit >= 0.8
+ ? 'bg-amber-400'
+ : 'bg-green-500'
+ }`}
+ style={{ width: `${Math.min(100, (subscription.pageview_usage / subscription.pageview_limit) * 100)}%` }}
+ />
+
+ )}
@@ -883,8 +993,18 @@ export default function OrganizationSettings() {
{(() => {
- const d = subscription.current_period_end ? new Date(subscription.current_period_end as string) : null
- return d && !Number.isNaN(d.getTime()) && d.getTime() !== 0 ? d.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' }) : '—'
+ const ts = subscription.next_invoice_period_end ?? subscription.current_period_end
+ const d = ts ? new Date(typeof ts === 'number' ? ts * 1000 : ts) : null
+ const dateStr = d && !Number.isNaN(d.getTime()) && d.getTime() !== 0
+ ? d.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })
+ : '—'
+ const amount = subscription.next_invoice_amount_due != null && subscription.next_invoice_currency
+ ? (subscription.next_invoice_amount_due / 100).toLocaleString('en-US', {
+ style: 'currency',
+ currency: subscription.next_invoice_currency.toUpperCase(),
+ })
+ : null
+ return amount && dateStr !== '—' ? `${dateStr} for ${amount}` : dateStr
})()}
@@ -904,7 +1024,7 @@ export default function OrganizationSettings() {
type="button"
onClick={handleManageSubscription}
disabled={isRedirectingToPortal}
- className="inline-flex items-center gap-1.5 text-sm text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors disabled:opacity-50"
+ className="inline-flex items-center gap-1.5 text-sm text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors disabled:opacity-50 focus:outline-none focus:ring-2 focus:ring-brand-orange focus:rounded"
>
Payment method & invoices
@@ -914,7 +1034,7 @@ export default function OrganizationSettings() {
setShowCancelPrompt(true)}
- className="inline-flex items-center gap-1.5 rounded-lg border border-neutral-200 dark:border-neutral-700 px-3.5 py-1.5 text-sm text-neutral-600 dark:text-neutral-400 hover:border-red-300 hover:text-red-600 dark:hover:border-red-800 dark:hover:text-red-400 transition-colors"
+ className="inline-flex items-center gap-1.5 rounded-xl border border-neutral-200 dark:border-neutral-700 px-3.5 py-1.5 text-sm text-neutral-600 dark:text-neutral-400 hover:border-red-300 hover:text-red-600 dark:hover:border-red-800 dark:hover:text-red-400 transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
>
Cancel subscription
@@ -923,7 +1043,7 @@ export default function OrganizationSettings() {
{/* Invoice History */}
-
Recent invoices
+
Recent invoices
{isLoadingInvoices ? (
@@ -1338,8 +1465,9 @@ export default function OrganizationSettings() {
setShowChangePlanModal(false)}
- className="text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-400"
+ className="text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-brand-orange rounded-lg p-1"
disabled={isChangingPlan}
+ aria-label="Close dialog"
>
@@ -1348,6 +1476,41 @@ export default function OrganizationSettings() {
Choose your pageview limit and billing interval. {hasActiveSubscription ? 'Your next invoice will reflect prorations.' : 'You’ll start a new subscription.'}
+
+
Plan
+
+ {([
+ { id: PLAN_ID_SOLO, name: 'Solo', sites: '1 site' },
+ { id: PLAN_ID_TEAM, name: 'Team', sites: 'Up to 5 sites' },
+ { id: PLAN_ID_BUSINESS, name: 'Business', sites: 'Up to 10 sites' },
+ ] as const).map((plan) => {
+ const isCurrentPlan = subscription?.plan_id === plan.id
+ const isSelected = changePlanId === plan.id
+ return (
+ setChangePlanId(plan.id)}
+ className={`relative p-3 rounded-xl border text-left transition-all focus:outline-none focus:ring-2 focus:ring-brand-orange ${
+ isSelected
+ ? 'border-brand-orange bg-brand-orange/5 dark:bg-brand-orange/10'
+ : 'border-neutral-200 dark:border-neutral-700 hover:border-neutral-300 dark:hover:border-neutral-600'
+ }`}
+ >
+
+ {plan.name}
+
+ {plan.sites}
+ {isCurrentPlan && (
+
+ Current
+
+ )}
+
+ )
+ })}
+
+
Pageviews per month
setChangePlanYearly(false)}
- className={`flex-1 py-2 text-sm font-medium rounded-md transition-colors ${!changePlanYearly ? 'bg-brand-orange text-white' : 'text-neutral-600 dark:text-neutral-400 hover:bg-neutral-100 dark:hover:bg-neutral-800'}`}
+ className={`flex-1 py-2 text-sm font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-brand-orange ${!changePlanYearly ? 'bg-brand-orange text-white' : 'text-neutral-600 dark:text-neutral-400 hover:bg-neutral-100 dark:hover:bg-neutral-800'}`}
>
Monthly
setChangePlanYearly(true)}
- className={`flex-1 py-2 text-sm font-medium rounded-md transition-colors ${changePlanYearly ? 'bg-brand-orange text-white' : 'text-neutral-600 dark:text-neutral-400 hover:bg-neutral-100 dark:hover:bg-neutral-800'}`}
+ className={`flex-1 py-2 text-sm font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-brand-orange ${changePlanYearly ? 'bg-brand-orange text-white' : 'text-neutral-600 dark:text-neutral-400 hover:bg-neutral-100 dark:hover:bg-neutral-800'}`}
>
Yearly
+ {hasActiveSubscription && (
+
+ {isLoadingPreview ? (
+
+
+ Calculating next invoice…
+
+ ) : invoicePreview ? (
+
+ Next invoice:{' '}
+ {(invoicePreview.amount_due / 100).toLocaleString('en-US', {
+ style: 'currency',
+ currency: invoicePreview.currency.toUpperCase(),
+ })}{' '}
+ on {new Date(invoicePreview.period_end * 1000).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })}{' '}
+ (prorated)
+
+ ) : (
+
+ Unable to calculate preview. Your next invoice will reflect prorations.
+
+ )}
+
+ )}
0). Present when backend supports usage API. */
pageview_usage?: number
+ /** Business name from Stripe Tax ID collection / business purchase flow (optional). */
+ business_name?: string
+ /** Tax IDs collected on the Stripe customer (VAT, EIN, etc.) for invoice verification. */
+ tax_ids?: TaxID[]
+ /** Next invoice amount in cents (for "Renews on X for €Y" display). */
+ next_invoice_amount_due?: number
+ /** Currency for next invoice (e.g. eur). */
+ next_invoice_currency?: string
+ /** Unix timestamp when next invoice period ends. */
+ next_invoice_period_end?: number
}
async function billingFetch(endpoint: string, options: RequestInit = {}): Promise {
@@ -64,12 +80,36 @@ export async function cancelSubscription(params?: CancelSubscriptionParams): Pro
})
}
+/** Clears cancel_at_period_end so the subscription continues past the current period. */
+export async function resumeSubscription(): Promise<{ ok: boolean }> {
+ return await billingFetch<{ ok: boolean }>('/api/billing/resume', {
+ method: 'POST',
+ })
+}
+
export interface ChangePlanParams {
plan_id: string
interval: string
limit: number
}
+export interface PreviewInvoiceResult {
+ amount_due: number
+ currency: string
+ period_end: number
+}
+
+export async function previewInvoice(params: ChangePlanParams): Promise {
+ const res = await billingFetch>('/api/billing/preview-invoice', {
+ method: 'POST',
+ body: JSON.stringify(params),
+ })
+ if (res && typeof res === 'object' && 'amount_due' in res && typeof (res as PreviewInvoiceResult).amount_due === 'number') {
+ return res as PreviewInvoiceResult
+ }
+ return null
+}
+
export async function changePlan(params: ChangePlanParams): Promise<{ ok: boolean }> {
return await billingFetch<{ ok: boolean }>('/api/billing/change-plan', {
method: 'POST',
diff --git a/lib/plans.ts b/lib/plans.ts
index c81a4d5..eb460b3 100644
--- a/lib/plans.ts
+++ b/lib/plans.ts
@@ -1,9 +1,22 @@
/**
* Shared plan and traffic tier definitions for pricing and billing (Change plan).
- * Backend supports plan_id "solo" and limit 10k–10M; month/year interval.
+ * Backend supports plan_id solo, team, business and limit 10k–10M; month/year interval.
*/
export const PLAN_ID_SOLO = 'solo'
+export const PLAN_ID_TEAM = 'team'
+export const PLAN_ID_BUSINESS = 'business'
+
+/** Sites limit per plan. Returns null for free (no limit enforced in UI). */
+export function getSitesLimitForPlan(planId: string | null | undefined): number | null {
+ if (!planId || planId === 'free') return null
+ switch (planId) {
+ case 'solo': return 1
+ case 'team': return 5
+ case 'business': return 10
+ default: return null
+ }
+}
/** Traffic tiers available for Solo plan (pageview limits). */
export const TRAFFIC_TIERS = [
diff --git a/package-lock.json b/package-lock.json
index c1f34dc..9c1256e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,16 +1,18 @@
{
"name": "pulse-frontend",
- "version": "0.6.0-alpha",
+ "version": "0.7.0-alpha",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pulse-frontend",
- "version": "0.6.0-alpha",
+ "version": "0.7.0-alpha",
"dependencies": {
"@ciphera-net/ui": "^0.0.57",
"@ducanh2912/next-pwa": "^10.2.9",
"@radix-ui/react-icons": "^1.3.0",
+ "@stripe/react-stripe-js": "^5.6.0",
+ "@stripe/stripe-js": "^8.7.0",
"axios": "^1.13.2",
"country-flag-icons": "^1.6.4",
"d3-scale": "^4.0.2",
@@ -2715,6 +2717,30 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/@stripe/react-stripe-js": {
+ "version": "5.6.0",
+ "resolved": "https://registry.npmjs.org/@stripe/react-stripe-js/-/react-stripe-js-5.6.0.tgz",
+ "integrity": "sha512-tucu/vTGc+5NXbo2pUiaVjA4ENdRBET8qGS00BM4BAU8J4Pi3eY6BHollsP2+VSuzzlvXwMg0it3ZLhbCj2fPg==",
+ "license": "MIT",
+ "dependencies": {
+ "prop-types": "^15.7.2"
+ },
+ "peerDependencies": {
+ "@stripe/stripe-js": ">=8.0.0 <9.0.0",
+ "react": ">=16.8.0 <20.0.0",
+ "react-dom": ">=16.8.0 <20.0.0"
+ }
+ },
+ "node_modules/@stripe/stripe-js": {
+ "version": "8.7.0",
+ "resolved": "https://registry.npmjs.org/@stripe/stripe-js/-/stripe-js-8.7.0.tgz",
+ "integrity": "sha512-tNUerSstwNC1KuHgX4CASGO0Md3CB26IJzSXmVlSuFvhsBP4ZaEPpY4jxWOn9tfdDscuVT4Kqb8cZ2o9nLCgRQ==",
+ "license": "MIT",
+ "peer": true,
+ "engines": {
+ "node": ">=12.16"
+ }
+ },
"node_modules/@surma/rollup-plugin-off-main-thread": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
diff --git a/package.json b/package.json
index c8b81cf..6900890 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pulse-frontend",
- "version": "0.7.0-alpha",
+ "version": "0.8.0-alpha",
"private": true,
"scripts": {
"dev": "next dev",
@@ -13,6 +13,8 @@
"@ciphera-net/ui": "^0.0.57",
"@ducanh2912/next-pwa": "^10.2.9",
"@radix-ui/react-icons": "^1.3.0",
+ "@stripe/react-stripe-js": "^5.6.0",
+ "@stripe/stripe-js": "^8.7.0",
"axios": "^1.13.2",
"country-flag-icons": "^1.6.4",
"d3-scale": "^4.0.2",