1. 1차적으로 요청하는 API

@PostMapping("/{boardId}")
    public ResponseEntity<ApiResult<PaymentResponse>> request(
            @PathVariable Long boardId,
            @Valid @ModelAttribute PaymentRequest request
    ) {
        String email = authenticationService.getEmail();
        PaymentResponse paymentResponse = paymentService.request(request, email, boardId);
        return ResponseEntity.ok(ApiUtils.success(paymentResponse));
    }

그럼 결과 값으로

{
  "success": true,
  "response": {
    "payType": "CARD",
    "amount": 100,
    "orderName": "주문명",
    "customerName": "푸항항",
    "customerEmail": "[email protected]",
    "orderId": "4_923237306",
    "successUrl": "<http://localhost:8080/payment/success>",
    "failUrl": "<http://localhost:8080/payment/fail>",
    "createAt": "2023-07-04T20:53:15.2922703",
    "paymentStatus": "READY"
  },
  "error": null
}

클라이언트

button.addEventListener('click', function () {
        tossPayments.requestPayment('카드', {
            amount: 100,
            orderId: '4_923237306',
            orderName: "주문명",
            customerName: "푸항항",
            customerEamil: "[email protected]",
            successUrl: '<http://localhost:8080/success>',
            failUrl: '<http://localhost:8080/fail>',
        })
    })

Untitled