import { IsDecimal, IsEnum, IsOptional, IsString, IsUUID } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { BookingPaymentMethod } from '@prisma/client';

export class CreatePaymentDto {
  @ApiProperty({ description: 'Booking record ID' })
  @IsUUID()
  recordId: string;

  @ApiProperty({ example: '3500.00' })
  @IsDecimal()
  amount: string;

  @ApiProperty({ enum: BookingPaymentMethod, example: 'CARD' })
  @IsEnum(BookingPaymentMethod)
  method: BookingPaymentMethod;

  @ApiPropertyOptional({ description: 'External payment provider ID' })
  @IsOptional()
  @IsString()
  externalId?: string;
}

export class PaymentCallbackDto {
  @ApiProperty({ description: 'External payment ID from provider' })
  @IsString()
  externalId: string;

  @ApiProperty({ enum: ['success', 'fail'], example: 'success' })
  @IsString()
  status: 'success' | 'fail';

  @ApiPropertyOptional({ description: 'Provider-specific metadata' })
  @IsOptional()
  metadata?: Record<string, any>;
}

export class RefundPaymentDto {
  @ApiPropertyOptional({
    example: '1000.00',
    description: 'Partial refund amount. If omitted, full refund.',
  })
  @IsOptional()
  @IsDecimal()
  amount?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  reason?: string;
}
