UNPKG

optumflex-subscription-core

Version:

Core logic and utilities for subscription management, pricing calculations, and data processing - framework agnostic

98 lines 3.19 kB
export type BillingCycle = 'weekly' | 'monthly' | 'quarterly' | 'halfyearly' | 'yearly'; export type PlanType = 'subscriptionPlans' | 'modelPortfolios'; export interface PricingPackage { id: string; title: string; description: string; prices: { [key in BillingCycle]: number; }; discounted: { [key in BillingCycle]: number; }; features: string[]; } export interface CartItem { plan: PricingPackage; cycle: BillingCycle; } export interface CheckoutPayload { packageCode: string; duration: BillingCycle; } export interface DiscountInfo { originalPrice: number; discountedPrice: number; savings: number; savingsPercentage: number; isDiscounted: boolean; } export interface SubscriptionState { subscriptionPlans: PricingPackage[]; modelPortfolios: PricingPackage[]; selectedCycles: { [planId: string]: BillingCycle; }; planType: PlanType; sortBy: string; loading: boolean; error: string | null; } export interface UseSubscriptionDataOptions { initialPlanType?: PlanType; initialSortBy?: string; onError?: (error: string) => void; onSuccess?: (message: string) => void; enableCart?: boolean; appUrl?: string; apiKey?: string; } export interface UseSubscriptionDataReturn { subscriptionPlans: PricingPackage[]; modelPortfolios: PricingPackage[]; selectedCycles: { [planId: string]: BillingCycle; }; planType: PlanType; sortBy: string; loading: boolean; error: string | null; setSelectedCycle: (planId: string, cycle: BillingCycle) => void; setPlanType: (planType: PlanType) => void; setSortBy: (sortBy: string) => void; processApiResponse: (data: any) => void; getDisplayedPlans: () => PricingPackage[]; getPlanStatistics: () => { totalPlans: number; plansWithDiscounts: number; averagePrice: number; priceRange: { min: number; max: number; }; }; getDiscountInfo: (plan: PricingPackage, cycle: BillingCycle) => DiscountInfo; getAvailableCycles: (plan: PricingPackage) => BillingCycle[]; generateSinglePlanCheckoutUrl: (plan: PricingPackage, cycle: BillingCycle) => string; formatPrice: (amount: number) => string; getPlanPrice: (plan: PricingPackage, cycle: BillingCycle) => string; cart?: CartItem[]; cartItemCount?: number; cartTotal?: number; showCart?: boolean; addToCart?: (plan: PricingPackage, cycle: BillingCycle) => void; removeFromCart?: (planId: string, cycle: BillingCycle) => void; updateCartItemCycle?: (planId: string, newCycle: BillingCycle) => void; clearCart?: () => void; setShowCart?: (show: boolean) => void; handleCheckout?: () => void; } export interface CartHandlers { addToCart: (plan: PricingPackage, cycle: BillingCycle) => void; removeFromCart: (planId: string, cycle: BillingCycle) => void; updateCartItemCycle: (planId: string, newCycle: BillingCycle) => void; clearCart: () => void; setShowCart: (show: boolean) => void; handleCheckout: () => void; } //# sourceMappingURL=subscription.d.ts.map