Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Billing fixes #3976

Merged
merged 11 commits into from
Feb 13, 2025
Merged

Billing fixes #3976

merged 11 commits into from
Feb 13, 2025

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Feb 12, 2025

Description

Brief background

Should go in in tandem with https://github.com/onyx-dot-app/danswer-control-plane/pull/26

When it comes to billing, we have a few pieces of relevant information to store:

  • Subscription status (trial / subscribed / etc.- all the other Stripe subscription status states)
  • Cancel at period end? (boolean)
  • Application status (status in the Onyx application)
    • What the current status is for a given user (full access, payment reminder, no access)
  • Time frames: trial start/end, bill period start/end

The ground truth is always Stripe, so we use the Stripe customer /subscription IDs to be able to reference the Stripe API as often as possible. That being said, we have two mechanisms for keeping subscription details up to date in the control plane:

  • Background processes that regularly crawl for the current status from Stripe, update subscription and tenant objects as needed
  • Web-hooks which should update details in real time

How do we make sure that the data plane always has accurate and up-to-date information on a given user's billing information (considering we don't want to add unnecessary complexity to the data plane)?

  • For billing page specifically, ping control plane for billing details to show user
  • For application status (i.e. full / gated access), transition "gating" notification endpoint to "application status update" endpoint which the control plane must receive a 200 from before updating the tenant's application status inthe control plane (ensuring the two are in sync).

What this PR does

  • Remove extraneous payment reminder notification "gating type" and transition to "application status" which should be continuously kept in sync with the data plane / ground truth
  • Clarify billing page with trial dates, "cancels at end of month?", and payment reminders.
  • Enable un-subscribed + inactive tenants to re-subscribe from their gating page by creating new checkout session
  • General code cleanup

How Has This Been Tested?

Test various billing flows with local multi tenant setup,
with both and only one of each of background processes and webhooks enabled

  • Cancel during trial with/without payment info
  • Cancel after trial ends
  • Cancel + immediately end trial
  • Resubscribe from "gating" page after unsubscribing and expiring subscription
  • Don't put in billing information + get to <2 days of trial left

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 11:02pm

Copy link
Contributor

@rkuo-danswer rkuo-danswer left a comment

Choose a reason for hiding this comment

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

did my best to review this, seems OK. This seems like a good candidate to add to Chris's testing bash document.

web/src/app/ee/admin/billing/BillingAlerts.tsx Outdated Show resolved Hide resolved
@pablonyx pablonyx added this pull request to the merge queue Feb 13, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 13, 2025
* misct billing_fixes
g

* various billing updates

* improvements

* quick nit

* k

* update

* k

* k

* k
@pablonyx pablonyx removed this pull request from the merge queue due to a manual request Feb 13, 2025
@pablonyx pablonyx merged commit 3260d79 into main Feb 13, 2025
10 of 11 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