| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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-4004' && 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_BEKASI/">
- <InquiryResult>
- <Response>00</Response>
- <Message>Sukses</Message>
- <transaction_id>201709191606131622</transaction_id>
- <NamaWP>NENENG KURNIASIH</NamaWP>
- <Jumlah_pokok>28793</Jumlah_pokok>
- <Jumlah_denda>576</Jumlah_denda>
- <JumlahBayar>29369</JumlahBayar>
- <TanggalBooking></TanggalBooking>
- <TanggalExpired></TanggalExpired>
- </InquiryResult>
- </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_BEKASI/">
- <PaymentResult>
- <Response>00</Response>
- <Message>Sukses</Message>
- <transaction_id>201709191607298865</transaction_id>
- <ntpd>15058084499314</ntpd>
- </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(3003, () => {
- console.log('SOAP dummy running at http://localhost:3003/dummy-pemko-4004');
- });
|