빌링 키 발급 중 400 error 문의

.

,
, 은 400 ERROR후 SUCCESS .


청 URL:
https://log-sandbox.tosspayments.com/v1/log
:
POST
:
400 Bad Request

.
const customerKey = generateRandomString();
const clientKey = "test_ck_D5GePWvyJnrK0W0k6q8gLzN97Eoq";

    useEffect(() => {
        async function fetchPayment() {
            try {
                const tossPayments = await loadTossPayments(clientKey);
                const paymentInstance = tossPayments.payment({ customerKey });
                console.log("paymentInstance", paymentInstance);
                setPayment(paymentInstance);
            } catch (error) {
                console.error("Error fetching payment:", error);
            }
        }

        fetchPayment();
    }, [clientKey, customerKey]);

    useEffect(() => {
        if (payment) {
            requestBillingAuth(); // payment 객체가 설정된 후에 자동으로 실행
        }
    }, [payment]);

async function requestBillingAuth() {
        console.log("payment", payment);
        if (!payment) {
            console.error('payment 객체가 초기화되지 않았습니다.');
            return;
        }

        await payment.requestBillingAuth({
            method: "CARD", // 자동결제(빌링)은 카드만 지원합니다
            successUrl: window.location.origin + "/account/billing", // 요청이 성공하면 리다이렉트되는 URL
            failUrl: window.location.origin + "/fail", // 요청이 실패하면 리다이렉트되는 URL
            customerEmail: "customer123@gmail.com",
            customerName: "김토스",
            windowTarget : "self"
        });
    }
Was this page helpful?