| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- 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+:)?Payments\b/.test(body);
- const regeXpaymentCode = /<NS1:paymentCode>(.*?)<\/NS1:paymentCode>/;
- const matcHpaymentCode = body.match(regeXpaymentCode);
- const paymentCode = matcHpaymentCode ? matcHpaymentCode[1] : null;
- let xmlInquiryResponse = 'a';
- let xmlPaymentsResponse = 'a';
- if (req.url === '/dummy-mpn' && req.method === 'POST') {
- if (paymentCode != '88888888') {
- 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.co.id/MPNService">
- <InquiryResult>
- <PaymentCode>820260622861293</PaymentCode>
- <BillingInfo1>056</BillingInfo1>
- <BillingInfo2>01</BillingInfo2>
- <BillingInfo3>430266</BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>502</BranchCode>
- <ChannelType>7012</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2026-06-23 15:54:37</Gmt>
- <LocalDateTime>2026-06-23 15:54:37</LocalDateTime>
- <SettlementDate>0624</SettlementDate>
- <SwitcherCode>171</SwitcherCode>
- <TerminalId>21688</TerminalId>
- <TerminalLocation>F02</TerminalLocation>
- <TransactionId>773956</TransactionId>
- <Amount>50000</Amount>
- <ResponseCode>00</ResponseCode>
- <CustomerName>ABDUL MALIK EFENDI</CustomerName>
- <Ntb></Ntb>
- <Ntpn></Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Tagihan Sukses</statusDescription>
- </Status>
- </Status>
- </InquiryResult>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- xmlPaymentsResponse = `<?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>
- <PaymentsResponse xmlns="http://btn.co.id/MPNService">
- <PaymentsResult>
- <PaymentCode>926062310585879</PaymentCode>
- <BankId>520200000990</BankId>
- <BillingInfo1>999</BillingInfo1>
- <BillingInfo2>01</BillingInfo2>
- <BillingInfo3>960186</BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6>Jl. H. R. Rasuna Said No.1, RT.1/RW.6, Guntur</BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>999</BranchCode>
- <ChannelType>7015</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2026-06-23 14:51:56</Gmt>
- <LocalDateTime>2026-06-23 14:51:53</LocalDateTime>
- <SettlementDate>0623</SettlementDate>
- <SwitcherCode>011</SwitcherCode>
- <TerminalId>3000009</TerminalId>
- <TerminalLocation>I99</TerminalLocation>
- <TransactionId>001685</TransactionId>
- <Amount>1000000</Amount>
- <BillerAccountNumber>1601300020711</BillerAccountNumber>
- <ResponseCode>00</ResponseCode>
- <CustomerName>MUFID MAN</CustomerName>
- <Ntb>300000003125</Ntb>
- <Ntpn>BDCB88Q3MDT0KTGN</Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Payment Sukses</statusDescription>
- </Status>
- </Status>
- </PaymentsResult>
- </PaymentsResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
-
- } else {
- 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.co.id/MPNService">
- <InquiryResult>
- <PaymentCode></PaymentCode>
- <BillingInfo1></BillingInfo1>
- <BillingInfo2></BillingInfo2>
- <BillingInfo3></BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode></BranchCode>
- <ChannelType></ChannelType>
- <Currency></Currency>
- <Gmt></Gmt>
- <LocalDateTime></LocalDateTime>
- <SettlementDate></SettlementDate>
- <SwitcherCode></SwitcherCode>
- <TerminalId></TerminalId>
- <TerminalLocation></TerminalLocation>
- <TransactionId></TransactionId>
- <Amount></Amount>
- <ResponseCode></ResponseCode>
- <CustomerName></CustomerName>
- <Ntb></Ntb>
- <Ntpn></Ntpn>
- <Status>
- <Status>
- <isError>true</isError>
- <errorCode>01</errorCode>
- <statusDescription>Invalid Customer Id</statusDescription>
- </Status>
- </Status>
- </InquiryResult>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- xmlPaymentsResponse = `<?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>
- <PaymentsResponse xmlns="http://btn.co.id/MPNService">
- <PaymentsResult>
- <PaymentCode></PaymentCode>
- <BankId></BankId>
- <BillingInfo1></BillingInfo1>
- <BillingInfo2></BillingInfo2>
- <BillingInfo3></BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode></BranchCode>
- <ChannelType></ChannelType>
- <Currency></Currency>
- <Gmt></Gmt>
- <LocalDateTime></LocalDateTime>
- <SettlementDate></SettlementDate>
- <SwitcherCode></SwitcherCode>
- <TerminalId></TerminalId>
- <TerminalLocation></TerminalLocation>
- <TransactionId></TransactionId>
- <Amount></Amount>
- <BillerAccountNumber></BillerAccountNumber>
- <ResponseCode></ResponseCode>
- <CustomerName></CustomerName>
- <Ntb></Ntb>
- <Ntpn></Ntpn>
- <Status>
- <Status>
- <isError>true</isError>
- <errorCode>01</errorCode>
- <statusDescription>Invalid Customer Id</statusDescription>
- </Status>
- </Status>
- </PaymentsResult>
- </PaymentsResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`;
- }
- if (paymentCode.startsWith('0') || paymentCode.startsWith('1') || paymentCode.startsWith('2') || paymentCode.startsWith('3')) {
- 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>
- <Inquiry xmlns="http://btn.co.id/MPNService">
- <paymentCode>031411231406157</paymentCode>
- <branchCode>F86</branchCode>
- <channelType>7012</channelType>
- <gmt>2026-07-22 06:06:32</gmt>
- <localDateTime>2026-07-22 06:06:32</localDateTime>
- <settlementDate>0722</settlementDate>
- <currency>IDR</currency>
- <switcherCode>001</switcherCode>
- <terminalId>21342</terminalId>
- <terminalLocation>F86</terminalLocation>
- <transactionId>000001</transactionId>
- <billingInfo1></billingInfo1>
- </Inquiry>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`
- xmlPaymentsResponse = `<?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>
- <PaymentsResult xmlns="http://btn.co.id/MPNService">
- <PaymentCode>031411231406157</PaymentCode>
- <BankId>520200000990</BankId>
- <BillingInfo1>827882283955000</BillingInfo1>
- <BillingInfo2>1</BillingInfo2>
- <BillingInfo3></BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6>7371032206720005000000-JL. MERDEKA - KABUPATEN MA</BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>586</BranchCode>
- <ChannelType>7012</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2026-07-22 06:06:41</Gmt>
- <LocalDateTime>2026-07-22 06:06:41</LocalDateTime>
- <SettlementDate>0722</SettlementDate>
- <SwitcherCode>171</SwitcherCode>
- <TerminalId>21342</TerminalId>
- <TerminalLocation>F86</TerminalLocation>
- <TransactionId>638096</TransactionId>
- <Amount>2007687</Amount>
- <BillerAccountNumber>1401390005391</BillerAccountNumber>
- <ResponseCode>00</ResponseCode>
- <CustomerName>TEDY PANDY</CustomerName>
- <Ntb>002134200002</Ntb>
- <Ntpn>8F1D967R100BFE2D</Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Payment Sukses</statusDescription>
- </Status>
- </Status>
- <BranchId>00586</BranchId>
- </PaymentsResult>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`
- } else if (paymentCode.startsWith('4') || paymentCode.startsWith('5') || paymentCode.startsWith('6')) {
- 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.co.id/MPNService">
- <InquiryResult>
- <PaymentCode>620191000189290</PaymentCode>
- <BankId>520200000990</BankId>
- <BillingInfo1>000000000000000</BillingInfo1>
- <BillingInfo2>73</BillingInfo2>
- <BillingInfo3>A000091909230EDH20190930</BillingInfo3>
- <BillingInfo4>2019-10-21</BillingInfo4>
- <BillingInfo5>050100</BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>35</BranchCode>
- <ChannelType>7010</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2019-10-22 08:37:21</Gmt>
- <LocalDateTime>2019-10-22 08:42:30</LocalDateTime>
- <SettlementDate>1022</SettlementDate>
- <SwitcherCode>031</SwitcherCode>
- <TerminalId>9903512</TerminalId>
- <TerminalLocation>C35</TerminalLocation>
- <TransactionId>193593</TransactionId>
- <Amount>576000</Amount>
- <ResponseCode>00</ResponseCode>
- <CustomerName>yanto suyanto</CustomerName>
- <Ntb></Ntb>
- <Ntpn></Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Tagihan Sukses</statusDescription>
- </Status>
- </Status>
- </InquiryResult>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`
- xmlPaymentsResponse = `<?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>
- <PaymentsResponse xmlns="http://btn.co.id/MPNService">
- <PaymentsResult>
- <PaymentCode>620191000189290</PaymentCode>
- <BankId>520200000990</BankId>
- <BillingInfo1>000000000000000</BillingInfo1>
- <BillingInfo2>73</BillingInfo2>
- <BillingInfo3>A000091909230EDH20190930</BillingInfo3>
- <BillingInfo4>2019-10-21</BillingInfo4>
- <BillingInfo5>050100</BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>35</BranchCode>
- <ChannelType>7010</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2019-10-22 08:37:29</Gmt>
- <LocalDateTime>2019-10-22 08:42:38</LocalDateTime>
- <SettlementDate>1022</SettlementDate>
- <SwitcherCode>391</SwitcherCode>
- <TerminalId>9903512</TerminalId>
- <TerminalLocation>C35</TerminalLocation>
- <TransactionId>835020</TransactionId>
- <Amount>576000</Amount>
- <BillerAccountNumber>1401390005391</BillerAccountNumber>
- <ResponseCode>00</ResponseCode>
- <CustomerName>YANTO SUYANTO</CustomerName>
- <Ntb>990351141057</Ntb>
- <Ntpn>50B562AF1J0SUMBA</Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Payment Sukses</statusDescription>
- </Status>
- </Status>
- <BranchId>35</BranchId>
- </PaymentsResult>
- </PaymentsResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`
- } else {
- 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.co.id/MPNService">
- <InquiryResult>
- <PaymentCode>820260721428752</PaymentCode>
- <BillingInfo1>056</BillingInfo1>
- <BillingInfo2>01</BillingInfo2>
- <BillingInfo3>432458</BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>37</BranchCode>
- <ChannelType>7016</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2026-07-22 15:46:31</Gmt>
- <LocalDateTime>2026-07-22 15:46:31</LocalDateTime>
- <SettlementDate>0723</SettlementDate>
- <SwitcherCode>171</SwitcherCode>
- <TerminalId>22511</TerminalId>
- <TerminalLocation>C37</TerminalLocation>
- <TransactionId>840448</TransactionId>
- <Amount>50000</Amount>
- <ResponseCode>00</ResponseCode>
- <CustomerName>ENDY PEBRIAN</CustomerName>
- <Ntb></Ntb>
- <Ntpn></Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Tagihan Sukses</statusDescription>
- </Status>
- </Status>
- </InquiryResult>
- </InquiryResponse>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>`
- xmlPaymentsResponse = `<?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>
- <PaymentsResult xmlns="http://btn.co.id/MPNService">
- <PaymentCode>820260721428752</PaymentCode>
- <BankId>520200000990</BankId>
- <BillingInfo1>056</BillingInfo1>
- <BillingInfo2>01</BillingInfo2>
- <BillingInfo3>432458</BillingInfo3>
- <BillingInfo4></BillingInfo4>
- <BillingInfo5></BillingInfo5>
- <BillingInfo6></BillingInfo6>
- <BillingInfo7></BillingInfo7>
- <BillingInfo8></BillingInfo8>
- <BillingInfo9></BillingInfo9>
- <BillingInfo10></BillingInfo10>
- <BranchCode>37</BranchCode>
- <ChannelType>7016</ChannelType>
- <Currency>IDR</Currency>
- <Gmt>2026-07-22 15:47:23</Gmt>
- <LocalDateTime>2026-07-22 15:47:23</LocalDateTime>
- <SettlementDate>0723</SettlementDate>
- <SwitcherCode>001</SwitcherCode>
- <TerminalId>22511</TerminalId>
- <TerminalLocation>C37</TerminalLocation>
- <TransactionId>640591</TransactionId>
- <Amount>50000</Amount>
- <BillerAccountNumber>1401390005391</BillerAccountNumber>
- <ResponseCode>00</ResponseCode>
- <CustomerName>ENDY PEBRIAN</CustomerName>
- <Ntb>002251100047</Ntb>
- <Ntpn>09D652G50CF7J28G</Ntpn>
- <Status>
- <Status>
- <isError>false</isError>
- <errorCode>00</errorCode>
- <statusDescription>Payment Sukses</statusDescription>
- </Status>
- </Status>
- <BranchId>00037</BranchId>
- </PaymentsResult>
- </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(xmlPaymentsResponse);
- } 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(3123, () => {
- console.log('SOAP dummy running at http://localhost:3123/dummy-mpn');
- });
|