diff --git a/src/main/java/com/postgraduate/domain/payment/application/usecase/PaymentManageUseCase.java b/src/main/java/com/postgraduate/domain/payment/application/usecase/PaymentManageUseCase.java index b2ee8c0f..a673e5a4 100644 --- a/src/main/java/com/postgraduate/domain/payment/application/usecase/PaymentManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/payment/application/usecase/PaymentManageUseCase.java @@ -101,8 +101,10 @@ public void refundPayBySenior(Senior senior, String orderId) { } public void refundPayByAdmin(User user, Long paymentId) { - if (user.getRole() != ADMIN) - throw new RefundFailException("NOT ADMIN"); + if (user.getRole() != ADMIN) { + log.error("Refund Fail : NOT ADMIN"); + throw new RefundFailException(); + } Payment payment = paymentGetService.byId(paymentId); log.info("ν™˜λΆˆ 진행 paymentId : {}", paymentId); refundPay(payment); @@ -154,9 +156,14 @@ private void refundProcess(CertificationResponse response, Payment payment) { .retrieve() .bodyToMono(RefundResponse.class) .block()) - .orElseThrow(() -> new RefundFailException("NPE")); - if (!refundResponse.PCD_PAY_RST().equals(SUCCESS.getName())) - throw new RefundFailException(refundResponse.PCD_PAY_CODE()); + .orElseThrow(() -> { + log.error("RefundFail : NPE"); + throw new RefundFailException(); + }); + if (!refundResponse.PCD_PAY_RST().equals(SUCCESS.getName())) { + log.error("Refund fail : {}", refundResponse.PCD_PAY_CODE()); + throw new RefundFailException(); + } } private Map getRefundRequestBody(CertificationResponse response, Payment payment) { diff --git a/src/main/java/com/postgraduate/domain/payment/exception/RefundFailException.java b/src/main/java/com/postgraduate/domain/payment/exception/RefundFailException.java index b132c135..f75b4207 100644 --- a/src/main/java/com/postgraduate/domain/payment/exception/RefundFailException.java +++ b/src/main/java/com/postgraduate/domain/payment/exception/RefundFailException.java @@ -3,11 +3,12 @@ import com.postgraduate.global.exception.ApplicationException; import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseMessage.FAIL_REFUND; +import static com.postgraduate.domain.payment.presentation.constant.PaymentResponseCode.REFUND_FAIL; public class RefundFailException extends ApplicationException { - public RefundFailException(String code) { - super(FAIL_REFUND.getMessage(), code); + public RefundFailException() { + super(FAIL_REFUND.getMessage(), REFUND_FAIL.getCode()); } } diff --git a/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java b/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java index a52b6990..952bdd0d 100644 --- a/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java +++ b/src/main/java/com/postgraduate/domain/payment/presentation/constant/PaymentResponseCode.java @@ -12,7 +12,8 @@ public enum PaymentResponseCode { PAYMENT_DELETE("PM203"), PAYMENT_NOT_FOUND("EX600"), - PAYMENT_FAIL("EX601"); + PAYMENT_FAIL("EX601"), + REFUND_FAIL("EX602"); private final String code; }