-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTOR] 토스페이 결제 redirect 설정 추가 (#53)
- Loading branch information
Showing
3 changed files
with
62 additions
and
35 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/main/java/com/oya/kr/payment/controller/TossPayCallbackController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.oya.kr.payment.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import com.oya.kr.payment.service.TossPayService; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* @author 김유빈 | ||
* @since 2024.03.10 | ||
*/ | ||
@Controller | ||
@RequestMapping("/api/v1/payments/toss") | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class TossPayCallbackController { | ||
|
||
private final TossPayService tossPayService; | ||
|
||
@Value("${payment.toss.success-callback}") | ||
private String successCallback; | ||
|
||
@Value("${payment.toss.fail-callback}") | ||
private String failCallback; | ||
|
||
/** | ||
* 토스페이 결제 승인 시 성공 콜백 | ||
* | ||
* @parameter String, String, String, Long | ||
* @return String | ||
* @author 김유빈 | ||
* @since 2024.02.29 | ||
*/ | ||
@GetMapping("/success") | ||
public String success( | ||
@RequestParam String orderId, | ||
@RequestParam String paymentType, | ||
@RequestParam String paymentKey, | ||
@RequestParam Long amount | ||
) { | ||
tossPayService.success(orderId, paymentType, paymentKey, amount); | ||
return String.format("redirect:%s", successCallback); | ||
} | ||
|
||
/** | ||
* 토스페이 결제 에러 시 실패 콜백 | ||
* | ||
* @return String | ||
* @author 김유빈 | ||
* @since 2024.02.29 | ||
*/ | ||
@GetMapping("/fail") | ||
public String fail() { | ||
tossPayService.fail(); | ||
return String.format("redirect:%s", failCallback); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters