dummyutbk.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const http = require('http');
  2. const server = http.createServer((req, res) => {
  3. let body = '';
  4. let hasInquiry = false;
  5. let hasPayment = true
  6. req.on('data', (chunk) => {
  7. body += chunk;
  8. });
  9. req.on('end', () => {
  10. console.log(body)
  11. hasInquiry = /<(\w+:)?Inquiry\b/.test(body);
  12. hasPayment = /<(\w+:)?Payment\b/.test(body);
  13. if (req.url === '/dummy-utbk' && req.method === 'POST') {
  14. const xmlInquiryResult = `<?xml version="1.0" encoding="utf-8"?>
  15. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  16. <SOAP-ENV:Body>
  17. <InquiryResult xmlns="http://BTN-SNPMB/">
  18. <rsp>000</rsp>
  19. <rspdesc>Successful</rspdesc>
  20. <ref>68</ref>
  21. <uuid>5fcc7969-449b-4bde-8dec-502d974eebd7</uuid>
  22. <kodeTagihan>01</kodeTagihan>
  23. <deskripsiPanjang>Biaya UTBK 2026</deskripsiPanjang>
  24. <deskripsiPendek>Biaya UTBK</deskripsiPendek>
  25. <nominal>200000</nominal>
  26. <noPembayaran>88802336</noPembayaran>
  27. <nisn>0086660415</nisn>
  28. <nama>ANDINI AZALIA SYAKIRA</nama>
  29. <dob>2008-02-29</dob>
  30. </InquiryResult>
  31. </SOAP-ENV:Body>
  32. </SOAP-ENV:Envelope>`;
  33. const xmlPaymentResult = `<?xml version="1.0" encoding="utf-8"?>
  34. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  35. <SOAP-ENV:Body>
  36. <PaymentResult xmlns="http://BTN-SNPMB/">
  37. <rsp>000</rsp>
  38. <rspdesc>Successful</rspdesc>
  39. <ref>68</ref>
  40. <uuid>5fcc7969-449b-4bde-8dec-502d974eebd7</uuid>
  41. <kodeTagihan>01</kodeTagihan>
  42. <deskripsiPanjang>Biaya UTBK 2026</deskripsiPanjang>
  43. <deskripsiPendek>Biaya UTBK</deskripsiPendek>
  44. <nominal>200000</nominal>
  45. <noPembayaran>88802336</noPembayaran>
  46. <nisn>0086660415</nisn>
  47. <nama>ANDINI AZALIA SYAKIRA</nama>
  48. <dob>2008-02-29</dob>
  49. <paidAmount>200000</paidAmount>
  50. <currency>IDR</currency>
  51. </PaymentResult>
  52. </SOAP-ENV:Body>
  53. </SOAP-ENV:Envelope>`;
  54. if(hasInquiry) {
  55. res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
  56. res.end(xmlInquiryResult);
  57. } else if (hasPayment) {
  58. res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
  59. res.end(xmlPaymentResult);
  60. } else {
  61. res.writeHead(404, { 'Content-Type': 'text/plain' });
  62. res.end('Not found');
  63. }
  64. } else {
  65. res.writeHead(404, { 'Content-Type': 'text/plain' });
  66. res.end('Not found');
  67. }
  68. });
  69. });
  70. server.listen(3071, () => {
  71. console.log('SOAP dummy running at http://localhost:3071/dummy-utbk');
  72. });