Entitlements
The entitlements system in ShipFlutter manages user subscriptions and purchases across different payment providers. It integrates with RevenueCat for mobile platforms and LemonSqueezy for web.
What are Entitlements?
An entitlement represents a user’s access to premium features. It includes:
class Entitlement { final String id; // Unique identifier final String productId; // Product identifier from store final PaymentStoreId storeId; // RevenueCat or LemonSqueezy final DateTime? expiresAt; // Subscription expiry final DateTime? unsubscribedAt; // Cancellation date final DateTime? billingIssueAt; // Payment issues final bool isTrial; // Trial period final bool willRenew; // Auto-renewal status final bool isActive; // Current access status}
The concept comes from RevenueCat’s Entitlements. We simplified and aligned it with LemonSqueezy’s Subscriptions.
Syncing Entitlements
The AccountService
automatically syncs entitlements with the user’s account:
- Listens to payment provider events
- Updates local entitlements state
- Syncs with Firestore database
- (Optional) Updates user’s custom claims
// Observe account changes including entitlementsaccountService.instance.observeAccount().listen((account) { final entitlements = account?.entitlements ?? []; // Handle entitlement changes});
In addition, you can configure RevenueCat and/or LemonSqueezy webhooks to sync entitlements with the server.