38 add billing webhook endpoint (#4158)
* Add self billing feature flag * Add two core tables for billing * Remove useless imports * Remove graphql decorators * Rename subscriptionProduct table * WIP: Add stripe config * Add controller to get product prices * Add billing service * Remove unecessary package * Simplify stripe service * Code review returns * Use nestjs param * Rename subscription to basePlan * Rename env variable * Add checkout endpoint * Remove resolver * Merge controllers * Fix security issue * Handle missing url error * Add workspaceId in checkout metadata * Add BILLING_STRIPE_WEBHOOK_SECRET env variable * WIP: add webhook endpoint * Fix body parser * Create Billing Subscription on payment success * Set subscriptionStatus active on webhook * Add useful log --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -32,6 +32,23 @@ export class EnvironmentService {
|
||||
return this.configService.get<string>('BILLING_PLAN_REQUIRED_LINK') ?? '';
|
||||
}
|
||||
|
||||
getBillingStripeBasePlanProductId(): string {
|
||||
return (
|
||||
this.configService.get<string>('BILLING_STRIPE_BASE_PLAN_PRODUCT_ID') ??
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
getBillingStripeApiKey(): string {
|
||||
return this.configService.get<string>('BILLING_STRIPE_API_KEY') ?? '';
|
||||
}
|
||||
|
||||
getBillingStripeWebhookSecret(): string {
|
||||
return (
|
||||
this.configService.get<string>('BILLING_STRIPE_WEBHOOK_SECRET') ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
isTelemetryEnabled(): boolean {
|
||||
return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true;
|
||||
}
|
||||
@ -305,15 +322,4 @@ export class EnvironmentService {
|
||||
this.configService.get<number>('MUTATION_MAXIMUM_RECORD_AFFECTED') ?? 100
|
||||
);
|
||||
}
|
||||
|
||||
getBillingStripeBasePlanProductId(): string {
|
||||
return (
|
||||
this.configService.get<string>('BILLING_STRIPE_BASE_PLAN_PRODUCT_ID') ??
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
getStripeApiKey(): string {
|
||||
return this.configService.get<string>('STRIPE_API_KEY') ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,17 +44,21 @@ export class EnvironmentVariables {
|
||||
@IsBoolean()
|
||||
IS_BILLING_ENABLED?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
BILLING_URL?: string;
|
||||
@ValidateIf((env) => env.IS_BILLING_ENABLED === true)
|
||||
BILLING_PLAN_REQUIRED_LINK?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ValidateIf((env) => env.IS_BILLING_ENABLED === true)
|
||||
BILLING_STRIPE_BASE_PLAN_PRODUCT_ID?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
STRIPE_API_KEY?: string;
|
||||
@ValidateIf((env) => env.IS_BILLING_ENABLED === true)
|
||||
BILLING_STRIPE_API_KEY?: string;
|
||||
|
||||
@IsString()
|
||||
@ValidateIf((env) => env.IS_BILLING_ENABLED === true)
|
||||
BILLING_STRIPE_WEBHOOK_SECRET?: string;
|
||||
|
||||
@CastToBoolean()
|
||||
@IsOptional()
|
||||
|
||||
Reference in New Issue
Block a user