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); if (req.url === '/dummy-bpjstkindv' && req.method === 'POST') { const xmlInquiryResponse = ` 7172021211910002 1 MARLON PORSISA 26-08-2020 02-01-2026 36800 0.00 0.00 20000 6800 10000 0 7172021211910002#TLR260120000150 00136900000087 N 20260120133155 T00#JKK,JKM,JHT 36800 false 00 Sukses `; const xmlPaymentResponse = ` 3275121503750001 1 925126557881 0 0 0 0 0 0 0 3275121503750001#3275121503750001#MBK251204000152 30000100392680 N051120250401202620251204110059 20251204110109 # 0 false 00 Sukses `; 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(3095, () => { console.log('SOAP dummy BPJS TK Individual running at http://localhost:3095/dummy-bpjstkindv'); });