Skip to content

Commit 176ea9f

Browse files
authored
refactor: 결제 confirm api 응답구조 변경
* refactor: 결제 완료 영수증 정보 get요청 api 주석처리 * refactor: 결제 완료 영수증 정보 get요청 api 주석처리2
1 parent d770ed4 commit 176ea9f

5 files changed

Lines changed: 51 additions & 50 deletions

File tree

backend/src/main/java/com/back/api/payment/order/service/OrderService.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88

99
import com.back.api.payment.order.dto.request.OrderRequestDto;
1010
import com.back.api.payment.order.dto.response.OrderResponseDto;
11-
import com.back.api.queue.service.QueueEntryProcessService;
1211
import com.back.api.ticket.service.TicketService;
13-
import com.back.domain.event.repository.EventRepository;
1412
import com.back.domain.payment.order.entity.Order;
1513
import com.back.domain.payment.order.entity.OrderStatus;
1614
import com.back.domain.payment.order.repository.OrderRepository;
17-
import com.back.domain.seat.repository.SeatRepository;
1815
import com.back.domain.ticket.entity.Ticket;
19-
import com.back.domain.user.repository.UserRepository;
2016
import com.back.global.error.code.OrderErrorCode;
2117
import com.back.global.error.code.PaymentErrorCode;
2218
import com.back.global.error.exception.ErrorException;
@@ -27,11 +23,7 @@
2723
@RequiredArgsConstructor
2824
public class OrderService {
2925
private final OrderRepository orderRepository;
30-
private final EventRepository eventRepository;
31-
private final UserRepository userRepository;
32-
private final SeatRepository seatRepository;
3326
private final TicketService ticketService;
34-
private final QueueEntryProcessService queueEntryProcessService;
3527

3628
/**
3729
* 주문 생성
@@ -71,7 +63,7 @@ public OrderResponseDto createOrder(OrderRequestDto orderRequestDto, Long userId
7163
*/
7264
private String generateOrderNumber() {
7365
Random random = new Random();
74-
long number = 1000000000L + (long) (random.nextDouble() * 9000000000L);
66+
long number = 1000000000L + (long)(random.nextDouble() * 9000000000L);
7567
return "WF" + number;
7668
}
7769

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.back.api.payment.payment.controller;
22

3-
import org.springframework.web.bind.annotation.PathVariable;
43
import org.springframework.web.bind.annotation.RequestBody;
54

65
import com.back.api.payment.payment.dto.request.PaymentConfirmRequest;
7-
import com.back.api.payment.payment.dto.response.PaymentConfirmResponse;
86
import com.back.api.payment.payment.dto.response.PaymentReceiptResponse;
97
import com.back.global.config.swagger.ApiErrorCode;
108
import com.back.global.response.ApiResponse;
119

1210
import io.swagger.v3.oas.annotations.Operation;
13-
import io.swagger.v3.oas.annotations.Parameter;
1411
import io.swagger.v3.oas.annotations.tags.Tag;
1512
import jakarta.validation.Valid;
1613

@@ -27,21 +24,22 @@ public interface PaymentApi {
2724
"PAYMENT_AMOUNT_MISMATCH",
2825
"PAYMENT_FAILED"
2926
})
30-
ApiResponse<PaymentConfirmResponse> confirmPayment(
27+
ApiResponse<PaymentReceiptResponse> confirmPayment(
3128
@Valid @RequestBody PaymentConfirmRequest request
3229
);
3330

34-
@Operation(
35-
summary = "결제 영수증 조회",
36-
description = "결제 완료 후 영수증 정보를 조회합니다. 주문, 티켓, 이벤트, 좌석 정보를 모두 포함합니다."
37-
)
38-
@ApiErrorCode({
39-
"ORDER_NOT_FOUND",
40-
"PAYMENT_NOT_FOUND",
41-
"UNAUTHORIZED_ORDER_ACCESS"
42-
})
43-
ApiResponse<PaymentReceiptResponse> getPaymentReceipt(
44-
@Parameter(description = "조회할 주문 ID", example = "1")
45-
@PathVariable Long orderId
46-
);
31+
/**
32+
@Operation( summary = "결제 영수증 조회",
33+
description = "결제 완료 후 영수증 정보를 조회합니다. 주문, 티켓, 이벤트, 좌석 정보를 모두 포함합니다."
34+
)
35+
@ApiErrorCode({
36+
"ORDER_NOT_FOUND",
37+
"PAYMENT_NOT_FOUND",
38+
"UNAUTHORIZED_ORDER_ACCESS"
39+
})
40+
ApiResponse<PaymentReceiptResponse> getPaymentReceipt(
41+
@Parameter(description = "조회할 주문 ID", example = "1")
42+
@PathVariable Long orderId
43+
);
44+
*/
4745
}
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.back.api.payment.payment.controller;
22

3-
import org.springframework.web.bind.annotation.GetMapping;
4-
import org.springframework.web.bind.annotation.PathVariable;
53
import org.springframework.web.bind.annotation.PostMapping;
64
import org.springframework.web.bind.annotation.RequestBody;
75
import org.springframework.web.bind.annotation.RequestMapping;
86
import org.springframework.web.bind.annotation.RestController;
97

108
import com.back.api.payment.payment.dto.request.PaymentConfirmRequest;
11-
import com.back.api.payment.payment.dto.response.PaymentConfirmResponse;
129
import com.back.api.payment.payment.dto.response.PaymentReceiptResponse;
1310
import com.back.api.payment.payment.service.PaymentService;
1411
import com.back.global.http.HttpRequestContext;
@@ -27,12 +24,12 @@ public class PaymentController implements PaymentApi {
2724

2825
@Override
2926
@PostMapping("/confirm")
30-
public ApiResponse<PaymentConfirmResponse> confirmPayment(
27+
public ApiResponse<PaymentReceiptResponse> confirmPayment(
3128
@Valid @RequestBody PaymentConfirmRequest request
3229
) {
3330
Long userId = httpRequestContext.getUser().getId();
3431

35-
PaymentConfirmResponse response = paymentService.confirmPayment(
32+
PaymentReceiptResponse response = paymentService.confirmPayment(
3633
request.orderId(),
3734
request.paymentKey(),
3835
request.amount(),
@@ -45,18 +42,21 @@ public ApiResponse<PaymentConfirmResponse> confirmPayment(
4542
);
4643
}
4744

48-
@Override
49-
@GetMapping("/{orderId}/receipt")
50-
public ApiResponse<PaymentReceiptResponse> getPaymentReceipt(
51-
@PathVariable Long orderId
52-
) {
53-
Long userId = httpRequestContext.getUser().getId();
54-
55-
PaymentReceiptResponse response = paymentService.getPaymentReceipt(orderId, userId);
56-
57-
return ApiResponse.ok(
58-
"결제 영수증 조회 성공",
59-
response
60-
);
61-
}
45+
/**
46+
* 결제 post요청에 응답값에 영수증 정보가 모두 담기는 것으로 변경,
47+
* 추후 PG연동 대비 보관처리
48+
@Override
49+
@GetMapping("/{orderId}/receipt") public ApiResponse<PaymentReceiptResponse> getPaymentReceipt(
50+
@PathVariable Long orderId
51+
) {
52+
Long userId = httpRequestContext.getUser().getId();
53+
54+
PaymentReceiptResponse response = paymentService.getPaymentReceipt(orderId, userId);
55+
56+
return ApiResponse.ok(
57+
"결제 영수증 조회 성공",
58+
response
59+
);
60+
}
61+
*/
6262
}

backend/src/main/java/com/back/api/payment/payment/service/PaymentService.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.back.api.payment.order.service.OrderService;
88
import com.back.api.payment.payment.client.PaymentClient;
99
import com.back.api.payment.payment.dto.request.PaymentConfirmCommand;
10-
import com.back.api.payment.payment.dto.response.PaymentConfirmResponse;
1110
import com.back.api.payment.payment.dto.response.PaymentConfirmResult;
1211
import com.back.api.payment.payment.dto.response.PaymentReceiptResponse;
1312
import com.back.api.queue.service.QueueEntryProcessService;
@@ -43,7 +42,7 @@ public class PaymentService {
4342
private final ApplicationEventPublisher eventPublisher;
4443

4544
@Transactional
46-
public PaymentConfirmResponse confirmPayment(
45+
public PaymentReceiptResponse confirmPayment(
4746
Long orderId,
4847
String clientPaymentKey,
4948
Long clientAmount,
@@ -99,7 +98,13 @@ public PaymentConfirmResponse confirmPayment(
9998
)
10099
);
101100

102-
return PaymentConfirmResponse.from(order, ticket);
101+
// 최종 결과조회
102+
// mock구성에서는 프론트 개발속도를 위해 confirmPayment에서 처리
103+
// PG연동시에 분리 필요
104+
order = orderService.getOrderWithDetails(orderId, userId);
105+
ticket = order.getTicket();
106+
107+
return PaymentReceiptResponse.from(order, ticket);
103108
}
104109

105110
/**

backend/src/test/java/com/back/api/payment/service/PaymentServiceTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
import com.back.api.payment.order.service.OrderService;
1717
import com.back.api.payment.payment.client.PaymentClient;
18-
import com.back.api.payment.payment.dto.response.PaymentConfirmResponse;
1918
import com.back.api.payment.payment.dto.response.PaymentConfirmResult;
19+
import com.back.api.payment.payment.dto.response.PaymentReceiptResponse;
2020
import com.back.api.payment.payment.service.PaymentService;
2121
import com.back.api.queue.service.QueueEntryProcessService;
2222
import com.back.api.ticket.service.TicketService;
@@ -72,18 +72,24 @@ void confirmPayment_success() {
7272
var order = OrderFactory.fakePendingOrder(draftTicket, amount);
7373

7474
var issuedTicket = TicketFactory.fakeIssuedTicket(user, seat, event);
75+
// 결제 완료 후 상태 (PAID + issuedTicket)
76+
var paidOrder = OrderFactory.fakePaidOrder(issuedTicket, amount, paymentKey);
7577

7678
given(orderService.getOrderForPayment(any(), any(), any()))
7779
.willReturn(order);
7880

81+
// 영수증 조회 시 PAID 상태의 order 반환
82+
given(orderService.getOrderWithDetails(any(), any()))
83+
.willReturn(paidOrder);
84+
7985
given(paymentClient.confirm(any()))
8086
.willReturn(new PaymentConfirmResult(paymentKey, amount, true));
8187

8288
given(ticketService.confirmPayment(any(), eq(userId)))
8389
.willReturn(issuedTicket);
8490

8591
// when
86-
PaymentConfirmResponse response = paymentService.confirmPayment(
92+
PaymentReceiptResponse response = paymentService.confirmPayment(
8793
1L,
8894
paymentKey,
8995
amount,

0 commit comments

Comments
 (0)