Skip to content

Fix/stripe invoice webhooks - #135

Merged
sinatayebati merged 30 commits into
mainfrom
fix/stripe-invoice-webhooks
Oct 4, 2026
Merged

sinatayebati merged 30 commits into
mainfrom
fix/stripe-invoice-webhooks

Conversation

@sinatayebati

@sinatayebati sinatayebati commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Provide a brief summary of the changes and the motivation behind them.

Related Issues

Link any related issues below (use Closes #123 to auto-close on merge).

  • Closes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / infrastructure change

Contributor Checklist

  • I have read the Contributing Guidelines
  • make lint passes with no errors
  • make test-unit passes
  • I have added or updated tests that cover my changes
  • I have updated documentation where necessary
  • My commits follow the project's commit message conventions

Screenshots / Logs

If applicable, add screenshots or log output to help reviewers.


Note

High Risk
Changes core Stripe overage charging, invoice webhook ordering, and period closure—errors could double-charge, miss revenue, or close the wrong billing period.

Overview
Introduces durable billing reports so usage overages are reserved in Postgres (billing_reports) with frozen Stripe payloads, then delivered asynchronously with retries—replacing the previous pattern of creating InvoiceItems inline and advancing watermarks immediately.

Stripe renewal flow is tightened: overages target the invoice’s ending period (from period_start/period_end), draft invoices get last-chance capture, finalized invoices roll charges to carryover, and invoice.paid stages closure markers without rebilling the wrong month. Subscription period advances are forward-only so delayed webhooks cannot rewind billing. A Celery dispatcher recovers pending reports and checks recently closed periods for late Redis counters.

Also bumps release to v0.7.0, default judge model to vertex_ai/gemini-3.5-flash-lite, upgrades LiteLLM, expands judge picker models, and makes batch/single eval run names optional in the dashboard (field moved below Model).

Deploy: run migration fd38fefe55a8 before rollout; avoid running legacy and new overage reporters in parallel.

Reviewed by Cursor Bugbot for commit 4d881e7. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread backend/app/services/billing_service.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b57421f. Configure here.

Comment thread backend/app/services/billing_reporting_service.py
Comment thread backend/app/infrastructure/db/repositories/billing_report_repo.py
Comment thread backend/tests/unit/test_llm_engine.py Fixed
@sinatayebati
sinatayebati merged commit 3be2210 into main Oct 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants