//let params = '{"groupHeader":{"messageIdentification":"BCA231220242992 2023121900000421519","creationDateTime":"2023-12-20T00:12:39.761Z","numberOfTransactions":"1","settlementInformation":{"settlementMethod":"CLRG","clearingSystem":{"proprietary":"LYXCT"}}},"creditTransferTransactionInformation":[{"paymentIdentification":{"instructionIdentification":"Not Provided","endToEndIdentification":"FraudTesting002","transactionIdentification":"BCA231220242992"},"paymentTypeInformation":{"serviceLevel":[{"code":"G001"}],"localInstrument":{"proprietary":"IBIP"}},"interbankSettlementAmount":{"amount":"30.00","activeCurrencyCode":"CAD"},"interbankSettlementDate":"2023-12-19","instructedAmount":{"amount":"30.00","activeCurrencyCode":"CAD"},"chargeBearer":"SHAR","instructingAgent":{"financialInstitutionIdentification":{"BICFI":"BOFMCAM0"}},"instructedAgent":{"financialInstitutionIdentification":{"clearingSystemMemberIdentification":{"clearingSystemIdentification":{"code":"NOTPROVIDED"}}}},"debtor":{"name":"Txmg489","postalAddress":{"addressLine":["Tsk04","Toronto,ON,Q7P 2G1 CA"]}},"debtorAccount":{"identification":{"other":{"identification":"0000000000000990000000000000011","schemeName":{"proprietary":"MECH"}}}},"debtorAgent":{"financialInstitutionIdentification":{"BICFI":"BOFMCAM0","name":"","postalAddress":{"addressLine":[""]}}},"creditorAgent":{"financialInstitutionIdentification":{"BICFI":"ROYCCAT2XXX","name":"Royal Bank of Canada","postalAddress":{"addressLine":["180 Wellington St. W. - 8th Floor","Toronto ON M5J 1J1 CA"]}}},"creditor":{"name":"Txmg489","postalAddress":{"addressLine":["Tsk04","Toronto,ON,Q7P 2G1 CA"]}},"creditorAccount":{"identification":{"other":{"identification":"00000000011DD"}}}}]}'; let params = '{"header":{"x-api-key":"XXXDummy","x-app-cat-id":"85456","x-event-type":"DPSHBCACCOP","x-fapi-financial-id":"001","x-request-id":"WRSSFraudId"},"body":"{"groupHeader":{"messageIdentification":"BCA231229000006 2023101000058148957","creationDateTime":"2023-10-10T12:51:07.061Z","numberOfTransactions":"1","settlementInformation":{"settlementMethod":"CLRG","clearingSystem":{"proprietary":"BKP"}}},"creditTransferTransactionInformation":{"paymentIdentification":{"instructionIdentification":"OP000166835","endToEndIdentification":"Not Provided","transactionIdentification":"BCA231229000006"},"paymentTypeInformation":{"serviceLevel":[{"code":"G001"}],"localInstrument":{"proprietary":"ISO"}},"interbankSettlementAmount":{"amount":"475.00","activeCurrencyCode":"CAD"},"interbankSettlementDate":"2023-10-10","instructedAmount":{"amount":"475.00","activeCurrencyCode":"CAD"},"chargeBearer":"SHAR","instructingAgent":{"financialInstitutionIdentification":{"BICFI":"BOFMCAM2"}},"instructedAgent":{"financialInstitutionIdentification":{"BICFI":"LOYDGB2L","clearingSystemMemberIdentification":{"clearingSystemIdentification":{"code":"NOTPROVIDED"}}}},"intermediaryAgent1":{"financialInstitutionIdentification":{"BICFI":"LOYDGB2L","name":"LLOYDS BANK PLC (LONDON)","postalAddress":{"addressLine":["U.K. INTERNATIONAL SERVICES","11-15 MONUMENT STREET","LONDON,EC3R 8EN GB"]}}},"intermediaryAgent1Account":{"identification":{"other":{"identification":"31691039255DT"}},"financialInstitutionIdentification":{"BICFI":"","name":"","postalAddress":{"addressLine":[""]}}},"debtor":{"name":"THE PHARMACY EXAMINING BOARD OF CAN","postalAddress":{"addressLine":["59 HAYDEN ST UNIT 200","TORONTO","ON CA M4Y0E7"]}},"debtorAccount":{"identification":{"other":{"identification":"04201054679","schemeName":{"proprietary":"MECH"}}}},"creditorAgent":{"financialInstitutionIdentification":{"BICFI":"BOFMCAM2","name":"LLOYDS BANK","postalAddress":{"addressLine":["CAXTON GATE 40-42 NEW ST","BIRMINGHAM B2 4EG","GB"]}}},"creditor":{"financialInstitutionIdentification":{"name":"ADERINLEWO ADESUNKANMI","postalAddress":{"addressLine":["47 DENTON CLOSE BOTLEY OXFORD ,OX2","9BW GB"]}}},"creditorAccount":{"identification":{"IBAN":"GB10LOYD77857073493868","other":{"identification":""}}},"remittanceInformation":{"unstructured":["R"]}}}"};' var debtorJson = JSON.parse(params); let debtorIdentification = debtorJson.body.creditTransferTransactionInformation[0].debtorAccount.identification.other.identification; let trxId = debtorJson.body.creditTransferTransactionInformation[0].paymentIdentification.transactionIdentification; //DecisionCode let approveArr = ['4837370497', '4201054679', "2308995971", "4838217145", "0002379865", "1881650589"]; let denyArr = ["4837370498", "4201054676", "2308995970", "4838217144", "0002379864", "1881650588" ]; let onHoldArr = ["4837370496", "4201054674", "2308995975", "4838217146", "0002379866", "1881650587 " ]; let timeoutArr = ["4837370495", "4201054675" ]; debtorAccSlice = debtorIdentification.slice(-10); console.log(approveArr.indexOf(debtorAccSlice)) let decision; if(approveArr.indexOf(debtorAccSlice) > 0){ decision = "Approved"; }else if(denyArr.indexOf(debtorAccSlice) > 0){ decision = "Deny"; }else if(onHoldArr.indexOf(debtorAccSlice) > 0){ decision = "OnHold"; }else if(timeoutArr.indexOf(debtorAccSlice) > 0){ decision = "Timeout"; }else{ decision = "Error"; } let response = { "IRIS": { "Version": 0, "Message": "ModelResponse", "IrisInstance": "IBM_SAFER_PAYMENTS", "MessageTypeId": 619, "SystemTime": new Date().toISOString(), "UniqueRecordId": 33296817, "MessageId": "", "Mandator": [ { "Mandatorname": "Technical Head Mandator", "Revision": 586 }, { "Mandatorname": "Card", "Revision": 93 }, { "Mandatorname": "Account", "Revision": 207 }, { "Mandatorname": "Party", "Revision": 77 }, { "Mandatorname": "BMO", "Revision": 208 } ], "Merging": false, "InstanceStatus": "Ok", "Latency": 37.922799, "Error": "", "ErrorCode": 0 }, "DecisionCode": debtorIdentification, "DecisionDescription": decision, "TxId": trxId } console.log(response);
Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json
.
Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.
Google chrome's javascript engine V8
and is pretty fast.Asynchronous
, event-driven
and works on single-thread model
thus eliminating the dis-advantages of multi-thread model.Express is one of the most popular web application framework in the NodeJS echosystem.
let moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
const _ = require("lodash");
let colors = ['blue', 'green', 'yellow', 'red'];
let firstElement = _.first(colors);
let lastElement = _.last(colors);
console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);
Following are the libraries supported by OneCompiler's NodeJS compiler.