-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAPHY-140 refactor: 결제 기능 리펙토링 #89
Conversation
* refactor: Pay 엔티티 필드 수정 * feat: 결제 준비, 결제 완료 DTO 생성
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
Prepare로 검증하고 Complete로 실제 결제를 진행하는 구조군요!
|
||
// 물품 금액과 결제 금액이 같은지 검증 | ||
if (!iamportPayment.getAmount().equals(item.getPrice())) { | ||
BigDecimal calculatedAmount = item.getPrice().multiply(BigDecimal.valueOf(request.getQuantity())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 BigDecimal이라 직접 안곱하고 multiply를 쓰는거군요
하나 배워갑니다 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이륙 허가요 슈우우우우우우우우우우ㅜ우ㅜㅜㅜㅜㅜㅜ우우웅~
@@ -34,56 +37,54 @@ public class PayService { | |||
private final IamportClient iamportClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 ItemRepository
-> ItemRepository<Item>
으로 바꾸면 밑에 로직에서 Optional을 안 써도 될 것 같습니다!
if (item.getStock() < request.getQuantity()) { | ||
throw SaphyException.from(ITEM_OUT_OF_STOCK); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어 이거 제가 1시간 전에 PR 올린 거에 들어있는 거긴 한데
item 엔티티 안에 재고에 따라 주문할 수 있는지 없는지 boolean canOrder() 메서드로 구현해놔서 나중에 바꿔도 될 것 같습니다!
try { | ||
// PortOne 결제 확인 | ||
iamportResponse = iamportClient.paymentByImpUid(request.getImpUid()); | ||
if (payResponse.getResponse().getAmount().equals(pay.getAmount())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 if문 조건은 뭔가 private 메서드로 뽑을 수 있으면 훨씬 깔끔할 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~!
.orElseThrow(() -> SaphyException.from(PAY_NOT_FOUND)); | ||
return new PayResponse(pay.getId(), pay.getTransactionId(), pay.getStatus()); | ||
private String generateMerchantUid() { | ||
return "ORD-" + UUID.randomUUID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UUID 앞에 ORD를 붙여서 직관적이라 좋은 거 같아요! 예전에 재우님 코드 리뷰에 있었던 내용을 반영한 건가요~?
if (item.getStock() < request.getQuantity()) { | ||
throw SaphyException.from(ITEM_OUT_OF_STOCK); | ||
} | ||
|
||
// 물품 금액과 결제 금액이 같은지 검증 | ||
if (!iamportPayment.getAmount().equals(item.getPrice())) { | ||
BigDecimal calculatedAmount = item.getPrice().multiply(BigDecimal.valueOf(request.getQuantity())); | ||
if (!calculatedAmount.equals(request.getAmount())) { | ||
throw SaphyException.from(PAY_PRICE_MISMATCH); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나중에 이런 조건문들은 private 메서드로 따로 빼서 리팩토링 하면 더 코드가 깔끔해질 거 같아요!
📄 Summary
🕰️ Actual Time of Completion
🙋🏻 More