유규선
유규선
결제연동 결제 요청 변수 추가 (PHP)
PHP index.html에서 결제 성공시 orderName, amount 값을 success로 보내고 success에서 GET으로 받고 있는데 orderName과 amount 이외의 변수 값을 넣어서 success에 보내고 그 값을 DB에 저장하고 싶은데 success에서 변수값을 다 못받네요 구현할 방법이 있을까요? ex) amount 경우에는 store.php -> index.html(기존 토스 페이먼츠 페이지) -> success.php 에서 store.php에서 amount 값을 입력하고 index.html에서 amount값을 GET으로 받고 이 값을 requestPayment를 통해 success.php로 전송중인데 이렇게 할 수 있는 게 amount 이외에 가능한게 있는지 store.php header("Location: /url/index.html?amount=" . urlencode($pay_amount) . "&text=".urlencode($pay_text)); index.html <script> const urlParams = new URLSearchParams(window.location.search); const amount = urlParams.get('amount'); const orderName = urlParams.get('text'); </script> paymentWidget.renderPaymentMethods("#payment-method", { value: amount }); const paymentRequestButton = document.getElementById( "payment-request-button" ); paymentRequestButton.addEventListener("click", () => { /** 결제 요청 * @docs https://docs.tosspayments.com/reference/widget-sdk#requestpayment%EA%B2%B0%EC%A0%9C-%EC%A0%95%EB%B3%B4 */ paymentWidget.requestPayment({ orderId: generateRandomString(),
orderName: orderName, amount: amount, success.php $orderId = $_GET['orderId']; $amount = $_GET['amount'];
9 replies