Add premium subscriptions and casual server orchestration#62
Draft
NicholasBottone wants to merge 5 commits into
Draft
Add premium subscriptions and casual server orchestration#62NicholasBottone wants to merge 5 commits into
NicholasBottone wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds premium subscriptions for casual server hosting, with Polar as the billing provider and SecondWebsite as the entitlement/usage authority. Ranked server flows remain free and separate.
Subscriptions and casual servers
subscriptionsDjango app.API endpoints added
GET /api/subscriptions/me/entitlement/GET /api/subscriptions/casual-games/GET /api/subscriptions/users/{discord_user_id}/entitlement/POST /api/subscriptions/server-sessions/start/POST /api/subscriptions/server-sessions/{session_id}/stop/POST /api/subscriptions/server-sessions/{session_id}/orchestrator-event/POST /subscriptions/polar/webhook/DB tables/models added
SubscriptionPlan: configurable tiers, pricing, server-minute limits, max session length, concurrency, Polar product mapping.SubscriptionEntitlement: provider-neutral active subscription/comp entitlement records.ServerSession: casual server reservation/lifecycle state, orchestrator session details, connection info, callbacks, failures.UsageLedgerEntry: billing-period usage ledger, rounded to 5-minute increments.WebhookEvent: idempotency/audit record for Polar and orchestrator events.Inter-service contracts
Discord bot -> SecondWebsite:
API_KEYviaX-API-KEY.owner_discord_id; SecondWebsite handles entitlement, remaining minutes, max session length, and concurrency.SecondWebsite -> orchestrator:
ORCHESTRATOR_API_BASE_URLandORCHESTRATOR_API_TOKEN.Orchestrator -> SecondWebsite:
orchestrator-event/withX-API-KEY.launch_accepted,ready,heartbeat,stopping,stopped,launch_failed,exited, andkilled.event_idis used for idempotency.Migration baseline repair
migrations/from.gitignore..venv/bin/python manage.py migrate --fake-initial.venv/bin/python manage.py migrateCI
Validation
manage.py makemigrations --check --dry-runmanage.py migrate --planmanage.py checkpytest