카드 매입 승인 경로 Spring Boot 3 전환 (ACX-E2E-1785394564819)
Some checks are pending
Verify / source-contract (push) Waiting to run
Some checks are pending
Verify / source-contract (push) Waiting to run
This commit is contained in:
parent
6221af0ab6
commit
ad8fb595d0
1 changed files with 43 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.acquirex.approval.service;
|
||||||
|
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain;
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Request;
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Response;
|
||||||
|
import com.acquirex.approval.domain.ApprovalDomain.Status;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ApprovalService {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ApprovalService.class);
|
||||||
|
|
||||||
|
public Response processApproval(Request request) {
|
||||||
|
log.info("매입 승인 요청: transactionId={}, merchantId={}, amount={}",
|
||||||
|
request.getTransactionId(), request.getMerchantId(), request.getAmount());
|
||||||
|
|
||||||
|
if (!validate(request)) {
|
||||||
|
return Response.rejected(request.getTransactionId(), "유효성 검증 실패");
|
||||||
|
}
|
||||||
|
|
||||||
|
String approvalId = ApprovalDomain.generateApprovalId();
|
||||||
|
Response response = Response.success(approvalId, request.getTransactionId());
|
||||||
|
log.info("매입 승인 완료: approvalId={}, status={}", approvalId, response.getStatus());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Response cancelApproval(String approvalId) {
|
||||||
|
log.info("매입 승인 취소: approvalId={}", approvalId);
|
||||||
|
if (approvalId == null || approvalId.isBlank()) {
|
||||||
|
return Response.rejected(null, "승인 ID가 유효하지 않습니다");
|
||||||
|
}
|
||||||
|
return Response.cancelled(approvalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validate(Request request) {
|
||||||
|
if (request == null) return false;
|
||||||
|
if (request.getAmount() == null || request.getAmount().signum() <= 0) return false;
|
||||||
|
if (request.getCardNumber() == null || request.getCardNumber().length() < 13) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue