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/.test(body);
hasPayment = /<(\w+:)?Payment/.test(body);
// console.log(hasInquiry);
// console.log(body);
if (req.url === '/dummy-asabri' && req.method === 'POST') {
const xmlInquiryDetailResponse = `
getDataPP102NonBPLS
00
Berhasil
BE141852
BE141852THT21
1
1
70
2
B/002759-AS/THT/I/2026
2026-01-08
1700
AAW0414
SUWANTAH
479045
1662
1
1943-03-02
WIKE TIN KEMASAN SARI
002
7309015003810002
0007601500167476
3
PERUMAHAN SOLINDO IM/5
003
BONTOA
MANDAI
A0398
A0026
6282259395559
008
4000000
4000000
0
4000000
0
`;
const xmlFlaggingDetailResponse = `
00
sukses
BTNTHT20901202600241154800010
`;
if(hasInquiry) {
res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
res.end(xmlInquiryDetailResponse);
} else if (hasPayment) {
res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
res.end(xmlFlaggingDetailResponse);
} 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(3046, () => {
console.log('SOAP dummy running at http://localhost:3046/dummy-asabri');
});