diff --git a/components/dashboard/src/teams/TeamBilling.tsx b/components/dashboard/src/teams/TeamBilling.tsx index c42221fadc7272..25aa4bdf926dab 100644 --- a/components/dashboard/src/teams/TeamBilling.tsx +++ b/components/dashboard/src/teams/TeamBilling.tsx @@ -34,6 +34,17 @@ export default function TeamBilling() { const [pendingTeamPlan, setPendingTeamPlan] = useState(); const [pollTeamSubscriptionTimeout, setPollTeamSubscriptionTimeout] = useState(); + console.log( + "members", + members.length, + "currency", + currency, + "teamSubscription", + teamSubscription, + "pendingTeamPlan", + pendingTeamPlan, + ); + useEffect(() => { if (!team) { return; diff --git a/components/ee/payment-endpoint/src/accounting/team-subscription2-service.ts b/components/ee/payment-endpoint/src/accounting/team-subscription2-service.ts index 84f306098c363a..2dee1e9241b356 100644 --- a/components/ee/payment-endpoint/src/accounting/team-subscription2-service.ts +++ b/components/ee/payment-endpoint/src/accounting/team-subscription2-service.ts @@ -11,6 +11,7 @@ import { TeamSubscription2 } from "@gitpod/gitpod-protocol/lib/team-subscription import { inject, injectable } from "inversify"; import { SubscriptionModel } from "./subscription-model"; import { SubscriptionService } from "./subscription-service"; +import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; @injectable() export class TeamSubscription2Service { @@ -19,6 +20,7 @@ export class TeamSubscription2Service { @inject(SubscriptionService) protected readonly subscriptionService: SubscriptionService; async addAllTeamMemberSubscriptions(ts2: TeamSubscription2): Promise { + log.info(`addAllTeamMemberSubscriptions: ts2=${JSON.stringify(ts2)}`); const members = await this.teamDB.findMembersByTeam(ts2.teamId); for (const member of members) { await this.addTeamMemberSubscription(ts2, member.userId); @@ -26,6 +28,7 @@ export class TeamSubscription2Service { } async addTeamMemberSubscription(ts2: TeamSubscription2, userId: string): Promise { + log.info(`addTeamMemberSubscription: ts2=${JSON.stringify(ts2)} userId=${JSON.stringify(userId)}`); const membership = await this.teamDB.findTeamMembership(userId, ts2.teamId); if (!membership) { throw new Error(`Could not find membership for user '${userId}' in team '${ts2.teamId}'`); @@ -39,6 +42,7 @@ export class TeamSubscription2Service { } protected async addSubscription(db: AccountingDB, userId: string, planId: string, teamMembershipId: string, startDate: string, amount: number, firstMonthAmount?: number, endDate?: string, cancelationDate?: string) { + log.info(`addSubscription: userId=${userId} planId=${planId} teamMembershipId=${teamMembershipId} startDate=${startDate} amount=${amount}`); const model = await this.loadSubscriptionModel(db, userId); const subscription = Subscription.create({ userId, @@ -56,6 +60,7 @@ export class TeamSubscription2Service { } async cancelAllTeamMemberSubscriptions(ts2: TeamSubscription2, date: Date): Promise { + log.info(`cancelAllTeamMemberSubscriptions: ts2=${JSON.stringify(ts2)} date=${date.toISOString()}`); const members = await this.teamDB.findMembersByTeam(ts2.teamId); for (const member of members) { const membership = await this.teamDB.findTeamMembership(member.userId, ts2.teamId); @@ -67,6 +72,7 @@ export class TeamSubscription2Service { } async cancelTeamMemberSubscription(ts2: TeamSubscription2, userId: string, teamMemberShipId: string, date: Date): Promise { + log.info(`cancelTeamMemberSubscription: ts2=${JSON.stringify(ts2)} userId=${userId} teamMemberShipId=${teamMemberShipId} date=${date.toISOString()}`); const { endDate } = Subscription.calculateCurrentPeriod(ts2.startDate, date); return this.accountingDb.transaction(async (db) => { await this.cancelSubscription(db, userId, ts2.planId, teamMemberShipId, endDate); @@ -74,6 +80,7 @@ export class TeamSubscription2Service { } protected async cancelSubscription(db: AccountingDB, userId: string, planId: string, teamMembershipId: string, cancellationDate: string) { + log.info(`cancelSubscription: userId=${userId} planId=${planId} teamMembershipId=${teamMembershipId} cancellationDate=${cancellationDate}`); const model = await this.loadSubscriptionModel(db, userId); const subscription = model.findSubscriptionByTeamMembershipId(teamMembershipId); if (!subscription) { diff --git a/components/ee/payment-endpoint/src/chargebee/endpoint-controller.ts b/components/ee/payment-endpoint/src/chargebee/endpoint-controller.ts index 54088a2be0585c..f8358a91faa46d 100644 --- a/components/ee/payment-endpoint/src/chargebee/endpoint-controller.ts +++ b/components/ee/payment-endpoint/src/chargebee/endpoint-controller.ts @@ -61,6 +61,7 @@ export class EndpointController { * @param res */ private async handleUpdateGitpodSubscription(req: express.Request, res: express.Response) { + log.info('Chargebee handleUpdateGitpodSubscription!'); if (!req.body || !req.body.event_type) { log.error('Received malformed event request from chargebee!'); return; @@ -70,7 +71,7 @@ export class EndpointController { const handled = await this.eventHandler.handle(req.body); if (!handled) { const payload = { chargebeeEventType: req.body.event_type, action: 'ignored' }; - log.debug(`Faithfully ignoring chargebee event of type: ${req.body.event_type}`, payload); + log.warn(`Faithfully ignoring chargebee event of type: ${req.body.event_type}`, payload); } res.status(200).send(); } catch (err) { diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 53ff6ca9a3e57d..16933781112e14 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -1430,6 +1430,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl { const members = await this.teamDB.findMembersByTeam(teamSubscription.teamId); const oldQuantity = teamSubscription.quantity; const newQuantity = members.length; + log.info(`updateTeamSubscriptionQuantity: oldQuantity=${oldQuantity}, newQuantity=${newQuantity}`); try { if (oldQuantity < newQuantity) { // Upgrade: Charge for it! @@ -1451,6 +1452,9 @@ export class GitpodServerEEImpl extends GitpodServerImpl { const description = `Pro-rated upgrade from '${oldQuantity}' to '${newQuantity}' team members (${formatDate( upgradeTimestamp, )})`; + log.info( + `chargeForUpgrade: paymentReference=${teamSubscription.paymentReference}, currentTermRemainingRatio=${currentTermRemainingRatio}, diffInCents=${diffInCents}`, + ); await this.upgradeHelper.chargeForUpgrade( "", teamSubscription.paymentReference, @@ -1464,6 +1468,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl { end_of_term: false, }); } catch (err) { + log.error("updateTeamSubscriptionQuantity failed", err); if (chargebee.ApiError.is(err) && err.type === "payment") { throw new ResponseError(ErrorCodes.PAYMENT_ERROR, `${err.api_error_code}: ${err.message}`); }