Skip to content

Commit 70a42ae

Browse files
author
Laurie T. Malau
committed
[usage] Use createStripeSubscription behind feature flag
1 parent 5e09a4d commit 70a42ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import { UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb"
119119
import { BillingServiceClient, BillingServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/billing.pb";
120120
import { IncrementalPrebuildsService } from "../prebuilds/incremental-prebuilds-service";
121121
import { ConfigProvider } from "../../../src/workspace/config-provider";
122+
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
122123

123124
@injectable()
124125
export class GitpodServerEEImpl extends GitpodServerImpl {
@@ -2177,6 +2178,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
21772178

21782179
const user = this.checkAndBlockUser("subscribeToStripe");
21792180

2181+
let team: Team | undefined;
21802182
try {
21812183
if (attrId.kind === "team") {
21822184
const team = await this.guardTeamOperation(attrId.teamId, "update");
@@ -2189,6 +2191,18 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
21892191
throw new Error(`No Stripe customer profile for '${attributionId}'`);
21902192
}
21912193

2194+
const createStripeSubscriptionOnUsage = await getExperimentsClientForBackend().getValueAsync(
2195+
"createStripeSubscriptionOnUsage",
2196+
false,
2197+
{
2198+
user: user,
2199+
},
2200+
);
2201+
2202+
if (createStripeSubscriptionOnUsage) {
2203+
await this.billingService.createStripeSubscription({ attributionId, setupIntentId, usageLimit });
2204+
}
2205+
21922206
await this.stripeService.setDefaultPaymentMethodForCustomer(customerId, setupIntentId);
21932207
await this.stripeService.createSubscriptionForCustomer(customerId, attributionId);
21942208

0 commit comments

Comments
 (0)