Closed easyCZ closed 2 years ago
Manually configured staging environment to send invoice.finalized
webhooks
Stripe signing secret is now loaded into staging/production with https://github.com/gitpod-io/ops/pull/3974
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.
We won't be going with this approach. Instead we'll approach it with https://github.com/gitpod-io/gitpod/issues/12741
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:
Interactions with Stripe and the
content-service
:Tasks
Done
Webhook registration
public-api
pod.Implement
FinalizeInvoice
RPCFinalizeInvoice
RPC onusage
that the public api will invoke from the webhook handler. (https://github.com/gitpod-io/gitpod/pull/11949)FinalizeInvoice
RPC when aninvoice.finalized
event is received. (https://github.com/gitpod-io/gitpod/pull/11987)Other
Notes