File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -116,16 +116,15 @@ export class StripeService {
116
116
}
117
117
118
118
async createSubscriptionForCustomer ( customerId : string , currency : Currency ) : Promise < void > {
119
- // FIXME(janx): Use configmap.
120
- const prices = {
121
- EUR : "price_1LAE0AGadRXm50o3xjegX0Kd" ,
122
- USD : "price_1LAE0AGadRXm50o3rKoktPiJ" ,
123
- } ;
119
+ const priceId = this . config ?. stripeConfig ?. usageProductPriceIds [ currency ] ;
120
+ if ( ! priceId ) {
121
+ throw new Error ( `No Stripe Price ID configured for currency '${ currency } '` ) ;
122
+ }
124
123
const startOfNextMonth = new Date ( new Date ( ) . toISOString ( ) . slice ( 0 , 7 ) + "-01" ) ; // First day of this month (YYYY-MM-01)
125
124
startOfNextMonth . setMonth ( startOfNextMonth . getMonth ( ) + 1 ) ; // Add one month
126
125
await this . getStripe ( ) . subscriptions . create ( {
127
126
customer : customerId ,
128
- items : [ { price : prices [ currency ] } ] ,
127
+ items : [ { price : priceId } ] ,
129
128
billing_cycle_anchor : Math . round ( startOfNextMonth . getTime ( ) / 1000 ) ,
130
129
} ) ;
131
130
}
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export type Config = Omit<
26
26
workspaceDefaults : WorkspaceDefaults ;
27
27
chargebeeProviderOptions ?: ChargebeeProviderOptions ;
28
28
stripeSecrets ?: { publishableKey : string ; secretKey : string } ;
29
+ stripeConfig ?: { usageProductPriceIds : { EUR : string ; USD : string } } ;
29
30
builtinAuthProvidersConfigured : boolean ;
30
31
blockedRepositories : { urlRegExp : RegExp ; blockUser : boolean } [ ] ;
31
32
inactivityPeriodForRepos ?: number ;
You can’t perform that action at this time.
0 commit comments