@@ -2020,13 +2020,6 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
2020
2020
} ) ;
2021
2021
}
2022
2022
2023
- protected async ensureIsUsageBasedFeatureFlagEnabled ( user : User ) : Promise < void > {
2024
- const isUsageBasedBillingEnabled = await this . isUsageBasedFeatureFlagEnabled ( user ) ;
2025
- if ( ! isUsageBasedBillingEnabled ) {
2026
- throw new ResponseError ( ErrorCodes . PERMISSION_DENIED , "not allowed" ) ;
2027
- }
2028
- }
2029
-
2030
2023
protected async ensureChargebeeApiIsAllowed ( sub : { user ?: User ; team ?: Team } ) : Promise < void > {
2031
2024
await this . ensureBillingMode ( sub , ( m ) => m . mode === "chargebee" ) ;
2032
2025
}
@@ -2281,7 +2274,16 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
2281
2274
await this . guardCostCenterAccess ( ctx , user . id , attrId , "update" ) ;
2282
2275
2283
2276
const response = await this . usageService . getCostCenter ( { attributionId } ) ;
2284
- if ( response ?. costCenter ?. billingStrategy !== CostCenter_BillingStrategy . BILLING_STRATEGY_STRIPE ) {
2277
+
2278
+ // backward compatibility for cost centers that were created before introduction of BillingStrategy
2279
+ if ( response . costCenter ) {
2280
+ const stripeSubscriptionId = await this . findStripeSubscriptionId ( ctx , attributionId ) ;
2281
+ if ( stripeSubscriptionId != undefined ) {
2282
+ response . costCenter . billingStrategy = CostCenter_BillingStrategy . BILLING_STRATEGY_STRIPE ;
2283
+ }
2284
+ }
2285
+
2286
+ if ( response . costCenter ?. billingStrategy !== CostCenter_BillingStrategy . BILLING_STRATEGY_STRIPE ) {
2285
2287
throw new ResponseError (
2286
2288
ErrorCodes . BAD_REQUEST ,
2287
2289
`Setting a usage limit is not valid for non-Stripe billing strategies` ,
@@ -2291,8 +2293,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
2291
2293
costCenter : {
2292
2294
attributionId,
2293
2295
spendingLimit : usageLimit ,
2294
- billingStrategy :
2295
- response ?. costCenter ?. billingStrategy || CostCenter_BillingStrategy . BILLING_STRATEGY_OTHER ,
2296
+ billingStrategy : CostCenter_BillingStrategy . BILLING_STRATEGY_OTHER ,
2296
2297
} ,
2297
2298
} ) ;
2298
2299
0 commit comments