Skip to content

Commit 2d2c70f

Browse files
geroplroboquat
authored andcommitted
[server] BillingMode: Use findCustomerByTeamId
1 parent acc216d commit 2d2c70f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

components/server/ee/src/billing/billing-mode.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ export class BillingModesImpl implements BillingModes {
135135
// 3. Check team memberships/plans
136136
// UBB overrides wins if there is _any_. But if there is none, use the existing Chargebee subscription.
137137
const teamsModes = await Promise.all(teams.map((t) => this.getBillingModeForTeam(t, now)));
138-
const hasUbbPaidTeamSeat = teamsModes.some((tm) => tm.mode === "usage-based" && !!tm.paid);
138+
const hasUbbPaidTeam = teamsModes.some((tm) => tm.mode === "usage-based" && !!tm.paid);
139139
const hasCbTeam = teamsModes.some((tm) => tm.mode === "chargebee");
140140
const hasCbTeamSeat = cbTeamSubscriptions.length > 0;
141141

142-
if (hasUbbPaidTeamSeat || hasUbbPersonal) {
143-
// UBB is greedy: once a user has at least a team seat, they should benefit from it!
142+
if (hasUbbPaidTeam || hasUbbPersonal) {
143+
// UBB is greedy: once a user has at least a paid team membership, they should benefit from it!
144144
const result: BillingMode = { mode: "usage-based" };
145145
if (hasCbTeam) {
146146
result.hasChargebeeTeamPlan = true;
@@ -198,7 +198,7 @@ export class BillingModesImpl implements BillingModes {
198198

199199
// 3. Now we're usage-based. We only have to figure out whether we have a plan yet or not.
200200
const result: BillingMode = { mode: "usage-based" };
201-
const customer = await this.stripeSvc.findCustomerByUserId(team.id);
201+
const customer = await this.stripeSvc.findCustomerByTeamId(team.id);
202202
if (customer) {
203203
const subscription = await this.stripeSvc.findUncancelledSubscriptionByCustomer(customer.id);
204204
if (subscription) {

0 commit comments

Comments
 (0)