카드 매입 승인 경로 Spring Boot 3 전환 #6
1 changed files with 102 additions and 0 deletions
102
src/main/java/com/acquirex/approval/dto/ApprovalDto.java
Normal file
102
src/main/java/com/acquirex/approval/dto/ApprovalDto.java
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
package com.acquirex.approval.dto;
|
||||
|
||||
import com.acquirex.approval.domain.ApprovalRequest.ApprovalStatus;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ApprovalDto {
|
||||
|
||||
public static class Request {
|
||||
@NotBlank(message = "Card number is required")
|
||||
@Pattern(regexp = "^\\d{13,19}$", message = "Invalid card number format")
|
||||
private String cardNumber;
|
||||
|
||||
@NotBlank(message = "Merchant ID is required")
|
||||
@Pattern(regexp = "^[A-Z0-9]{8,15}$", message = "Invalid merchant ID format")
|
||||
private String merchantId;
|
||||
|
||||
@NotNull(message = "Amount is required")
|
||||
@Positive(message = "Amount must be positive")
|
||||
private BigDecimal amount;
|
||||
|
||||
@NotBlank(message = "Currency is required")
|
||||
@Pattern(regexp = "^[A-Z]{3}$", message = "Invalid currency code")
|
||||
private String currency;
|
||||
|
||||
public Request() {}
|
||||
|
||||
public Request(String cardNumber, String merchantId, BigDecimal amount, String currency) {
|
||||
this.cardNumber = cardNumber;
|
||||
this.merchantId = merchantId;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getCardNumber() { return cardNumber; }
|
||||
public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; }
|
||||
public String getMerchantId() { return merchantId; }
|
||||
public void setMerchantId(String merchantId) { this.merchantId = merchantId; }
|
||||
public BigDecimal getAmount() { return amount; }
|
||||
public void setAmount(BigDecimal amount) { this.amount = amount; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
}
|
||||
|
||||
public static class Response {
|
||||
private Long requestId;
|
||||
private String approvalCode;
|
||||
private ApprovalStatus status;
|
||||
private BigDecimal amount;
|
||||
private String currency;
|
||||
private String message;
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
public Response() {
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public Response(Long requestId, ApprovalStatus status, String message) {
|
||||
this.requestId = requestId;
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public static Response approved(Long requestId, String approvalCode, BigDecimal amount, String currency) {
|
||||
Response r = new Response();
|
||||
r.requestId = requestId;
|
||||
r.approvalCode = approvalCode;
|
||||
r.status = ApprovalStatus.APPROVED;
|
||||
r.amount = amount;
|
||||
r.currency = currency;
|
||||
r.message = "Approval successful";
|
||||
return r;
|
||||
}
|
||||
|
||||
public static Response declined(Long requestId, String reason) {
|
||||
Response r = new Response();
|
||||
r.requestId = requestId;
|
||||
r.status = ApprovalStatus.DECLINED;
|
||||
r.message = reason;
|
||||
return r;
|
||||
}
|
||||
|
||||
public Long getRequestId() { return requestId; }
|
||||
public void setRequestId(Long requestId) { this.requestId = requestId; }
|
||||
public String getApprovalCode() { return approvalCode; }
|
||||
public void setApprovalCode(String approvalCode) { this.approvalCode = approvalCode; }
|
||||
public ApprovalStatus getStatus() { return status; }
|
||||
public void setStatus(ApprovalStatus status) { this.status = status; }
|
||||
public BigDecimal getAmount() { return amount; }
|
||||
public void setAmount(BigDecimal amount) { this.amount = amount; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
public String getMessage() { return message; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public LocalDateTime getTimestamp() { return timestamp; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue