Add multi-plan subscriptions, quotas, and token usage APIs
Implements #16/#17/#36: Founders/Standard/Pro/Business/Backer catalog, Backer email whitelist, prompt-window + token-period gates, and tokens_in/out on conversation/prompt + subscription usage APIs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from finance.models import Invoice, Payment
|
||||
from finance.models import Invoice, Payment, SubscriptionPlan
|
||||
|
||||
|
||||
class InvoiceSerializer(serializers.ModelSerializer):
|
||||
@@ -49,7 +49,38 @@ class PaymentSerializer(serializers.ModelSerializer):
|
||||
class CheckoutSessionSerializer(serializers.Serializer):
|
||||
success_url = serializers.URLField(required=False, allow_blank=False)
|
||||
cancel_url = serializers.URLField(required=False, allow_blank=False)
|
||||
plan_slug = serializers.SlugField(required=False, allow_blank=False)
|
||||
|
||||
|
||||
class PortalSessionSerializer(serializers.Serializer):
|
||||
return_url = serializers.URLField(required=False, allow_blank=False)
|
||||
|
||||
|
||||
class SubscriptionPlanSerializer(serializers.ModelSerializer):
|
||||
features = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = SubscriptionPlan
|
||||
fields = [
|
||||
"slug",
|
||||
"name",
|
||||
"description",
|
||||
"price_cents",
|
||||
"currency",
|
||||
"interval",
|
||||
"is_public",
|
||||
"is_selectable",
|
||||
"features",
|
||||
"prompt_quota_per_window",
|
||||
"prompt_window_hours",
|
||||
"monthly_token_quota",
|
||||
"sort_order",
|
||||
]
|
||||
read_only_fields = fields
|
||||
|
||||
def get_features(self, obj):
|
||||
return {
|
||||
"text_generation": obj.allows_feature("text_generation"),
|
||||
"image_generation": obj.allows_feature("image_generation"),
|
||||
"all_future_features": obj.allows_all_future_features,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user