Toss payments 개발자 커뮤니티Tp개커Toss payments 개발자 커뮤니티
Powered by
bim93B
Toss payments 개발자 커뮤니티•16mo ago•
4 replies
bim93

requestPayment의 metadata 파라미터 사용방법 문의

    async function requestPayment() {
        // 공통 결제 데이터 객체를 생성합니다.
        const paymentData = {
            method: method, // 'CARD', 'VIRTUAL_ACCOUNT', 'TRANSFER' 중 하나
            amount: {
                currency: "KRW",
                value: amount,
            },
            orderId: orderId,
            orderName: orderName,
            successUrl: window.location.origin + successUrl,
            failUrl: window.location.origin + failUrl,
            customerEmail: customerEmail,
            customerName: customerName,
            customerMobilePhone: customerMobilePhone,
            metadata: {
                product_type: product_type,
                lecture_code: lecture_code,
            },
        };

        // 결제 수단에 따라 추가 옵션을 설정합니다.
        if (method === 'VIRTUAL_ACCOUNT') {
            paymentData.virtualAccount = {
                cashReceipt: {
                    type: "미발행",
                },
                validHours: 168,
            };
        } else if (method === 'TRANSFER') {
            paymentData.transfer = {
                cashReceipt: {
                    type: "미발행",
                },
            };
        }

        // 결제 요청을 수행합니다.
        await payment.requestPayment(paymentData);
    }

    requestPayment().catch((r) => {
        const btn_arr = []
        btn_arr["confirm"] = {func: `location.href='${failUrl}';`};
        custom_alert(r.message, "", btn_arr);
    });
    async function requestPayment() {
        // 공통 결제 데이터 객체를 생성합니다.
        const paymentData = {
            method: method, // 'CARD', 'VIRTUAL_ACCOUNT', 'TRANSFER' 중 하나
            amount: {
                currency: "KRW",
                value: amount,
            },
            orderId: orderId,
            orderName: orderName,
            successUrl: window.location.origin + successUrl,
            failUrl: window.location.origin + failUrl,
            customerEmail: customerEmail,
            customerName: customerName,
            customerMobilePhone: customerMobilePhone,
            metadata: {
                product_type: product_type,
                lecture_code: lecture_code,
            },
        };

        // 결제 수단에 따라 추가 옵션을 설정합니다.
        if (method === 'VIRTUAL_ACCOUNT') {
            paymentData.virtualAccount = {
                cashReceipt: {
                    type: "미발행",
                },
                validHours: 168,
            };
        } else if (method === 'TRANSFER') {
            paymentData.transfer = {
                cashReceipt: {
                    type: "미발행",
                },
            };
        }

        // 결제 요청을 수행합니다.
        await payment.requestPayment(paymentData);
    }

    requestPayment().catch((r) => {
        const btn_arr = []
        btn_arr["confirm"] = {func: `location.href='${failUrl}';`};
        custom_alert(r.message, "", btn_arr);
    });


metadata에 2개 추가해서 결제요청 성공하면 successUrl쪽에 파라미터로 보내주는거 아닌가요?
일단 추가해도 successUrl이동해도 파라미터로 안올길래 질문드립니다

어떻게 사용하는건가요? 예시를 알고싶습니다
Toss payments 개발자 커뮤니티 banner
Toss payments 개발자 커뮤니티Join
Toss payments 개발자 커뮤니티입니다. 결제 연동하며 겪는 기술 문의부터, 결제 시장에 대한 다양한 정보까지 얻어가세요~
15,588Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

mid 별 결제위젯 사용방법 문의ㅇ
웅~!웅웅~! / ❓┃연동개발-문의
3y ago
요청 파라미터 문의
000 / ❓┃연동개발-문의
13mo ago
현금영수증 파라미터 문의
유부장유유부장 / ❓┃연동개발-문의
3y ago
고유식별번호 파라미터 전달 문의
장용호장장용호 / ❓┃연동개발-문의
9mo ago