Enforce config for billing; updated packages
This commit is contained in:
@@ -5,6 +5,8 @@ import { redirect } from 'next/navigation';
|
||||
import { enhanceAction } from '@kit/next/actions';
|
||||
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
||||
|
||||
import featureFlagsConfig from '~/config/feature-flags.config';
|
||||
|
||||
// billing imports
|
||||
import {
|
||||
TeamBillingPortalSchema,
|
||||
@@ -12,12 +14,22 @@ import {
|
||||
} from '../schema/team-billing.schema';
|
||||
import { createTeamBillingService } from './team-billing.service';
|
||||
|
||||
/**
|
||||
* @name enabled
|
||||
* @description This feature flag is used to enable or disable team account billing.
|
||||
*/
|
||||
const enabled = featureFlagsConfig.enableTeamAccountBilling;
|
||||
|
||||
/**
|
||||
* @name createTeamAccountCheckoutSession
|
||||
* @description Creates a checkout session for a team account.
|
||||
*/
|
||||
export const createTeamAccountCheckoutSession = enhanceAction(
|
||||
(data) => {
|
||||
if (!enabled) {
|
||||
throw new Error('Team account billing is not enabled');
|
||||
}
|
||||
|
||||
const client = getSupabaseServerActionClient();
|
||||
const service = createTeamBillingService(client);
|
||||
|
||||
@@ -35,6 +47,10 @@ export const createTeamAccountCheckoutSession = enhanceAction(
|
||||
*/
|
||||
export const createBillingPortalSession = enhanceAction(
|
||||
async (formData: FormData) => {
|
||||
if (!enabled) {
|
||||
throw new Error('Team account billing is not enabled');
|
||||
}
|
||||
|
||||
const params = TeamBillingPortalSchema.parse(Object.fromEntries(formData));
|
||||
|
||||
const client = getSupabaseServerActionClient();
|
||||
|
||||
Reference in New Issue
Block a user