From 48e1b1dfe1b96ec2ae93729bb1d654b944d34e56 Mon Sep 17 00:00:00 2001 From: DongGeon Lee <71763322+himodu@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:42:06 +0900 Subject: [PATCH] #53 - Kakao Payment refactor - for Intergration with client - tid parameter fix --- .../mymoo/domain/payment/controller/PaymentController.java | 2 +- .../domain/payment/service/Impl/PaymentServiceImpl.java | 5 +---- .../example/mymoo/domain/payment/service/PaymentService.java | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) 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); }