import { Injectable } from '@nestjs/common';
import { PaymentGateway } from './interfaces/payment-gateway.interface';
import { PaynowGateway } from './gateways/paynow.gateway';
import { PesePayGateway } from './gateways/pesepay.gateway';
import { MockGateway } from './gateways/mock.gateway';
import { PrismaService } from '../../prisma/prisma.service';

@Injectable()
export class PaymentFactory {
  constructor(private readonly prisma: PrismaService) {}

  getGateway(gatewayType: string, credentials?: Record<string, any>): PaymentGateway {
    if (!credentials) {
      return new MockGateway(this.prisma);
    }

    switch (gatewayType.toLowerCase()) {
      case 'paynow':
        return new PaynowGateway(credentials);
      case 'pesepay':
        return new PesePayGateway(credentials);
      case 'mock':
      default:
        return new MockGateway(this.prisma);
    }
  }
}
