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+:)?Payment\b/.test(body);
if (req.url === '/dummy-pemko-4002' && req.method === 'POST') {
const xmlInquiryResponse = `
000
Success
[ESB544600779]
APIM20251229185135
1
21.74.020.004.014-0912.0
2025
HERI KUNCORO
JL KAMPUNG SRIMULYO GG KELINCI NO 19
85537
83046
2491
0
0
0
0
0
0
0
2025-09-30T00:00:00Z
`;
const xmlPaymentResponse = `
000
Success
[ESB544600779]
APIM20251229185135
1
21.74.020.004.014-0912.0
2025
HERI KUNCORO
JL KAMPUNG SRIMULYO GG KELINCI NO 19
85537
83046
2491
0
0
0
0
0
0
0
2025-09-30T00:00:00Z
`;
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(xmlPaymentResponse);
} 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(3002, () => {
console.log('SOAP dummy running at http://localhost:3002/dummy-pemko-4002');
});