| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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-pemko-4001' && req.method === 'POST') {
- const xmlInquiryResponse = `<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://H2HPEMKOT_BATAM/">
- <Response>00</Response>
- <Message>Sukses</Message>
- <transaction_id>201806211148204973</transaction_id>
- <NamaWP>PT GRIYA HIJAU LESTARI</NamaWP>
- <Jumlah_pokok>302818</Jumlah_pokok>
- <Jumlah_denda>0</Jumlah_denda>
- <JumlahBayar>302818</JumlahBayar>
- <TanggalBooking></TanggalBooking>
- <TanggalExpired></TanggalExpired>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- const xmlPaymentResponse = `<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://H2HPEMKOT_BATAM/">
- <rsp>000</rsp>
- <resdesc>Request Data Berhasil</resdesc>
- <dataRes>
- <additionalInfo>
- <ntpd>15058084499314</ntpd>
- </additionalInfo>
- </dataRes>
- </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(3005, () => {
- console.log('SOAP dummy running at http://localhost:3005/dummy-pemko-4001');
- });
|