Skip to content

Commit

Permalink
#53 - Kakao Payment refactor
Browse files Browse the repository at this point in the history
- for Intergration with client
- tid parameter fix
  • Loading branch information
himodu committed Dec 6, 2024
1 parent e753dfa commit 48e1b1d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ResponseEntity<PayResponseDTO> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 48e1b1d

Please sign in to comment.