This document provides the technical implementation overview for billing, refund, and promotions behavior in the hosted reference deployment.
Scope
This overview covers:
- Promotion data model and precedence resolution.
- Billing integration points where promotions affect price/tier behavior.
- Refund lifecycle processing, adjustment reconciliation, and audit coverage.
- Security controls and policy guardrails applied to billing/refund actions.
This is an implementation overview, not a product roadmap. Future enhancements should be tracked as separate technical proposals.
Architecture Overview
Core implementation areas:
- Domain and resolver
checktick_app/core/models.pychecktick_app/core/services/promotion_resolver.py- Billing/provider integration
checktick_app/core/billing.pychecktick_app/core/views_billing.py- Platform admin billing/refund operations
checktick_app/core/views_platform_admin.pychecktick_app/core/templates/core/platform_admin/billing.html- Public pricing/signup surfacing
checktick_app/core/views.pychecktick_app/core/templates/core/home.htmlchecktick_app/core/templates/core/pricing.html- Lifecycle operations and notifications
checktick_app/core/management/commands/process_promotion_lifecycle.pychecktick_app/core/email_utils.py
Promotions: Model and Resolution
Promotion model
Promotions are represented as first-class records with:
- Scope (
platform,tier,account) and target metadata. - Effect type/value for discounting or tier override behavior.
- Activation window (
starts_at,ends_at) and active flag. - Priority and audit metadata for deterministic selection and traceability.
Deterministic precedence
Effective promotion resolution is deterministic:
- Account-scoped promotions (most specific).
- Tier-scoped promotions.
- Platform-scoped promotions.
- Baseline pricing/tier behavior when no promotion applies.
Within a scope, priority and recency determine the winner.
Public pricing/signup integration
Public pages surface resolved active offers for eligible tiers while preserving baseline pricing as canonical fallback.
Billing Integration
Price and tier evaluation
Billing flows integrate promotion resolution before provider-side amounts are prepared.
Key rules:
- Applied promotion metadata is carried with billing records for traceability.
- Promotion outputs are bounded by business constraints (for example, no negative charge amounts).
- Effective tier/price decisions are reproducible from persisted metadata.
Organization checkout
Organization checkout applies effective pricing with the same guardrails used across other billing entry points.
Refund Lifecycle and Reconciliation
Admin-initiated refunds
Platform admin billing supports operator-initiated refund actions with policy constraints:
- Hosted reference flow automates full refunds only.
- Reason code is mandatory.
- Additional free-text reason is required when reason code is
other.
Webhook-driven lifecycle states
Refund lifecycle transitions are processed from signed provider webhooks (for example: created, paid, failed, funds_returned, refund_settled), with idempotent reconciliation.
Adjustment reporting
Promotion-linked adjustments are summarized in platform admin billing reporting with bounded query windows and structured metadata for finance and audit workflows.
Audit and Notifications
Audit coverage includes:
- Promotion create/update/toggle/revoke lifecycle events.
- Refund request and reconciliation metadata.
- Operator attribution and provider reference fields.
Notification coverage includes customer-facing refund processed messaging and promotion lifecycle notifications where configured.
Security Controls
Security controls in this implementation include:
- Superuser-only access for platform admin billing/promotion actions.
- Strict HTTP method controls for sensitive endpoints.
- Rate limiting on billing and admin operations.
- Webhook signature verification with required webhook secret.
- CSRF protection on administrative form actions.
Self-Hosted Behavior
For SELF_HOSTED=true deployments, billing is disabled by default. Promotion and refund integrations are only applicable where operators explicitly implement and configure an external billing provider.