| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- const http = require('http');
- const server = http.createServer((req, res) => {
- let body = '';
- let hasInquiry = false;
- let hasPayment = true
- 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-smmptn' && req.method === 'POST') {
- const xmlInquiryResponse = `<?xml version="1.0" encoding="utf-8"?>
- <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">
- <SOAP-ENV:Body>
- <InquiryResponse xmlns="http://BTN-SMM/">
- <rsp>000</rsp>
- <rspdesc>Transaction success</rspdesc>
- <trxID>45</trxID>
- <idTagihan>953016738727</idTagihan>
- <namaMhs>HADI NUR CAHAYA</namaMhs>
- <fakultas>UTBK SMMPTN-BARAT</fakultas>
- <billCode>00</billCode>
- <billName>BIAYA PENDAFTARAN</billName>
- <billShortName>SMMPTN-BARAT 2026</billShortName>
- <billAmount>375000</billAmount>
- <totalTagihan>375000</totalTagihan>
- <reference1>0</reference1>
- <reference2>0</reference2>
- <reference3>0</reference3>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- const xmlPaymentResponse = `<?xml version="1.0" encoding="utf-8"?>
- <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">
- <SOAP-ENV:Body>
- <PaymentResponse xmlns="http://BTN-SMM/">
- <rsp>000</rsp>
- <rspdesc>Transaction success</rspdesc>
- <trxID>47</trxID>
- <idTagihan>953016738727</idTagihan>
- <namaMhs>HADI NUR CAHAYA</namaMhs>
- <fakultas>UTBK SMMPTN-BARAT</fakultas>
- <billName>BIAYA PENDAFTARAN</billName>
- <billShortName>SMMPTN-BARAT 2026</billShortName>
- </PaymentResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- if(hasInquiry) {
- res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
- res.end(xmlInquiryResponse);
- } else if (hasPayment) {
- res.writeHead(200, { 'Content-Type': 'text/xml; charset=ISO-8859-1' });
- res.end(xmlPaymentResponse);
- } else {
- res.writeHead(404, { 'Content-Type': 'text/plain' });
- res.end('Not found');
- }
- } else {
- res.writeHead(404, { 'Content-Type': 'text/plain' });
- res.end('Not found');
- }
- });
- });
- server.listen(3070, () => {
- console.log('SOAP dummy running at http://localhost:3070/dummy-smmptn');
- });
|