Created
October 3, 2019 17:08
-
-
Save bilashcse/401a82edf126b33079cfdceab66cda4a to your computer and use it in GitHub Desktop.
Porichoi NID Verification API NodeJs Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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