using System.Text.Json.Serialization;

namespace EasyPaySample.Models
{
    // 거래 등록 요청
    public class TradeWebPayRequest
    {
        public string MallId { get; set; } = string.Empty;
        public string ShopOrderNo { get; set; } = string.Empty;
        public string Amount { get; set; } = string.Empty;
        public string PayMethodTypeCode { get; set; } = string.Empty;
        public string Currency { get; set; } = "00";
        public string ReturnUrl { get; set; } = string.Empty;
        public string DeviceTypeCode { get; set; } = "pc";
        public string ClientTypeCode { get; set; } = "00";
        public OrderInfo OrderInfo { get; set; } = new();
    }

    public class OrderInfo
    {
        public string GoodsName { get; set; } = string.Empty;
    }

    // 통계적 응답 구조 (성공/실패 공통)
    public class EasyPayResponse
    {
        public string ResCd { get; set; } = string.Empty;
        public string ResMsg { get; set; } = string.Empty;
        
        // 결제 등록 시 응답
        public string? AuthPageUrl { get; set; }
        public string? PgCno { get; set; }
        
        // 결제 승인 시 응답
        public string? ShopTransactionId { get; set; }
        public string? ShopOrderNo { get; set; }
        public string? TransactionDate { get; set; }
        public decimal? Amount { get; set; }
        public string? PayMethodTypeCode { get; set; }
        
        // 가상계좌 및 상세 정보 (중첩 구조 대응)
        public PaymentInfo? PaymentInfo { get; set; }
        
        // 취소 시 응답
        public string? OriPgCno { get; set; }
        public string? CancelPgCno { get; set; }
        public decimal? CancelAmount { get; set; }
        public decimal? RemainAmount { get; set; }
    }

    public class PaymentInfo
    {
        public string? PayMethodTypeCode { get; set; }
        public VirtualAccountInfo? VirtualAccountInfo { get; set; }
    }

    public class VirtualAccountInfo
    {
        public string? BankCode { get; set; }
        public string? BankName { get; set; }
        public string? AccountNo { get; set; }
        public string? DepositName { get; set; }
        public string? ExpiryDate { get; set; }
    }

    // 승인 요청
    public class ApprovalRequest
    {
        public string MallId { get; set; } = string.Empty;
        public string ShopTransactionId { get; set; } = string.Empty;
        public string AuthorizationId { get; set; } = string.Empty;
        public string ShopOrderNo { get; set; } = string.Empty;
        public string ApprovalReqDate { get; set; } = string.Empty;
    }

    // 취소 요청
    public class ReviseRequest
    {
        public string MallId { get; set; } = string.Empty;
        public string ShopTransactionId { get; set; } = string.Empty;
        public string CancelReqDate { get; set; } = string.Empty;
        public string PgCno { get; set; } = string.Empty;
        public string ReviseTypeCode { get; set; } = "40"; // 40: 전체취소
        public string MsgAuthValue { get; set; } = string.Empty;
    }
}
