결제위젯 클라이언트 쪽 예제코드를 실행하면 에러가 납니다.

로 street4zss MID .

.

TypeError: Cannot read properties of undefined (reading 'id')
    at r.selectedPaymentMethod.isNormalMethodFirst (11-fe79a70f88345b5f.js:53:49477)
    at ed.ofPaymentMethodMap (11-fe79a70f88345b5f.js:53:49534)
   ...
toss-test:30 Uncaught (in promise) r: 알 수 없는 에러가 발생했습니다.
    at https://js.tosspayments.com/v2/standard:7:546228
    at Object.otherwise (https://js.tosspayments.com/v2/standard:7:429238)
   ...


.
<!DOCTYPE html>
<html lang="ko">
  <head>
    <head>
      <!-- 스크립트 추가 -->
      <script src="https://js.tosspayments.com/v2/standard"></script>
    </head>

    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>결제위젯 샘플</title>
  </head>
  <body>
    <script>
        // 스크립트 태그 연동방식
        function generateRandomString() {
           return window.btoa(Math.random().toString()).slice(0, 20);
        }
        async function main () {
            const tossPayments = TossPayments("test_gck_QbgMGZzorzzKQwgdaNLLrl5E1em4"); // 결제위젯 연동 키
            const widgets = tossPayments.widgets({ customerKey: generateRandomString() });
            widgets.setAmount({
              currency: 'KRW',
              value: 1000,
            });
            const paymentMethodWidget = await widgets.renderPaymentMethods({
              selector: "#payment-method",
              variantKey: "DEFAULT",
            });
        }
        main();  

      </script>
    <div class="wrapper w-100">
      <div class="max-w-540 w-100">
        <div id="payment-method" class="w-100"></div>
        <div id="agreement" class="w-100"></div>
        <div class="btn-wrapper w-100">
          <button id="payment-request-button" class="btn primary w-100">결제하기</button>
        </div>
      </div>
    </div>
  </body>
</html>

한 bill_wsneapvjb mid.

.
Was this page helpful?