<html>
<head>
...
<script src="https://js.tosspayments.com/v1/payment-widget"></script>
</head>
<body>
<div id="payment-method"></div
<button id="payment-request-button">결제하기</button>
<script>
const clientKey = '${clientKey}' // 상점을 특정하는 키
const amount = '${payment.amount}' // 결제 금액
const orderId = '${payment.orderId}' // 주문번호
const orderName = '${payment.orderName}' // 주문명
/*결제위젯 영역 렌더링*/
const paymentWidget = PaymentWidget(clientKey, PaymentWidget.ANONYMOUS) // 회원 결제 초기화
paymentMethods = paymentWidget.renderPaymentMethods('#payment-method', amount)
const button = document.getElementById('#payment-request-button') // 결제하기 버튼
button.addEventListener('click', () => {
paymentWidget.requestPayment({
orderId: orderId,
amount: amount,
customerName: '',
customerEmail: '',
orderName: orderName,
appScheme: 'YOUR_APP_SCHEME://',
successUrl: 'tosspayments://payment/success',
failUrl: 'tosspayments://payment/fail'
}).catch(err => {
window.ReactNativeWebView.postMessage(JSON.stringify(err))
})
})
</script>
</body>
</html>
<html>
<head>
...
<script src="https://js.tosspayments.com/v1/payment-widget"></script>
</head>
<body>
<div id="payment-method"></div
<button id="payment-request-button">결제하기</button>
<script>
const clientKey = '${clientKey}' // 상점을 특정하는 키
const amount = '${payment.amount}' // 결제 금액
const orderId = '${payment.orderId}' // 주문번호
const orderName = '${payment.orderName}' // 주문명
/*결제위젯 영역 렌더링*/
const paymentWidget = PaymentWidget(clientKey, PaymentWidget.ANONYMOUS) // 회원 결제 초기화
paymentMethods = paymentWidget.renderPaymentMethods('#payment-method', amount)
const button = document.getElementById('#payment-request-button') // 결제하기 버튼
button.addEventListener('click', () => {
paymentWidget.requestPayment({
orderId: orderId,
amount: amount,
customerName: '',
customerEmail: '',
orderName: orderName,
appScheme: 'YOUR_APP_SCHEME://',
successUrl: 'tosspayments://payment/success',
failUrl: 'tosspayments://payment/fail'
}).catch(err => {
window.ReactNativeWebView.postMessage(JSON.stringify(err))
})
})
</script>
</body>
</html>