dummyutbk.js 2.9 KB

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