1
0

dummyBPJSTKINDV.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. const http = require('http');
  2. const server = http.createServer((req, res) => {
  3. let body = '';
  4. let hasInquiry = false;
  5. let hasPayment = false;
  6. req.on('data', (chunk) => {
  7. body += chunk;
  8. });
  9. req.on('end', () => {
  10. hasInquiry = /<(\w+:)?Inquiry\b/.test(body);
  11. hasPayment = /<(\w+:)?Payment\b/.test(body);
  12. if (req.url === '/dummy-bpjstkindv' && req.method === 'POST') {
  13. const xmlInquiryResponse = `<?xml version="1.0" encoding="utf-8"?>
  14. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  15. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  17. <soap:Body>
  18. <InquiryResponse xmlns="http://BTN-BPJSTKINDV/">
  19. <InquiryResult>
  20. <billinfo1>7172021211910002</billinfo1>
  21. <billinfo2>1</billinfo2>
  22. <billinfo3>MARLON PORSISA</billinfo3>
  23. <billinfo4>26-08-2020</billinfo4>
  24. <billinfo5>02-01-2026</billinfo5>
  25. <billinfo6/>
  26. <billinfo7>36800</billinfo7>
  27. <billinfo8>0.00</billinfo8>
  28. <billinfo9>0.00</billinfo9>
  29. <billinfo10>20000</billinfo10>
  30. <billinfo11>6800</billinfo11>
  31. <billinfo12>10000</billinfo12>
  32. <billinfo13>0</billinfo13>
  33. <billinfo14>7172021211910002#TLR260120000150</billinfo14>
  34. <billinfo15>00136900000087</billinfo15>
  35. <billinfo16>N</billinfo16>
  36. <billinfo17>20260120133155</billinfo17>
  37. <billinfo18>T00#JKK,JKM,JHT</billinfo18>
  38. <billinfo19/>
  39. <billinfo20/>
  40. <totalAmount>36800</totalAmount>
  41. <billDetails/>
  42. <status>
  43. <Status>
  44. <isError>false</isError>
  45. <errorCode>00</errorCode>
  46. <errorDescription>Sukses</errorDescription>
  47. </Status>
  48. </status>
  49. </InquiryResult>
  50. </InquiryResponse>
  51. </soap:Body>
  52. </soap:Envelope>`;
  53. const xmlPaymentResponse = `<?xml version="1.0" encoding="utf-8"?>
  54. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  55. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  56. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  57. <soap:Body>
  58. <PaymentResponse xmlns="http://BTN-BPJSTKINDV/">
  59. <PaymentResult>
  60. <billinfo1>3275121503750001</billinfo1>
  61. <billinfo2>1</billinfo2>
  62. <billinfo3/>
  63. <billinfo4/>
  64. <billinfo5/>
  65. <billinfo6>925126557881</billinfo6>
  66. <billinfo7>0</billinfo7>
  67. <billinfo8>0</billinfo8>
  68. <billinfo9>0</billinfo9>
  69. <billinfo10>0</billinfo10>
  70. <billinfo11>0</billinfo11>
  71. <billinfo12>0</billinfo12>
  72. <billinfo13>0</billinfo13>
  73. <billinfo14>3275121503750001#3275121503750001#MBK251204000152</billinfo14>
  74. <billinfo15>30000100392680</billinfo15>
  75. <billinfo16>N051120250401202620251204110059</billinfo16>
  76. <billinfo17>20251204110109</billinfo17>
  77. <billinfo18>#</billinfo18>
  78. <billinfo19/>
  79. <billinfo20/>
  80. <totalAmount>0</totalAmount>
  81. <billDetails/>
  82. <status>
  83. <Status>
  84. <isError>false</isError>
  85. <errorCode>00</errorCode>
  86. <errorDescription>Sukses</errorDescription>
  87. </Status>
  88. </status>
  89. </PaymentResult>
  90. </PaymentResponse>
  91. </soap:Body>
  92. </soap:Envelope>`;
  93. if (hasInquiry) {
  94. res.writeHead(200, { 'Content-Type': 'text/xml; charset=utf-8' });
  95. res.end(xmlInquiryResponse);
  96. } else if (hasPayment) {
  97. res.writeHead(200, { 'Content-Type': 'text/xml; charset=utf-8' });
  98. res.end(xmlPaymentResponse);
  99. } else {
  100. res.writeHead(400, { 'Content-Type': 'text/plain' });
  101. res.end('Bad Request: No Inquiry or Payment action found');
  102. }
  103. } else {
  104. res.writeHead(404, { 'Content-Type': 'text/plain' });
  105. res.end('Not found');
  106. }
  107. });
  108. });
  109. server.listen(3095, () => {
  110. console.log('SOAP dummy BPJS TK Individual running at http://localhost:3095/dummy-bpjstkindv');
  111. });