Skip to content

Commit b3cc98b

Browse files
committed
DEBUG
1 parent 81b41f1 commit b3cc98b

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

components/dashboard/src/teams/TeamBilling.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ export default function TeamBilling() {
3434
const [pendingTeamPlan, setPendingTeamPlan] = useState<PendingPlan | undefined>();
3535
const [pollTeamSubscriptionTimeout, setPollTeamSubscriptionTimeout] = useState<NodeJS.Timeout | undefined>();
3636

37+
console.log(
38+
"members",
39+
members.length,
40+
"currency",
41+
currency,
42+
"teamSubscription",
43+
teamSubscription,
44+
"pendingTeamPlan",
45+
pendingTeamPlan,
46+
);
47+
3748
useEffect(() => {
3849
if (!team) {
3950
return;

components/ee/payment-endpoint/src/accounting/team-subscription2-service.ts

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { TeamSubscription2 } from "@gitpod/gitpod-protocol/lib/team-subscription
1111
import { inject, injectable } from "inversify";
1212
import { SubscriptionModel } from "./subscription-model";
1313
import { SubscriptionService } from "./subscription-service";
14+
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
1415

1516
@injectable()
1617
export class TeamSubscription2Service {
@@ -19,13 +20,15 @@ export class TeamSubscription2Service {
1920
@inject(SubscriptionService) protected readonly subscriptionService: SubscriptionService;
2021

2122
async addAllTeamMemberSubscriptions(ts2: TeamSubscription2): Promise<void> {
23+
log.info(`addAllTeamMemberSubscriptions: ts2=${JSON.stringify(ts2)}`);
2224
const members = await this.teamDB.findMembersByTeam(ts2.teamId);
2325
for (const member of members) {
2426
await this.addTeamMemberSubscription(ts2, member.userId);
2527
}
2628
}
2729

2830
async addTeamMemberSubscription(ts2: TeamSubscription2, userId: string): Promise<void> {
31+
log.info(`addTeamMemberSubscription: ts2=${JSON.stringify(ts2)} userId=${JSON.stringify(userId)}`);
2932
const membership = await this.teamDB.findTeamMembership(userId, ts2.teamId);
3033
if (!membership) {
3134
throw new Error(`Could not find membership for user '${userId}' in team '${ts2.teamId}'`);
@@ -39,6 +42,7 @@ export class TeamSubscription2Service {
3942
}
4043

4144
protected async addSubscription(db: AccountingDB, userId: string, planId: string, teamMembershipId: string, startDate: string, amount: number, firstMonthAmount?: number, endDate?: string, cancelationDate?: string) {
45+
log.info(`addSubscription: userId=${userId} planId=${planId} teamMembershipId=${teamMembershipId} startDate=${startDate} amount=${amount}`);
4246
const model = await this.loadSubscriptionModel(db, userId);
4347
const subscription = Subscription.create({
4448
userId,
@@ -56,6 +60,7 @@ export class TeamSubscription2Service {
5660
}
5761

5862
async cancelAllTeamMemberSubscriptions(ts2: TeamSubscription2, date: Date): Promise<void> {
63+
log.info(`cancelAllTeamMemberSubscriptions: ts2=${JSON.stringify(ts2)} date=${date.toISOString()}`);
5964
const members = await this.teamDB.findMembersByTeam(ts2.teamId);
6065
for (const member of members) {
6166
const membership = await this.teamDB.findTeamMembership(member.userId, ts2.teamId);
@@ -67,13 +72,15 @@ export class TeamSubscription2Service {
6772
}
6873

6974
async cancelTeamMemberSubscription(ts2: TeamSubscription2, userId: string, teamMemberShipId: string, date: Date): Promise<void> {
75+
log.info(`cancelTeamMemberSubscription: ts2=${JSON.stringify(ts2)} userId=${userId} teamMemberShipId=${teamMemberShipId} date=${date.toISOString()}`);
7076
const { endDate } = Subscription.calculateCurrentPeriod(ts2.startDate, date);
7177
return this.accountingDb.transaction(async (db) => {
7278
await this.cancelSubscription(db, userId, ts2.planId, teamMemberShipId, endDate);
7379
});
7480
}
7581

7682
protected async cancelSubscription(db: AccountingDB, userId: string, planId: string, teamMembershipId: string, cancellationDate: string) {
83+
log.info(`cancelSubscription: userId=${userId} planId=${planId} teamMembershipId=${teamMembershipId} cancellationDate=${cancellationDate}`);
7784
const model = await this.loadSubscriptionModel(db, userId);
7885
const subscription = model.findSubscriptionByTeamMembershipId(teamMembershipId);
7986
if (!subscription) {

components/ee/payment-endpoint/src/chargebee/endpoint-controller.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class EndpointController {
6161
* @param res
6262
*/
6363
private async handleUpdateGitpodSubscription(req: express.Request, res: express.Response) {
64+
log.info('Chargebee handleUpdateGitpodSubscription!');
6465
if (!req.body || !req.body.event_type) {
6566
log.error('Received malformed event request from chargebee!');
6667
return;
@@ -70,7 +71,7 @@ export class EndpointController {
7071
const handled = await this.eventHandler.handle(req.body);
7172
if (!handled) {
7273
const payload = { chargebeeEventType: req.body.event_type, action: 'ignored' };
73-
log.debug(`Faithfully ignoring chargebee event of type: ${req.body.event_type}`, payload);
74+
log.warn(`Faithfully ignoring chargebee event of type: ${req.body.event_type}`, payload);
7475
}
7576
res.status(200).send();
7677
} catch (err) {

components/server/ee/src/workspace/gitpod-server-impl.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
14301430
const members = await this.teamDB.findMembersByTeam(teamSubscription.teamId);
14311431
const oldQuantity = teamSubscription.quantity;
14321432
const newQuantity = members.length;
1433+
log.info(`updateTeamSubscriptionQuantity: oldQuantity=${oldQuantity}, newQuantity=${newQuantity}`);
14331434
try {
14341435
if (oldQuantity < newQuantity) {
14351436
// Upgrade: Charge for it!
@@ -1451,6 +1452,9 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
14511452
const description = `Pro-rated upgrade from '${oldQuantity}' to '${newQuantity}' team members (${formatDate(
14521453
upgradeTimestamp,
14531454
)})`;
1455+
log.info(
1456+
`chargeForUpgrade: paymentReference=${teamSubscription.paymentReference}, currentTermRemainingRatio=${currentTermRemainingRatio}, diffInCents=${diffInCents}`,
1457+
);
14541458
await this.upgradeHelper.chargeForUpgrade(
14551459
"",
14561460
teamSubscription.paymentReference,
@@ -1464,6 +1468,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
14641468
end_of_term: false,
14651469
});
14661470
} catch (err) {
1471+
log.error("updateTeamSubscriptionQuantity failed", err);
14671472
if (chargebee.ApiError.is(err) && err.type === "payment") {
14681473
throw new ResponseError(ErrorCodes.PAYMENT_ERROR, `${err.api_error_code}: ${err.message}`);
14691474
}

0 commit comments

Comments
 (0)