Skip to content

Commit

Permalink
Check billingMode in onTeamDeleted method
Browse files Browse the repository at this point in the history
Don't attempt to look up Stripe subscription information if the deleted
team is not using usage based billing.
  • Loading branch information
Andrew Farries committed Sep 28, 2022
1 parent 18bd74a commit 54b0724
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1596,11 +1596,14 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
{ teamId, chargebeeSubscriptionId },
);
}
const subscriptionId = await this.stripeService.findUncancelledSubscriptionByAttributionId(
AttributionId.render({ kind: "team", teamId: teamId }),
);
if (subscriptionId) {
await this.stripeService.cancelSubscription(subscriptionId);
const billingMode = await this.billingModes.getBillingMode({ kind: "team", teamId: teamId }, now);
if (billingMode.mode === "usage-based") {
const subscriptionId = await this.stripeService.findUncancelledSubscriptionByAttributionId(
AttributionId.render({ kind: "team", teamId: teamId }),
);
if (subscriptionId) {
await this.stripeService.cancelSubscription(subscriptionId);
}
}
}

Expand Down

0 comments on commit 54b0724

Please sign in to comment.