// IMP.init("imp00000000"); // 가맹점 식별코드
window.IMP_CONFIG = {
userCode: 'imp00000000', // 실제 배포 시 가맹점 식별코드 입력
pg: 'html5_inicis', // PG사 (이니시스/KCP/토스페이먼츠 등)
ready: false
};
// 결제 요청 함수 (실제 아임포트 연동)
window.requestPayment = function(options, onSuccess, onFail) {
// 실제 IMP 객체가 있으면 진짜 결제
if (typeof IMP !== 'undefined' && IMP_CONFIG.ready) {
IMP.request_pay({
pg: IMP_CONFIG.pg,
pay_method: options.method || 'card',
merchant_uid: 'takbaejob_' + Date.now(),
name: options.name,
amount: options.amount,
buyer_name: options.buyerName || '',
buyer_tel: options.buyerTel || '',
buyer_email: options.buyerEmail || '',
}, function(rsp) {
if (rsp.success) {
// 서버에 결제 검증 요청 (실제 배포 시 필수)
verifyPayment(rsp.imp_uid, rsp.merchant_uid, onSuccess, onFail);
} else {
onFail && onFail(rsp.error_msg);
}
});
} else {
// 데모 모드: 시뮬레이션
simulatePayment(options, onSuccess, onFail);
}
};
// 서버 결제 검증 (실제 배포 시 백엔드 API 호출)
function verifyPayment(imp_uid, merchant_uid, onSuccess, onFail) {
// fetch('/api/payment/verify', {
// method: 'POST',
// headers: { 'Content-Type': 'application/json' },
// body: JSON.stringify({ imp_uid, merchant_uid })
// }).then(res => res.json()).then(data => {
// if (data.success) onSuccess(data);
// else onFail(data.message);
// });
onSuccess({ imp_uid: imp_uid, merchant_uid: merchant_uid });
}
// 데모 결제 시뮬레이션
function simulatePayment(options, onSuccess, onFail) {
var ov = document.createElement('div');
ov.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:9999999;display:flex;align-items:center;justify-content:center;padding:20px;';
ov.innerHTML =
'' +
'
' +
'
상단 노출 구매
'+(postTitle||'선택된 공고')+'
' +
'
' +
'
' +
// 효과 미리보기
'
' +
'
⚡ 상단 노출 효과
' +
'
' +
effectBox('평균 조회수', '+284%', '#0C447C') +
effectBox('평균 지원자', '+8.3명', '#27500A') +
'
' +
'
' +
// 기간 선택
'
' +
'
기간 선택
' +
'
' +
boostOption2('3d', '3일', 10000, '빠른 충원') +
boostOption2('7d', '7일', 20000, '가장 인기', true) +
boostOption2('30d', '30일', 60000, '상시 모집') +
'
' +
'
' +
'
' +
'
';
document.body.appendChild(ov);
document.getElementById('boost-close').onclick = function(){ ov.remove(); };
ov.onclick = function(e){ if(e.target===ov) ov.remove(); };
};
function effectBox(label, val, color) {
return '