성공리다이렉트 url 이동 후 500에러 반환 문제.

. react와 typescript.

const tossPay = async () => {
    const paymentWidget = await loadPaymentWidget(
      tossConfig.clientKey,
      tossConfig.customerKey
    );
    paymentWidget.renderPaymentMethods(
      "#payment-method",
      calculateTotalPrice()
    );

    paymentWidget.requestPayment({
      orderId: "",
      orderName: "",
      successUrl: "https://localhost:3000/success",
      failUrl: "https://localhost:3000/fail",
      customerEmail: userEmail,
      customerName: userName,
    });
  };


.

export const SuccessPage = () => {
  const confirmPayments = async () => {
    const url = "https://api.tosspayments.com/v1/payments/confirm";
    const requestOptions = {
      method: "POST",
      headers: {
        Authorization: `Basic test_sk_~~~`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        paymentKey: paymentKey,
        amount: amount,
        orderId: orderId,
      }),
    };
    const response = await fetch(url, requestOptions);
    if (!response.ok) {
      throw new Error("결제 승인 API 호출 실패");
    }
    const responseJson = await response.json();
    console.log(responseJson);
  };
  confirmPayments().catch((error: any) => {
    console.log(error.message);
  });
  return <div></div>;
};


('/success').

, , .

,

Failed to load resource: the server responded with a status of 500 ()

,

{"code":"UNAUTHORIZED_KEY","message":"릿 .","data":null}

.

500릿 . , .

?
Was this page helpful?