| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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-bpjskes' && req.method === 'POST') {
- const xmlInquiryResponse = `<?xml version="1.0" encoding="utf-8"?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <InquiryResponse xmlns="http://BTN-BPJSKES/">
- <InquiryResult>
- <billinfo1>BPJSKES</billinfo1>
- <billinfo2>COR</billinfo2>
- <billinfo3>8888890001100299</billinfo3>
- <billinfo4>COR</billinfo4>
- <billinfo5>1</billinfo5>
- <billinfo6>1-H A AZIZ MACHMUD FA</billinfo6>
- <billinfo7>PANGKAL PINANG</billinfo7>
- <billinfo8>4C1E89221DDC2017</billinfo8>
- <billinfo9/>
- <billinfo10/>
- <billinfo11>0602</billinfo11>
- <billinfo12/>
- <totalAmount>13023415</totalAmount>
- <terminalID>I99</terminalID>
- <idTransaksi>88888900011002990099991058002520260421</idTransaksi>
- <transDateTime>2026-04-21 11:13:10</transDateTime>
- <billDetails/>
- <status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <errorDescription>success</errorDescription>
- </Status>
- </status>
- </InquiryResult>
- </InquiryResponse>
- </soap:Body>
- </soap:Envelope>`;
- const xmlPaymentResponse = `<?xml version="1.0" encoding="utf-8"?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <PaymentResponse xmlns="http://BTN-BPJSKES/">
- <PaymentResult>
- <billinfo1/>
- <billinfo2/>
- <billinfo3/>
- <billinfo4/>
- <billinfo5/>
- <billinfo6/>
- <billinfo7/>
- <billinfo8/>
- <billinfo9/>
- <billinfo10/>
- <billinfo11/>
- <billinfo12/>
- <totalAmount>0</totalAmount>
- <terminalID/>
- <idTransaksi/>
- <transDateTime/>
- <billDetails/>
- <status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <errorDescription>success</errorDescription>
- </Status>
- </status>
- </PaymentResult>
- </PaymentResponse>
- </soap:Body>
- </soap:Envelope>`;
- 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(3093, () => {
- console.log('SOAP dummy BPJS Kesehatan running at http://localhost:3016/dummy-bpjskes');
- });
|