@tosspayments/payment-sdk 결제 위젯 관련 문의입니다.

'' , sdk 된 redirect URL 은 successUrl .

시 orderId 'client-advice-14448-12193-1729337857302' . ()

.

useEffect(() => {
  switch (phase) {
    case "init":
      const { origin, pathname, search } = window.location;
      const query = new URLSearchParams(search);
      query.delete("orderId");
      query.delete("amount");
      loadTossPayments(process.env.NEXT_PUBLIC_TOSS_CLIENT_KEY).then(({ requestPayment }) =>
        requestPayment("카드", {
          amount: Number(amount),
          orderId,
          orderName,
          successUrl: origin + pathname.replace("init", "success") + "?" + query,
          failUrl: origin + pathname.replace("init", "failure") + "?" + query,
        }).catch((error) => {
          console.error(error);
          alert("결제를 취소합니다.");
          window.history.go(-2);
        }),
      );
      return;
    case "success":
      router.push({ pathname: onSuccess, query: { ...router.query, paymentId: paymentKey } });
      return;
    case "failure":
      router.push({ pathname: onFailure, query: { ...router.query, errorCode, errorMessage } });
      return;
  }
}, []);
Was this page helpful?