@@ -76,7 +76,7 @@ import {
76
76
TeamSubscriptionSlot ,
77
77
TeamSubscriptionSlotResolved ,
78
78
} from "@gitpod/gitpod-protocol/lib/team-subscription-protocol" ;
79
- import { Plans } from "@gitpod/gitpod-protocol/lib/plans" ;
79
+ import { Currency , Plans } from "@gitpod/gitpod-protocol/lib/plans" ;
80
80
import * as pThrottle from "p-throttle" ;
81
81
import { formatDate } from "@gitpod/gitpod-protocol/lib/util/date-time" ;
82
82
import { FindUserByIdentityStrResult , UserService } from "../../../src/user/user-service" ;
@@ -1892,14 +1892,19 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
1892
1892
}
1893
1893
}
1894
1894
1895
- async subscribeTeamToStripe ( ctx : TraceContext , teamId : string , setupIntentId : string ) : Promise < void > {
1895
+ async subscribeTeamToStripe (
1896
+ ctx : TraceContext ,
1897
+ teamId : string ,
1898
+ setupIntentId : string ,
1899
+ currency : Currency ,
1900
+ ) : Promise < void > {
1896
1901
const user = this . checkAndBlockUser ( "subscribeUserToStripe" ) ;
1897
1902
await this . ensureIsUsageBasedFeatureFlagEnabled ( user ) ;
1898
1903
await this . guardTeamOperation ( teamId , "update" ) ;
1899
1904
const team = await this . teamDB . findTeamById ( teamId ) ;
1900
1905
try {
1901
- await this . stripeService . createCustomerForTeam ( user , team ! , setupIntentId ) ;
1902
- // TODO(janx): Create a Stripe usage-based Subscription for the customer
1906
+ const customer = await this . stripeService . createCustomerForTeam ( user , team ! , setupIntentId ) ;
1907
+ await this . stripeService . createSubscriptionForCustomer ( customer . id , currency ) ;
1903
1908
} catch ( error ) {
1904
1909
log . error ( `Failed to subscribe team '${ teamId } ' to Stripe` , error ) ;
1905
1910
throw new ResponseError ( ErrorCodes . INTERNAL_SERVER_ERROR , `Failed to subscribe team '${ teamId } ' to Stripe` ) ;
0 commit comments