Skip to content

Commit

Permalink
HotFix : 환불 실패 예외 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ywj9811 committed Nov 5, 2024
1 parent 341be2a commit c2b186c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<String, String> getRefundRequestBody(CertificationResponse response, Payment payment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit c2b186c

Please sign in to comment.