const http = require('http'); const server = http.createServer((req, res) => { let body = ''; let hasInquiry = false; let hasPayment = true req.on('data', (chunk) => { body += chunk; }); req.on('end', () => { hasInquiry = /<(\w+:)?Inquiry\b/.test(body); hasPayment = /<(\w+:)?Payments\b/.test(body); const regeXpaymentCode = /(.*?)<\/NS1:paymentCode>/; const matcHpaymentCode = body.match(regeXpaymentCode); const paymentCode = matcHpaymentCode ? matcHpaymentCode[1] : null; let xmlInquiryResponse = 'a'; let xmlPaymentsResponse = 'a'; if (req.url === '/dummy-mpn' && req.method === 'POST') { if (paymentCode != '88888888') { xmlInquiryResponse = ` 820260622861293 056 01 430266 502 7012 IDR 2026-06-23 15:54:37 2026-06-23 15:54:37 0624 171 21688 F02 773956 50000 00 ABDUL MALIK EFENDI false 00 Tagihan Sukses `; xmlPaymentsResponse = ` 926062310585879 520200000990 999 01 960186 Jl. H. R. Rasuna Said No.1, RT.1/RW.6, Guntur 999 7015 IDR 2026-06-23 14:51:56 2026-06-23 14:51:53 0623 011 3000009 I99 001685 1000000 1601300020711 00 MUFID MAN 300000003125 BDCB88Q3MDT0KTGN false 00 Payment Sukses `; } else { xmlInquiryResponse = ` true 01 Invalid Customer Id `; xmlPaymentsResponse = ` true 01 Invalid Customer Id `; } if (paymentCode.startsWith('0') || paymentCode.startsWith('1') || paymentCode.startsWith('2') || paymentCode.startsWith('3')) { xmlInquiryResponse = ` 031411231406157 F86 7012 2026-07-22 06:06:32 2026-07-22 06:06:32 0722 IDR 001 21342 F86 000001 ` xmlPaymentsResponse = ` 031411231406157 520200000990 827882283955000 1 7371032206720005000000-JL. MERDEKA - KABUPATEN MA 586 7012 IDR 2026-07-22 06:06:41 2026-07-22 06:06:41 0722 171 21342 F86 638096 2007687 1401390005391 00 TEDY PANDY 002134200002 8F1D967R100BFE2D false 00 Payment Sukses 00586 ` } else if (paymentCode.startsWith('4') || paymentCode.startsWith('5') || paymentCode.startsWith('6')) { xmlInquiryResponse = ` 620191000189290 520200000990 000000000000000 73 A000091909230EDH20190930 2019-10-21 050100 35 7010 IDR 2019-10-22 08:37:21 2019-10-22 08:42:30 1022 031 9903512 C35 193593 576000 00 yanto suyanto false 00 Tagihan Sukses ` xmlPaymentsResponse = ` 620191000189290 520200000990 000000000000000 73 A000091909230EDH20190930 2019-10-21 050100 35 7010 IDR 2019-10-22 08:37:29 2019-10-22 08:42:38 1022 391 9903512 C35 835020 576000 1401390005391 00 YANTO SUYANTO 990351141057 50B562AF1J0SUMBA false 00 Payment Sukses 35 ` } else { xmlInquiryResponse = ` 820260721428752 056 01 432458 37 7016 IDR 2026-07-22 15:46:31 2026-07-22 15:46:31 0723 171 22511 C37 840448 50000 00 ENDY PEBRIAN false 00 Tagihan Sukses ` xmlPaymentsResponse = ` 820260721428752 520200000990 056 01 432458 37 7016 IDR 2026-07-22 15:47:23 2026-07-22 15:47:23 0723 001 22511 C37 640591 50000 1401390005391 00 ENDY PEBRIAN 002251100047 09D652G50CF7J28G false 00 Payment Sukses 00037 ` } if(hasInquiry) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' }); res.end(xmlInquiryResponse); } else if (hasPayment) { res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' }); res.end(xmlPaymentsResponse); } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not found'); } } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end('Not found'); } }); }); server.listen(3123, () => { console.log('SOAP dummy running at http://localhost:3123/dummy-mpn'); });