import { ApiProperty } from "@nestjs/swagger";
import { PaymentAttemptStatus, PaymentMethod, Provider } from "@prisma/client";

export class PaymentAttemptDto {
  @ApiProperty({ example: "pa_01HXYZABCDEFGHJKMNPQRSTV" })
  id!: string;

  @ApiProperty({ example: "pi_01HXYZABCDEFGHJKMNPQRSTV" })
  intentId!: string;

  @ApiProperty({ enum: Provider, example: Provider.dlocal })
  provider!: Provider;

  @ApiProperty({ required: false, nullable: true, example: "D-12345-67890" })
  providerPaymentId!: string | null;

  @ApiProperty({ enum: PaymentMethod, example: PaymentMethod.card })
  method!: PaymentMethod;

  @ApiProperty({
    required: false,
    nullable: true,
    example: "18",
    description: "Código del medio en el provider (ej. platformId de Dpago) usado en este intento.",
  })
  platformId!: string | null;

  @ApiProperty({ enum: PaymentAttemptStatus, example: PaymentAttemptStatus.processing })
  status!: PaymentAttemptStatus;

  @ApiProperty({ required: false, nullable: true, example: "200" })
  responseCode!: string | null;

  @ApiProperty({ required: false, nullable: true, example: "Pending capture" })
  responseMessage!: string | null;

  @ApiProperty({
    required: false,
    nullable: true,
    example: "https://pago.dpago.com/link?code=pl_864058fc4be979a2",
    description:
      "URL externa para completar/compartir el pago: hosted checkout del provider, link de pago " +
      "nativo (ej. Dpago `/links`) o página de QR. Redirigí o compartí según el caso.",
  })
  redirectUrl?: string | null;

  @ApiProperty({
    required: false,
    nullable: true,
    type: String,
    example: "00020101021220265898125204739953036005406100.05802PY5907UPAY...6304ABCD",
    description:
      "Payload EMV del QR a renderizar inline (ej. `qrInformation` de Dpago) cuando el medio " +
      "devuelve QR en vez de redirección. Generá el QR a partir de este string. `null` si no aplica.",
  })
  qr?: unknown | null;

  @ApiProperty({ example: "2026-06-07T14:30:00.000Z" })
  createdAt!: Date;
}
