| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 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-bpjstkindv' && 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-BPJSTKINDV/">
- <InquiryResult>
- <billinfo1>7172021211910002</billinfo1>
- <billinfo2>1</billinfo2>
- <billinfo3>MARLON PORSISA</billinfo3>
- <billinfo4>26-08-2020</billinfo4>
- <billinfo5>02-01-2026</billinfo5>
- <billinfo6/>
- <billinfo7>36800</billinfo7>
- <billinfo8>0.00</billinfo8>
- <billinfo9>0.00</billinfo9>
- <billinfo10>20000</billinfo10>
- <billinfo11>6800</billinfo11>
- <billinfo12>10000</billinfo12>
- <billinfo13>0</billinfo13>
- <billinfo14>7172021211910002#TLR260120000150</billinfo14>
- <billinfo15>00136900000087</billinfo15>
- <billinfo16>N</billinfo16>
- <billinfo17>20260120133155</billinfo17>
- <billinfo18>T00#JKK,JKM,JHT</billinfo18>
- <billinfo19/>
- <billinfo20/>
- <totalAmount>36800</totalAmount>
- <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-BPJSTKINDV/">
- <PaymentResult>
- <billinfo1>3275121503750001</billinfo1>
- <billinfo2>1</billinfo2>
- <billinfo3/>
- <billinfo4/>
- <billinfo5/>
- <billinfo6>925126557881</billinfo6>
- <billinfo7>0</billinfo7>
- <billinfo8>0</billinfo8>
- <billinfo9>0</billinfo9>
- <billinfo10>0</billinfo10>
- <billinfo11>0</billinfo11>
- <billinfo12>0</billinfo12>
- <billinfo13>0</billinfo13>
- <billinfo14>3275121503750001#3275121503750001#MBK251204000152</billinfo14>
- <billinfo15>30000100392680</billinfo15>
- <billinfo16>N051120250401202620251204110059</billinfo16>
- <billinfo17>20251204110109</billinfo17>
- <billinfo18>#</billinfo18>
- <billinfo19/>
- <billinfo20/>
- <totalAmount>0</totalAmount>
- <billDetails/>
- <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(3095, () => {
- console.log('SOAP dummy BPJS TK Individual running at http://localhost:3095/dummy-bpjstkindv');
- });
|