dummyVASKOM.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const http = require('http');
  2. const PORT = 7090;
  3. const server = http.createServer((req, res) => {
  4. if (req.method === 'POST') {
  5. let body = '';
  6. req.on('data', chunk => {
  7. body += chunk.toString();
  8. });
  9. req.on('end', () => {
  10. try {
  11. const parsedBody = JSON.parse(body);
  12. console.log ("not parsed")
  13. console.log(body)
  14. console.log("parsed")
  15. console.log(parsedBody)
  16. const customMessage = {
  17. "cnl": "NBDS",
  18. "tno": null,
  19. "data": {
  20. "trxAmount": "10000",
  21. "feeAmount": "0",
  22. "narative": "PRIMO-9072",
  23. "reffNoRev": "",
  24. "accNoTo": "1601300001199",
  25. "narativeExt": "",
  26. "vaNo": "",
  27. "invoiceNo": "",
  28. "accNoFrom": "1401300014178",
  29. "accPoolingFrom": "1401300014178",
  30. "accNameTo": "BPG 022 KPP P SOREANG",
  31. "accPoolingTo": "1601300001199",
  32. "accPoolingNameTo": "RKK DJPP PUPR OPS II",
  33. "balanceTo": "83007374396"
  34. },
  35. "procode": "0200.000020.000001VAD",
  36. "iss": "--",
  37. "mid": null,
  38. "exp_iso8601": "2026-06-15T16:28:25+07:00",
  39. "bic": "BTNIDJA",
  40. "iat": 1781515405,
  41. "jti": "500540799991",
  42. "tid": "99991"
  43. };
  44. res.writeHead(200, { 'Content-Type': 'application/json' });
  45. res.end(JSON.stringify(customMessage));
  46. } catch (error) {
  47. res.writeHead(400, { 'Content-Type': 'application/json' });
  48. res.end(JSON.stringify({ error: "Invalid JSON" }));
  49. }
  50. });
  51. } else {
  52. res.writeHead(405, { 'Content-Type': 'application/json' });
  53. res.end(JSON.stringify({ error: "Only POST allowed" }));
  54. }
  55. });
  56. server.listen(PORT, () => {
  57. console.log(`Server running at http://localhost:${PORT}/`);
  58. });