Skip to content

Commit ca2970c

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

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 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 {
@@ -2189,8 +2190,20 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
21892190
throw new Error(`No Stripe customer profile for '${attributionId}'`);
21902191
}
21912192

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

21952208
// Creating a cost center for this customer
21962209
const { costCenter } = await this.usageService.setCostCenter({

0 commit comments

Comments
 (0)