const http = require('http'); const server = http.createServer((req, res) => { let body = ''; let hasInquiry = false; let hasPayment = false; req.on('data', (chunk) => { body += chunk; }); req.on('end', () => { hasInquiry = /<(\w+:)?Inquiry\b/.test(body); hasPayment = /<(\w+:)?Payment\b/.test(body); const regeXbillkey1 = /(.*?)<\/NS1:billkey1>/; const regeXbillkey2 = /(.*?)<\/NS1:billkey2>/; const regeXbillkey3 = /(.*?)<\/NS1:billkey3>/; const regeXbillkey4 = /(.*?)<\/NS1:billkey4>/; const regeXbillkey5 = /(.*?)<\/NS1:billkey5>/; const regeXbillkey6 = /(.*?)<\/NS1:billkey6>/; const regeXbillkey7 = /(.*?)<\/NS1:billkey7>/; const regeXbillkey8 = /(.*?)<\/NS1:billkey8>/; const regeXbillkey9 = /(.*?)<\/NS1:billkey9>/; const regeXbillkey10 = /(.*?)<\/NS1:billkey10>/; const regeXterminalID = /(.*?)<\/NS1:terminalID>/; const regeXidTransaksi = /(.*?)<\/NS1:idTransaksi>/; const regeXtransDateTime = /(.*?)<\/NS1:transDateTime>/; const matcHbillkey1 = body.match(regeXbillkey1); const matcHbillkey2 = body.match(regeXbillkey2); const matcHbillkey3 = body.match(regeXbillkey3); const matcHbillkey4 = body.match(regeXbillkey4); const matcHbillkey5 = body.match(regeXbillkey5); const matcHbillkey6 = body.match(regeXbillkey6); const matcHbillkey7 = body.match(regeXbillkey7); const matcHbillkey8 = body.match(regeXbillkey8); const matcHbillkey9 = body.match(regeXbillkey9); const matcHbillkey10 = body.match(regeXbillkey10); const matcHterminalID = body.match(regeXterminalID); const matcHidTransaksi = body.match(regeXidTransaksi); const matcHtransDateTime = body.match(regeXtransDateTime); const billkey1 = matcHbillkey1 ? matcHbillkey1[1] : null; const billkey2 = matcHbillkey2 ? matcHbillkey2[1] : null; const billkey3 = matcHbillkey3 ? matcHbillkey3[1] : null; const billkey4 = matcHbillkey4 ? matcHbillkey4[1] : null; const billkey5 = matcHbillkey5 ? matcHbillkey5[1] : null; const billkey6 = matcHbillkey6 ? matcHbillkey6[1] : null; const billkey7 = matcHbillkey7 ? matcHbillkey7[1] : null; const billkey8 = matcHbillkey8 ? matcHbillkey8[1] : null; const billkey9 = matcHbillkey9 ? matcHbillkey9[1] : null; const billkey10 = matcHbillkey10 ? matcHbillkey10[1] : null; const terminalID = matcHterminalID ? matcHterminalID[1] : null; const idTransaksi = matcHidTransaksi ? matcHidTransaksi[1] : null; const transDateTime = matcHtransDateTime ? matcHtransDateTime[1] : null; let errCode = `00` let errMessage = `success` if (billkey3 == '88888888') { errCode = `01` errMessage = `Invalid virtual account number.` } if (req.url === '/dummy-bpjstk' && req.method === 'POST') { const xmlInquiryResponse = ` `+billkey1+` `+billkey2+` `+billkey3+` `+billkey4+` UIN SYARIF HIDAYATULLAH JAKARTA - PKWT 00012/2025 23199061 0 931206 JHT0751756#JKK0751756#JKM0751756 CMS11756120496159990751756 {"KODE_IURAN":"423199061000"} 931206 JHTJKKJKMJPKJPN 850620 35815 44771 0 0 false 00 Sukses `; const xmlPaymentResponse = ` false`+ errCode+ errMessage+` `; if (hasInquiry) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=utf-8' }); res.end(xmlInquiryResponse); } else if (hasPayment) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=utf-8' }); res.end(xmlPaymentResponse); } else { res.writeHead(400, { 'Content-Type': 'text/plain' }); res.end('Bad Request: No Inquiry or Payment action found'); } } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not found'); } }); }); server.listen(3094, () => { console.log('SOAP dummy BPJS Ketenagakerjaan running at http://localhost:3017/dummy-bpjstk'); });