Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
jankeromnes committed Aug 31, 2022
1 parent 0734efb commit 913cf9f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/server/ee/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2054,15 +2054,21 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
}

async createOrUpdateStripeCustomerForTeam(ctx: TraceContext, teamId: string, currency: string): Promise<void> {
log.warn(`XXXX: createOrUpdateStripeCustomerForTeam ${teamId} ${currency}`);
const user = this.checkAndBlockUser("createOrUpdateStripeCustomerForTeam");
const team = await this.guardTeamOperation(teamId, "update");
await this.ensureStripeApiIsAllowed({ team });
try {
log.warn("XXXX: looking for existing customer");
let customer = await this.stripeService.findCustomerByTeamId(team!.id);
if (!customer) {
log.warn("XXXX: no customer, creating one...");
customer = await this.stripeService.createCustomerForTeam(user, team!);
log.warn("XXXX: created");
}
log.warn("XXXX: setting the currency...");
await this.stripeService.setPreferredCurrencyForCustomer(customer, currency);
log.warn("XXXX: currency set");
} catch (error) {
log.error(`Failed to update Stripe customer profile for team '${teamId}'`, error);
throw new ResponseError(
Expand All @@ -2074,15 +2080,19 @@ export class GitpodServerEEImpl extends GitpodServerImpl {

protected defaultSpendingLimit = 100;
async subscribeTeamToStripe(ctx: TraceContext, teamId: string, setupIntentId: string): Promise<void> {
log.warn(`XXXX: subscribeTeamToStripe ${teamId}`);
this.checkAndBlockUser("subscribeUserToStripe");
const team = await this.guardTeamOperation(teamId, "update");
await this.ensureStripeApiIsAllowed({ team });
try {
log.warn("XXXX: sub looking for existing customer");
let customer = await this.stripeService.findCustomerByTeamId(team!.id);
if (!customer) {
throw new Error(`No Stripe customer profile for team '${team.id}'`);
}
log.warn("XXXX: sub setting default payment method");
await this.stripeService.setDefaultPaymentMethodForCustomer(customer, setupIntentId);
log.warn("XXXX: sub creating subscription");
await this.stripeService.createSubscriptionForCustomer(customer);

const attributionId = AttributionId.render({ kind: "team", teamId });
Expand Down

0 comments on commit 913cf9f

Please sign in to comment.