getMySubscription method
Fetch the active subscription for the current user (solo Professional).
Implementation
Future<SubscriptionModel?> getMySubscription() async {
final userId = _client.auth.currentUser?.id;
if (userId == null) return null;
try {
final response = await _client
.from('subscriptions')
.select()
.eq('target_user_id', userId)
.inFilter('status', ['active', 'past_due'])
.order('current_period_end', ascending: false)
.limit(1)
.maybeSingle();
if (response == null) return null;
return SubscriptionModel.fromJson(response);
} catch (e) {
dev.log('getMySubscription failed: $e', name: 'BillingDatasource');
return null;
}
}