본문 바로가기
프로젝트/장애인 PT 플랫폼, PTFD

Portone을 활용한 수기 결제(백엔드 단에 전 권한 이임)

by 임지혁코딩 2024. 2. 21.
@RestController
@RequiredArgsConstructor
@Slf4j
public class HandWritePayController {

    private final WebClient webClient = WebClient.builder().baseUrl("https://api.portone.io").build();

    private final String mytoken = 
    @PostMapping("/handwritepay")
    public Mono<BillingPayResponse> HandWritePay()
    {
        MethodDto handwritemethod = new MethodDto(
                new CardDto
                        (new CredentialDTO("testcard",
                        2026,
                        11)
        ));


        PaymentAmount amount = new PaymentAmount(30000);

        HandwritePayRequest handwritePayRequest =
                new HandwritePayRequest("channel-key-4bc1f3ce-78aa-4265-9f5d-49bb1a1d9896",
                        handwritemethod,
                        "test를위한이름",
                        amount,
                        "KRW") ;

        Mono<BillingPayResponse> monoResult = webClient
                .post()
                .uri("/payments/{paymentId}/instant", "testfor1")
                .header("Authorization", "Bearer " + mytoken)
                .retrieve()
                .bodyToMono(BillingPayResponse.class)
                .onErrorResume(e -> {
                    log.info("Error occurred: {}", e.getMessage());

                    return Mono.error(e) ;
                });

        return monoResult;



    }

 

현재 이와 같이, 굳이 백엔드 단에 모든 결제 권한을 위임하였다.

 

그 이유는, 책임의 명확한 분리와, msa구조로 변경시 위함이다 .

 

하지만 현재 invalid request라는 error가 계속해서 등장한다. 

 

해당 문제에 대해 고민하여 보겠다 .

 

* 해당 문제가, 카드 정보 개인사 불가능이란 문제로 인해 유발될 가능성이 있다고 생각하여

고객센터에 정책 관련하여 질문을 올려보도록 하겠다.