Trey t
|
65476e2d66
|
Implement freemium subscription system - Shared Kotlin models (Phase 4)
Shared Kotlin Features:
- Complete subscription data models with kotlinx.serialization
- SubscriptionApi client for all backend endpoints
- SubscriptionCache for storing subscription state
- SubscriptionHelper utility for checking user limits
Models (Subscription.kt):
- SubscriptionStatus (tier, usage, limits, master toggle flag)
- UsageStats (current usage counts)
- TierLimits (tier-specific limits, null = unlimited)
- UpgradeTriggerData (configurable prompts)
- FeatureBenefit (Free vs Pro comparison)
- Promotion (seasonal campaigns)
- ReceiptVerificationRequest/Response
- PurchaseVerificationRequest/Response
API Client (SubscriptionApi.kt):
- getSubscriptionStatus() - fetch user subscription
- getUpgradeTriggers() - fetch upgrade prompts
- getFeatureBenefits() - fetch tier comparison
- getActivePromotions() - fetch active promotions
- verifyIOSReceipt() - verify Apple purchase
- verifyAndroidPurchase() - verify Google purchase
Cache (SubscriptionCache.kt):
- Stores currentSubscription in mutableState
- Stores upgradeTriggers, featureBenefits, promotions
- Reactive state for UI observation
- clear() method for logout
Helper (SubscriptionHelper.kt):
- canAddProperty() - check property limit
- canAddTask() - check task limit
- shouldShowUpgradePromptForContractors() - check if should show upgrade screen
- shouldShowUpgradePromptForDocuments() - check if should show upgrade screen
- Respects master toggle (limitationsEnabled)
- Returns UsageCheck(allowed, triggerKey)
Next: iOS StoreKit implementation (Phase 5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-24 13:30:53 -06:00 |
|