@@ -84,7 +84,7 @@ public OrderPrepareResponseDto prepareOrder(Long memberId, OrderPrepareRequestDt
8484 Coupon coupon = validateCoupon (request .appliedCouponId (), memberId , cartProducts );
8585 validatePointUsage (request .point (), member );
8686
87- int totalAmount = 0 ;
87+ int totalAmount ;
8888 if (request .orderType () == OrderType .PERSONAL ) {
8989 totalAmount = cartProducts .stream ()
9090 .mapToInt (cp ->
@@ -156,7 +156,7 @@ public OrderApproveResponseDto approveOrder(Long memberId, OrderApproveRequestDt
156156 .orElseThrow (() -> new BadRequestException (ErrorStatus .ORDER_NOT_FOUND ));
157157
158158 // 결제 금액과 결제해야 할 금액이 동일한지 확인
159- if (!request .paidAmount ().equals (order .getPaidAmount ())) {
159+ if (!request .paidAmount ().equals (order .getTotalAmount ())) {
160160 throw new GeneralException (ErrorStatus .PAYMENT_AMOUNT_MISMATCH );
161161 }
162162
@@ -170,7 +170,7 @@ public OrderApproveResponseDto approveOrder(Long memberId, OrderApproveRequestDt
170170 HttpEntity <Map <String , Object >> entity = new HttpEntity <>(body , getHeaders ());
171171 ResponseEntity <PaymentResponseDto > responseEntity = restTemplateConfig .restTemplate ().postForEntity (tossPaymentsConfig .getApproveUrl (), entity , PaymentResponseDto .class );
172172 PaymentResponseDto responseDto = getPaymentResponseDto (responseEntity );
173- order .updatePaymentInfo (request .orderId (), PaymentMethod .valueOf (responseDto .type ()), OrderStatus .DONE , request .paidAmount ());
173+ order .updatePaymentInfo (request .orderId (), PaymentMethod .valueOf (responseDto .type ()), request . paymentKey (), OrderStatus .DONE , request .paidAmount ());
174174
175175 // 포인트 사용
176176 member .updatePoint (member .getPoint () - order .getPointUsedAmount ());
@@ -207,7 +207,7 @@ public OrderApproveResponseDto approveOrder(Long memberId, OrderApproveRequestDt
207207 return OrderApproveResponseDto .of (order );
208208
209209 } catch (HttpClientErrorException e ) { // 400번대 에러
210- log .error ("토스 환불 4xx 서버 에러: {}" , e .getResponseBodyAsString ());
210+ log .error ("토스 환불 4xx 서버 에러: {}" , e .getMessage ());
211211 throw new TossPaymentException (ErrorStatus .TOSS_PAYMENT_BAD_REQUEST );
212212 } catch (HttpServerErrorException e ) { // 500번대 에러
213213 log .error ("토스 환불 5xx 서버 에러: {}" , e .getResponseBodyAsString ());
0 commit comments