결제연동 결제 요청 변수 추가 (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'];
젯 JavaScript SDK.
결제위젯 JavaScript SDK | 토스페이먼츠 개발자센터
Was this page helpful?