| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- 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);
- const regeXbillkey1 = /<NS1:billkey1>(.*?)<\/NS1:billkey1>/;
- const regeXbillkey2 = /<NS1:billkey2>(.*?)<\/NS1:billkey2>/;
- const regeXbillkey3 = /<NS1:billkey3>(.*?)<\/NS1:billkey3>/;
- const regeXbillkey4 = /<NS1:billkey4>(.*?)<\/NS1:billkey4>/;
- const regeXbillkey5 = /<NS1:billkey5>(.*?)<\/NS1:billkey5>/;
- const regeXbillkey6 = /<NS1:billkey6>(.*?)<\/NS1:billkey6>/;
- const regeXbillkey7 = /<NS1:billkey7>(.*?)<\/NS1:billkey7>/;
- const regeXbillkey8 = /<NS1:billkey8>(.*?)<\/NS1:billkey8>/;
- const regeXbillkey9 = /<NS1:billkey9>(.*?)<\/NS1:billkey9>/;
- const regeXbillkey10 = /<NS1:billkey10>(.*?)<\/NS1:billkey10>/;
- const regeXterminalID = /<NS1:terminalID>(.*?)<\/NS1:terminalID>/;
- const regeXidTransaksi = /<NS1:idTransaksi>(.*?)<\/NS1:idTransaksi>/;
- const regeXtransDateTime = /<NS1:transDateTime>(.*?)<\/NS1:transDateTime>/;
- const matcHbillkey1 = body.match(regeXbillkey1);
- const matcHbillkey2 = body.match(regeXbillkey2);
- const matcHbillkey3 = body.match(regeXbillkey3);
- const matcHbillkey4 = body.match(regeXbillkey4);
- const matcHbillkey5 = body.match(regeXbillkey5);
- const matcHbillkey6 = body.match(regeXbillkey6);
- const matcHbillkey7 = body.match(regeXbillkey7);
- const matcHbillkey8 = body.match(regeXbillkey8);
- const matcHbillkey9 = body.match(regeXbillkey9);
- const matcHbillkey10 = body.match(regeXbillkey10);
- const matcHterminalID = body.match(regeXterminalID);
- const matcHidTransaksi = body.match(regeXidTransaksi);
- const matcHtransDateTime = body.match(regeXtransDateTime);
- const billkey1 = matcHbillkey1 ? matcHbillkey1[1] : null;
- const billkey2 = matcHbillkey2 ? matcHbillkey2[1] : null;
- const billkey3 = matcHbillkey3 ? matcHbillkey3[1] : null;
- const billkey4 = matcHbillkey4 ? matcHbillkey4[1] : null;
- const billkey5 = matcHbillkey5 ? matcHbillkey5[1] : null;
- const billkey6 = matcHbillkey6 ? matcHbillkey6[1] : null;
- const billkey7 = matcHbillkey7 ? matcHbillkey7[1] : null;
- const billkey8 = matcHbillkey8 ? matcHbillkey8[1] : null;
- const billkey9 = matcHbillkey9 ? matcHbillkey9[1] : null;
- const billkey10 = matcHbillkey10 ? matcHbillkey10[1] : null;
- const terminalID = matcHterminalID ? matcHterminalID[1] : null;
- const idTransaksi = matcHidTransaksi ? matcHidTransaksi[1] : null;
- const transDateTime = matcHtransDateTime ? matcHtransDateTime[1] : null;
- let errCode = `<errorCode>00</errorCode>`
- let errMessage = `<errorDescription>success</errorDescription>`
- if (billkey3 == '88888888') {
- errCode = `<errorCode>01</errorCode>`
- errMessage = `<errorDescription>Invalid virtual account number.</errorDescription>`
- }
- 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>`+billkey3+`</billinfo1>
- <billinfo2>`+billkey4+`</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>`+
- errCode+
- errMessage+`
- </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');
- });
|