TypeScript Interfaces
Complete TypeScript definitions for all Billing SDK components and data structures
Plan Interface
The Plan
interface is used to define the structure of a pricing plan and is shared across all the PricingTable
components.
interface Plan {
id: string
title: string
description: string
highlight?: boolean
type?: 'monthly' | 'yearly'
currency?: string
monthlyPrice: string
yearlyPrice: string
buttonText: string
badge?: string
features: {
name: string
icon: string
iconColor?: string
}[],
benefits?: string[]
}
Whenever you add a new component which uses the Plan
interface, a file /lib/billingsdk-config.ts
will be created with the plans
array.
CurrentPlan Interface
The CurrentPlan
interface is used to define the structure of a user's current subscription plan and billing information. It combines plan details with subscription-specific data.
interface CurrentPlan {
plan: Plan
type: 'monthly' | 'yearly' | 'custom'
price?: string
nextBillingDate: string
paymentMethod: string
status: 'active' | 'inactive' | 'past_due' | 'cancelled'
}
Properties
- plan: The complete
Plan
object containing plan details - type: The billing cycle type (
monthly
,yearly
, orcustom
) - price: Optional current price (useful for custom pricing)
- nextBillingDate: The date when the next billing cycle starts
- paymentMethod: The payment method used for the subscription
- status: The current status of the subscription plan
A sample of the /lib/billingsdk-config.ts
file is:
// lib/billingsdk-config.ts
export interface Plan {
id: string
title: string
description: string
highlight?: boolean
type?: 'monthly' | 'yearly'
currency?: string
monthlyPrice: string
yearlyPrice: string
buttonText: string
badge?: string
features: {
name: string
icon: string
iconColor?: string
}[]
}
export interface CurrentPlan {
plan: Plan
type: 'monthly' | 'yearly' | 'custom'
price?: string
nextBillingDate: string
paymentMethod: string
status: 'active' | 'inactive' | 'past_due' | 'cancelled'
}
export const plans: Plan[] = [
{
id: 'starter',
title: 'Starter',
description: 'For developers testing out Liveblocks locally.',
currency: '$',
monthlyPrice: '0',
yearlyPrice: '0',
buttonText: 'Start today for free',
features: [
{
name: 'Presence',
icon: "check",
iconColor: 'text-green-500'
},
{
name: 'Comments',
icon: "check",
iconColor: 'text-orange-500'
},
{
name: 'Notifications',
icon: "check",
iconColor: 'text-teal-500'
},
{
name: 'Text Editor',
icon: "check",
iconColor: 'text-blue-500'
},
{
name: 'Sync Datastore',
icon: "check",
iconColor: 'text-zinc-500'
}
],
},
{
id: 'pro',
title: 'Pro',
description: 'For companies adding collaboration in production.',
currency: '$',
monthlyPrice: '20',
yearlyPrice: '199',
buttonText: 'Sign up',
badge: 'Most popular',
highlight: true,
features: [
{
name: 'Presence',
icon: "check",
iconColor: 'text-green-500'
},
{
name: 'Comments',
icon: "check",
iconColor: 'text-orange-500'
},
{
name: 'Notifications',
icon: "check",
iconColor: 'text-teal-500'
},
{
name: 'Text Editor',
icon: "check",
iconColor: 'text-blue-500'
},
{
name: 'Sync Datastore',
icon: "check",
iconColor: 'text-zinc-500'
}
],
},
{
id: 'enterprise',
title: 'Enterprise',
description: 'For organizations that need more support and compliance features.',
currency: '$',
monthlyPrice: 'Custom',
yearlyPrice: 'Custom',
buttonText: 'Contact sales',
features: [
{
name: 'Presence',
icon: "check",
iconColor: 'text-green-500'
},
{
name: 'Comments',
icon: "check",
iconColor: 'text-orange-500'
},
{
name: 'Notifications',
icon: "check",
iconColor: 'text-teal-500'
},
{
name: 'Text Editor',
icon: "check",
iconColor: 'text-blue-500'
},
{
name: 'Sync Datastore',
icon: "check",
iconColor: 'text-zinc-500'
}
],
}
];
Payment Method Manager
The Payment Method Manager component provides a PCI-compliant UI for managing billing payment methods. Uses redirect-to-gateway approach for secure add/edit operations with no direct handling of sensitive data.
Theming
Customize your components by modifying CSS variables in global.css