| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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-ws-spp-0001' && 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="H2HUGM/btn/">
- <InquiryResult>
- <currency>360</currency>
- <billInfo1>25/561563/EK/25744</billInfo1>
- <billInfo2>Axel Hernanda</billInfo2>
- <billInfo3>S1 AKUNTANSI</billInfo3>
- <billInfo4>SPP:9200</billInfo4>
- <billInfo5>Periode GENAP 2025</billInfo5>
- <billInfo6>3276061605070002</billInfo6>
- <billReff>UKT :Rp. 9,200,000.00</billReff>
- <totalBill>9200000</totalBill>
- <billDetails>
- <billDetails>
- <billCode>01</billCode>
- <billName>UKT</billName>
- <billShortName>UKT</billShortName>
- <billAmount>9200000</billAmount>
- <reference1></reference1>
- <reference2></reference2>
- <reference3></reference3>
- </billDetails>
- </billDetails>
- <status>
- <Status>
- <isError>False</isError>
- <errorCode>00</errorCode>
- <statusDescription>Sukses</statusDescription>
- </Status>
- </status>
- </InquiryResult>
- </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="H2HUGM/btn/">
- <PaymentResult>
- <billInfo1>25/561563/EK/25744</billInfo1>
- <billInfo2>Axel Hernanda</billInfo2>
- <billInfo3>S1 AKUNTANSI</billInfo3>
- <billInfo4>SPP:9200</billInfo4>
- <billInfo5>Periode GENAP 2025</billInfo5>
- <status>
- <Status>
- <isError>False</isError>
- <errorCode>01</errorCode>
- <statusDescription>Invalid Data</statusDescription>
- </Status>
- </status>
- </PaymentResult>
- </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(3008, () => {
- console.log('SOAP dummy running at http://localhost:3008/dummy-ws-spp-0001');
- });
|