Skip to content

Instantly share code, notes, and snippets.

@bilashcse
Created October 3, 2019 17:08
Show Gist options
  • Save bilashcse/401a82edf126b33079cfdceab66cda4a to your computer and use it in GitHub Desktop.
Save bilashcse/401a82edf126b33079cfdceab66cda4a to your computer and use it in GitHub Desktop.
Porichoi NID Verification API NodeJs Implementation
const request = require('request-promise-native');
const verificationEndPoint = 'end_point';
const subscriptionKey = 'subscription_key';
async function verify({ nidNumber, fullName, dob }) {
let response = await request({
method: 'POST',
qs: {
national_id: nidNumber,
person_dob: dob,
person_fullname: fullName
},
url: verificationEndPoint,
headers: {
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': subscriptionKey
},
json: true
});
if (typeof response === 'string') {
response = response.replace(/'/g, '"');
response = JSON.parse(response);
}
if (response.passKyc && (response.passKyc === 'true' || response.passKyc === 'yes')) {
return { nid: nidNumber, valid: true };
}
return { nid: nidNumber, valid: false };
}
module.exports = {
verify
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment