bim93
bim9310h ago

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이동해도 파라미터로 안올길래 질문드립니다 어떻게 사용하는건가요? 예시를 알고싶습니다
6 Replies
토스페이먼츠 BOT
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) : - 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요. * 주말/공휴일에는 답변이 늦을 수 있어요.
Ayaan
Ayaan10h ago
결제 승인시에 돌아옵니다.
bim93
bim9310h ago
결제 승인전에 사용해야하는데 이런 경우에는 successUrl에 쿼리스트링형태로 보내야하나요?
Ayaan
Ayaan10h ago
네네 맞습니다.
bim93
bim9310h ago
감사합니다
토스페이먼츠 BOT
❤️ 기술문의 경험이 어떠셨나요?!
간단히 코멘트 남겨주세요! 제품 발전에 큰 힘이 됩니다.