Skip to content

feat: add billing surface for Hosted Switchboard#125

Open
GautamKumarOffical wants to merge 1 commit into
kcolbchain:mainfrom
GautamKumarOffical:feat/billing-surface
Open

feat: add billing surface for Hosted Switchboard#125
GautamKumarOffical wants to merge 1 commit into
kcolbchain:mainfrom
GautamKumarOffical:feat/billing-surface

Conversation

@GautamKumarOffical

Copy link
Copy Markdown

Summary

Adds billing surface for Hosted Switchboard with Standard/Pro tier support.

Closes #87

What this PR does

Implements the foundational billing system for Hosted Switchboard customers:

Billing Tiers

  • Standard: 1000 tx/month included, $0.001/tx overage
  • Pro: 10000 tx/month included, $0.0008/tx overage (10% annual discount)

Features

  • BillingTier enum for tier selection
  • TierConfig with included tx, overage rates, pricing
  • BillingManager for customer metering
  • Per-tx counter and overage calculation
  • Monthly invoice generation

Files

  • switchboard/billing.py — Billing module
  • tests/test_billing.py — Unit tests

Acceptance Criteria

  • Tier definitions (Standard, Pro)
  • Per-tx metering
  • Overage calculation
  • Invoice generation
  • Stripe integration (follow-up PR)
  • Customer dashboard (follow-up PR)

Implements the Standard/Pro tier billing system with:
- BillingTier enum (Standard, Pro)
- TierConfig with included tx, overage rates, pricing
- BillingManager for customer metering
- Per-tx counter and overage calculation
- Monthly invoice generation

Closes kcolbchain#87

Signed-off-by: Gautam Kumar <gautamkumarofficial@users.noreply.github.com>
@abhicris

Copy link
Copy Markdown
Contributor

Welcome to kcolbchain, @GautamKumarOffical — glad you're here. 🌱

Here's what happens from this PR:

  1. Our automated review looks for obvious issues (tests, secrets, size) within a couple of hours.
  2. If it's clean and CI passes, we merge without back-and-forth.
  3. If we need changes, we'll leave a specific comment — not a generic nit. Push another commit and we re-review.

While you wait:

  • Run the repo's tests locally (see the repo README.md).
  • Keep the PR scoped to one concern — bigger PRs land slower.
  • Don't commit tokens or .env contents.

What happens after your first merge

Thanks for writing the code. We're building this to last.

@abhicris

Copy link
Copy Markdown
Contributor

🤖 Audit verdict: needs_human

Code lacks monthly reset mechanism for transaction counts, causing incorrect billing calculations across months.

Risks flagged:

  • Monthly billing cycle not enforced: tx_count_current_month in CustomerBilling is never reset, so transactions accumulate across months
  • get_tx_count() docstring promises 'current month's tx count' but performs no month-based filtering despite recording timestamps
  • Tests do not cover multi-month scenarios; single-month test cases don't catch the reset bug

Audited by the kcolbchain PR pipeline. See pipeline docs.

@gtx20060124-bot

Copy link
Copy Markdown

Good catch @abhicris. Suggestion: add a method gated by a cron-like check on — if the stored timestamp is > 30 days old, reset to 0 and update the timestamp. This keeps it pull-based without needing an external scheduler.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Productize Switchboard Hosted: Standard + Pro billing surface

3 participants