php에서 결제연동 테스트를 진행하려고 합니다.
가이드북 문서에 적혀있는 대로 아래와 같은 소스로 만들었는데 브라우저 콘솔상에
[caught Error: selector에 해당하는 element를 찾을 수 없습니다. selector 값을 다시 확인해주세요. (selector: #payment-method)]
이런 에러문구가 뜨는데 확인 바랍니다.
<?php
$clientKey = "testck";
$customerKey = "testsk";
?>
<head>
<title>결제하기</title>
<script src="https://js.tosspayments.com/v1/payment-widget"></script>
</head>
<body>
<script>
const clientKey = '<?php echo $clientKey?>';
const customerKey = '<?php echo $customerKey?>';
var paymentWidget = PaymentWidget(clientKey, customerKey); // 결제위젯 초기화
paymentWidget = PaymentWidget(clientKey, PaymentWidget.ANONYMOUS); // 비회원 결제
paymentWidget.renderPaymentMethods('#payment-method', 15000);
paymentWidget.requestPayment({
orderId: 'AD8aZDpbzXs4EQa-UkIX6',
orderName: '토스 티셔츠 외 2건',
successUrl: 'http://localhost:8080/success',
failUrl: 'http://localhost:8080/fail',
customerEmail: 'customer123@gmail.com',
customerName: '김토스'
});
</script>
<input type="text" name="payment-method" id="payment-method" />
<button type="button" onClick="requestPayment();">결제하기</button>
</body>
</html>
[caught Error: selector에 해당하는 element를 찾을 수 없습니다. selector 값을 다시 확인해주세요. (selector: #payment-method)]
이런 에러문구가 뜨는데 확인 바랍니다.
<?php
$clientKey = "testck";
$customerKey = "testsk";
?>
<head>
<title>결제하기</title>
<script src="https://js.tosspayments.com/v1/payment-widget"></script>
</head>
<body>
<script>
const clientKey = '<?php echo $clientKey?>';
const customerKey = '<?php echo $customerKey?>';
var paymentWidget = PaymentWidget(clientKey, customerKey); // 결제위젯 초기화
paymentWidget = PaymentWidget(clientKey, PaymentWidget.ANONYMOUS); // 비회원 결제
paymentWidget.renderPaymentMethods('#payment-method', 15000);
paymentWidget.requestPayment({
orderId: 'AD8aZDpbzXs4EQa-UkIX6',
orderName: '토스 티셔츠 외 2건',
successUrl: 'http://localhost:8080/success',
failUrl: 'http://localhost:8080/fail',
customerEmail: 'customer123@gmail.com',
customerName: '김토스'
});
</script>
<input type="text" name="payment-method" id="payment-method" />
<button type="button" onClick="requestPayment();">결제하기</button>
</body>
</html>
