diff --git a/src/main/java/com/example/mymoo/domain/payment/controller/PaymentController.java b/src/main/java/com/example/mymoo/domain/payment/controller/PaymentController.java index 297fad9..f849494 100644 --- a/src/main/java/com/example/mymoo/domain/payment/controller/PaymentController.java +++ b/src/main/java/com/example/mymoo/domain/payment/controller/PaymentController.java @@ -36,7 +36,7 @@ public ResponseEntity approve( //승인 처리 - 이 부분은 프론트에서 1차적으로 리다이렉트 // 프론트에서 받은 결제 정보(pg_token)를 해당 api에 넘겨주면 서버에 반영됨 return ResponseEntity.status(HttpStatus.ACCEPTED) - .body(paymentService.approve(pgToken, tid, userDetails.getAccountId())); + .body(paymentService.approve(tid, pgToken, userDetails.getAccountId())); } @GetMapping("cancel") diff --git a/src/main/java/com/example/mymoo/domain/payment/service/Impl/PaymentServiceImpl.java b/src/main/java/com/example/mymoo/domain/payment/service/Impl/PaymentServiceImpl.java index b663082..ecda134 100644 --- a/src/main/java/com/example/mymoo/domain/payment/service/Impl/PaymentServiceImpl.java +++ b/src/main/java/com/example/mymoo/domain/payment/service/Impl/PaymentServiceImpl.java @@ -39,7 +39,6 @@ public class PaymentServiceImpl implements PaymentService { @Value("${kakao.pay.partner-order-id}") private String partnerOrderId; - private String tid; public KakaoPayReadyResponse payReady(String name, Integer totalPrice, Long accountId){ // Request header @@ -69,14 +68,12 @@ public KakaoPayReadyResponse payReady(String name, Integer totalPrice, Long acco entityMap, KakaoPayReadyResponse.class ); - this.tid = response.getBody().getTid(); - // 주문번호와 TID를 매핑해서 저장해놓는다. // Mapping TID with partner_order_id then save it to use for approval request. return response.getBody(); } @Transactional - public PayResponseDTO approve(String pgToken, String tida, Long accountId){ + public PayResponseDTO approve(String tid, String pgToken, Long accountId){ // ready할 때 저장해놓은 TID로 승인 요청 // Call “Execute approved payment” API by pg_token, TID mapping to the current payment transaction and other parameters. HttpHeaders headers = new HttpHeaders(); diff --git a/src/main/java/com/example/mymoo/domain/payment/service/PaymentService.java b/src/main/java/com/example/mymoo/domain/payment/service/PaymentService.java index b5eca17..9ca3adb 100644 --- a/src/main/java/com/example/mymoo/domain/payment/service/PaymentService.java +++ b/src/main/java/com/example/mymoo/domain/payment/service/PaymentService.java @@ -5,5 +5,5 @@ public interface PaymentService { KakaoPayReadyResponse payReady(String name, Integer totalPrice, Long accountId); - PayResponseDTO approve(String pgToken, String tid, Long accountId); + PayResponseDTO approve(String tid, String pgToken, Long accountId); }