Skip to content

Commit

Permalink
feat: 결제 완료시 상품 상태에 따라서 결제 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
Su-daa committed Jan 24, 2024
1 parent e1e57cf commit 5dbdd3d
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,26 +150,31 @@ public PaymentResponse savePayment(PaymentRequest request, PrincipalDetails prin

Optional<Nego> nego = negoRepository.findFirstByUser_IdAndProduct_IdOrderByCreatedAtDesc(userId, product.getId());

//네고가 존재할때, 결제 대기중 -> 타임아웃 경우
if (nego.isPresent()) {
//상품상태 = 예약중
if (product.getProductStatus() == ProductStatus.RESERVED) {
if (nego.isEmpty()) {
cancelPayment(request.getImpUid());
return PaymentResponse.failed();
}
if (nego.get().getStatus() != order.getNegoStatus()) {
cancelPayment(request.getImpUid());
return PaymentResponse.timeOver();
return PaymentResponse.failed();
}
if (product.getProductStatus() == ProductStatus.RESERVED) {
if (nego.get().getStatus() != NegotiationStatus.PAYMENT_PENDING) {
cancelPayment(request.getImpUid());
return PaymentResponse.failed();
}
if (nego.get().getStatus() != NegotiationStatus.PAYMENT_PENDING) {
cancelPayment(request.getImpUid());
return PaymentResponse.failed();
}
nego.get().completed();
}

if (product.getProductStatus() == ProductStatus.RESERVED) {
if (nego.isEmpty()) {
//상품상태 = 판매중
//네고 내역 존재할 때
if (nego.isPresent()) {
//네고 상태: 결제 대기중 -> 타임아웃 => 결제 결과 타임오버
if (nego.get().getStatus() != order.getNegoStatus()) {
cancelPayment(request.getImpUid());
return PaymentResponse.failed();
return PaymentResponse.timeOver();
}
nego.get().transferPending();
}

order.waitTransfer();
Expand Down

0 comments on commit 5dbdd3d

Please sign in to comment.