Files
myeasycms-v2/packages/billing/gateway/src/server/services/billing-gateway/billing-gateway-factory.service.ts
gbuomprisco 23154c366d Remove Cloudflare mailer implementation, update dependencies and updated code to reflect stricter EsLint settings
Deleted CloudflareMailer class and its implementation from the mailers package. Updated dependencies across various packages, converting certain imports to use `type` only, and bumped versions for packages like `react-query`, `lucide-react`, and others.
2024-08-01 14:57:55 +02:00

38 lines
915 B
TypeScript

import 'server-only';
import { z } from 'zod';
import {
type BillingProviderSchema,
BillingStrategyProviderService,
} from '@kit/billing';
export class BillingGatewayFactoryService {
static async GetProviderStrategy(
provider: z.infer<typeof BillingProviderSchema>,
): Promise<BillingStrategyProviderService> {
switch (provider) {
case 'stripe': {
const { StripeBillingStrategyService } = await import('@kit/stripe');
return new StripeBillingStrategyService();
}
case 'lemon-squeezy': {
const { LemonSqueezyBillingStrategyService } = await import(
'@kit/lemon-squeezy'
);
return new LemonSqueezyBillingStrategyService();
}
case 'paddle': {
throw new Error('Paddle is not supported yet');
}
default:
throw new Error(`Unsupported billing provider: ${provider as string}`);
}
}
}