Skip to content

Billing controller excludes WorkspaceInstances which are already included in previous invoices #10937

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

Closed
9 of 16 tasks
Tracked by #9036
easyCZ opened this issue Jun 27, 2022 · 5 comments
Closed
9 of 16 tasks
Tracked by #9036
Assignees
Labels
team: webapp Issue belongs to the WebApp team

Comments

@easyCZ
Copy link
Member

easyCZ commented Jun 27, 2022

The billing controller will need to be given the full set of WorkspaceInstances (which the UsageController fetched) to perform it's run. This is because in a given billing period (May 1 - May 31), a user can have potentially a large number of subscriptions (not in parallel) - create then cancel and repeat. For the cancelled subscriptions, they will of course need to settle it but we must not charge them for any usage from a cancelled subscription (but within that month). And the Billing Controller is the only component which should have access to Stripe to retrieve this data.
In practice, the controller will need to exclude all WorkspaceInstances which match previously already billed WorkspaceInstances.

Architecture

System architecture:

regular-operation

Interactions with Stripe and the content-service:

invoice-created

Tasks

Done

Webhook registration

  • Register webhook in Stripe (Stripe docs)
  • Add webhook signing secret as K8S secret and mount it into the public-api pod.
  • Implement Stripe signature verification on the webhook. (Stripe docs)

Implement FinalizeInvoice RPC

Other

  • Add report ids to invoice metadata
    • So that when the invoice finalizes we know which report to retrieve from the content service.

Notes

  • To add the webhook signing secret to the cluster we can follow the same pattern as was done for the Stripe API keys - create the secret in the GCP secret dashboard (for preview, staging and production)
    • Add secrets to staging and prod clusters via terraform, eg these PRs for preview [1] and staging/production [1,2].
@easyCZ easyCZ mentioned this issue Jun 27, 2022
73 tasks
@easyCZ
Copy link
Member Author

easyCZ commented Jun 27, 2022

@easyCZ
Copy link
Member Author

easyCZ commented Aug 22, 2022

Manually configured staging environment to send invoice.finalized webhooks

@easyCZ
Copy link
Member Author

easyCZ commented Aug 23, 2022

Stripe signing secret is now loaded into staging/production with https://github.com/gitpod-io/ops/pull/3974

@easyCZ easyCZ self-assigned this Aug 26, 2022
@easyCZ easyCZ moved this from Next Milestone to In Progress in 🍎 WebApp Team Aug 26, 2022
@easyCZ
Copy link
Member Author

easyCZ commented Aug 28, 2022

A WIP for finalizing invoices. Currently, the finalization event doens't tell us which AttributionID it is for. It only gives us the Invoice ID.

We'll need to link the InvoiceID to the attribution ID used for the invoice. Likely, this will need to come from the subscription when it is made originally. This currently contains the teamId field which could be used.

@easyCZ
Copy link
Member Author

easyCZ commented Sep 12, 2022

We won't be going with this approach. Instead we'll approach it with #12741

@easyCZ easyCZ closed this as completed Sep 12, 2022
Repository owner moved this from In Progress to Done in 🍎 WebApp Team Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team: webapp Issue belongs to the WebApp team
Projects
Status: Done
Development

No branches or pull requests

3 participants