| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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-bpjstk' && 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-BPJSTK/">
- <InquiryResult>
- <billinfo1>BPJSTK</billinfo1>
- <billinfo2>BPJSTK</billinfo2>
- <billinfo3>423199061000</billinfo3>
- <billinfo4>N</billinfo4>
- <billinfo5/>
- <billinfo6>UIN SYARIF HIDAYATULLAH JAKARTA - PKWT</billinfo6>
- <billinfo7>00012/2025</billinfo7>
- <billinfo8>23199061</billinfo8>
- <billinfo9>0</billinfo9>
- <billinfo10>931206</billinfo10>
- <billinfo11>JHT0751756#JKK0751756#JKM0751756</billinfo11>
- <billinfo12> CMS11756120496159990751756</billinfo12>
- <addvalues>{"KODE_IURAN":"423199061000"}</addvalues>
- <totalAmount>931206</totalAmount>
- <billDetails>
- <billName>JHTJKKJKMJPKJPN</billName>
- <billAmount>850620 35815 44771 0 0 </billAmount>
- </billDetails>
- <status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <errorDescription>Sukses</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-BPJSTK/">
- <PaymentResult>
- <billinfo1/>
- <billinfo2/>
- <status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <errorDescription>Sukses</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(3094, () => {
- console.log('SOAP dummy BPJS Ketenagakerjaan running at http://localhost:3017/dummy-bpjstk');
- });
|