diff --git a/src/main/java/com/sumte/payment/controller/KakaoRedirectController.java b/src/main/java/com/sumte/payment/controller/KakaoRedirectController.java
new file mode 100644
index 0000000..d53916c
--- /dev/null
+++ b/src/main/java/com/sumte/payment/controller/KakaoRedirectController.java
@@ -0,0 +1,97 @@
+package com.sumte.payment.controller;
+
+import com.sumte.apiPayload.ApiResponse;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import java.net.URI;
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+@Tag(name = "결제 리다이렉트 API", description = "PG사 결제 후 앱으로 리다이렉트 처리")
+public class KakaoRedirectController {
+
+ @Value("${kakao.pay.android.scheme}")
+ private String scheme;
+
+ @Value("${kakao.pay.android.host}")
+ private String host;
+
+ @GetMapping("/pay/success")
+ @Operation(
+ summary = "결제 성공 리다이렉트",
+ description = "카카오페이 결제 성공 후 앱으로 리다이렉트합니다.
" +
+ "Query Parameter로 paymentId, pg_token이 전달됩니다."
+ )
+ public ResponseEntity> success(
+ @RequestParam Long paymentId,
+ @RequestParam("pg_token") String pgToken) {
+
+ String deepLink = UriComponentsBuilder.newInstance()
+ .scheme(scheme).host(host).path("/success")
+ .queryParam("paymentId", paymentId)
+ .queryParam("pg_token", pgToken)
+ .build().toUriString();
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setLocation(URI.create(deepLink));
+ return ResponseEntity.status(HttpStatus.FOUND)
+ .headers(headers)
+ .body(ApiResponse.success(deepLink));
+ }
+
+ @GetMapping("/pay/cancel")
+ @Operation(
+ summary = "결제 취소 리다이렉트",
+ description = "카카오페이 결제 취소 후 앱으로 리다이렉트합니다.
" +
+ "Query Parameter로 paymentId가 전달됩니다."
+ )
+ public ResponseEntity> cancel(@RequestParam Long paymentId) {
+ String deepLink = UriComponentsBuilder.newInstance()
+ .scheme(scheme).host(host).path("/cancel")
+ .queryParam("paymentId", paymentId)
+ .build().toUriString();
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setLocation(URI.create(deepLink));
+ return ResponseEntity.status(HttpStatus.FOUND)
+ .headers(headers)
+ .body(ApiResponse.success(deepLink));
+ }
+
+ @GetMapping("/pay/fail")
+ @Operation(
+ summary = "결제 실패 리다이렉트",
+ description = "카카오페이 결제 실패 후 앱으로 리다이렉트합니다.
" +
+ "Query Parameter로 paymentId, code, message가 전달됩니다."
+ )
+ public ResponseEntity> fail(
+ @RequestParam Long paymentId,
+ @RequestParam(required=false) String code,
+ @RequestParam(required=false) String message) {
+
+ String deepLink = UriComponentsBuilder.newInstance()
+ .scheme(scheme).host(host).path("/fail")
+ .queryParam("paymentId", paymentId)
+ .queryParam("code", code)
+ .queryParam("message", message)
+ .build().toUriString();
+
+ HttpHeaders headers = new HttpHeaders();
+ headers.setLocation(URI.create(deepLink));
+ return ResponseEntity.status(HttpStatus.FOUND)
+ .headers(headers)
+ .body(ApiResponse.success(deepLink));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/sumte/payment/service/PaymentServiceImpl.java b/src/main/java/com/sumte/payment/service/PaymentServiceImpl.java
index 308b077..5269e58 100644
--- a/src/main/java/com/sumte/payment/service/PaymentServiceImpl.java
+++ b/src/main/java/com/sumte/payment/service/PaymentServiceImpl.java
@@ -52,9 +52,9 @@ public PaymentResponseDTO.PaymentReadyResponse requestPayment(PaymentRequestDTO.
.quantity("1")
.total_amount(String.valueOf(dto.getAmount()))
.tax_free_amount("0")
- .approval_url(redirectDomain + "/pay/success")
- .cancel_url(redirectDomain + "/pay/cancel")
- .fail_url(redirectDomain + "/pay/fail")
+ .approval_url(redirectDomain + "/pay/success?paymentId=" + payment.getId())
+ .cancel_url(redirectDomain + "/pay/cancel?paymentId=" + payment.getId())
+ .fail_url(redirectDomain + "/pay/fail?paymentId=" + payment.getId())
.build();
KakaoPayReadyResponseDTO kakaoResponse = kakaoPayClient.requestPayment(request);
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 4115d4f..de94de1 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -64,4 +64,7 @@ kakao:
pay:
secret-key: ${KAKAOPAY_SECRET_KEY}
redirect:
- domain: ${DOMAIN}
\ No newline at end of file
+ domain: ${DOMAIN}
+ android:
+ scheme : myapp
+ host : pay