Skip to content

Add PremiumService, normalize PremiumModel, refactor API/Cog, add tests and docs, bump discord.py#12

Draft
bergaman9 wants to merge 2 commits intomainfrom
codex/prepare-refactor-plan-for-project
Draft

Add PremiumService, normalize PremiumModel, refactor API/Cog, add tests and docs, bump discord.py#12
bergaman9 wants to merge 2 commits intomainfrom
codex/prepare-refactor-plan-for-project

Conversation

@bergaman9
Copy link
Owner

Motivation

  • Consolidate premium subscription logic into an application service to separate business rules from API and bot cogs.
  • Normalize tier/payment representations and make activation idempotent to reduce payment/transaction edge cases.
  • Provide a runnable migration/refactor plan and documentation for production-grade premium/billing changes.

Description

  • Added a new PremiumService (src/services/premium_service.py) that centralizes get_status and activate_with_payment use-cases and enforces idempotency and payment verification.
  • Updated the premium data model (src/database/models/premium.py) to normalize tier and payment method values and adjusted in-place activation/upsert behavior.
  • Refactored API routes (src/api/routes/premium_api.py) to use PremiumService and simplified route logic to delegate verification/activation to the service; preserved a TODO for proper JWT auth.
  • Refactored the Discord cog (src/cogs/premium/premium.py) to use PremiumService, normalize displayed tiers, and fixed permission checks to use app_commands.checks.has_permissions.
  • Bumped discord.py minimal version in requirements.txt from >=2.3.0 to >=2.5.2.
  • Added design and rollout documentation (docs/PRODUCTION_REFACTOR_AND_PREMIUM_PLAN.md, docs/REFACTOR_PLAN_DISCORDPY_PREMIUM.md) describing architecture, migration, and sprint roadmap.
  • Added unit/integration-style tests for the service (tests/test_premium_service.py) using lightweight dummy model/crypto service fakes.

Testing

  • Added tests/test_premium_service.py covering success path, idempotency, and unknown-tier handling for activate_with_payment and executed the suite with pytest.
  • Test run: all tests in tests/test_premium_service.py passed (3 tests, async pytest markers).
  • No other automated CI gates were modified in this change.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant