platform-codebase/features/payments/backend-api/payments.module.ts

58 lines
1.9 KiB
TypeScript
Executable file

import { DomainEventsModule } from '@lilith/domain-events'
import { BullModule } from '@nestjs/bullmq'
import { Module } from '@nestjs/common'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { TypeOrmModule } from '@nestjs/typeorm'
import { GiftCardsModule } from './gift-cards/gift-cards.module'
import { NOWPaymentsModule } from './nowpayments/nowpayments.module'
import { ProvidersModule } from './providers/providers.module'
import { SegpayModule } from './segpay/segpay.module'
import { getDatabaseConfig } from './src/database/database.config'
import { WebhooksModule } from './webhooks/webhooks.module'
/**
* Payments Module
*
* Main module for payment processing functionality.
* Includes:
* - Payment providers (Segpay, NOWPayments)
* - Payment provider factory for provider selection
* - Webhook handling
* - Gift card purchases
* - Domain events for funnel tracking
*/
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
envFilePath: ['.env.local', '.env'],
}),
// Database configuration
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: getDatabaseConfig,
inject: [ConfigService],
}),
// Queue infrastructure for domain events
BullModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
connection: {
host: configService.get('DATABASE_REDIS_HOST', 'localhost'),
port: configService.get<number>('DATABASE_REDIS_PORT', 6379),
password: configService.get('DATABASE_REDIS_PASSWORD'),
},
}),
inject: [ConfigService],
}),
DomainEventsModule.forFeature(),
SegpayModule,
NOWPaymentsModule,
ProvidersModule,
WebhooksModule,
GiftCardsModule,
],
exports: [SegpayModule, NOWPaymentsModule, ProvidersModule, GiftCardsModule],
})
export class PaymentsModule {}