The Enhanced SDK for Phone Number Verification and ID Verification is a JavaScript library that can be used with React and React Native applications. This library allows developers to easily integrate phone number verification and ID verification features into their applications.
To install the Enhanced SDK for Phone Number Verification and ID Verification, simply run the following command:
yarn add pavelon-verify-kyc
To use the Enhanced SDK for Phone Number Verification and ID Verification, import it into your JavaScript or TypeScript code and initialize it with your Auth Token, Private Key, App Id & domain Id key
import EnhancedKyc from 'pavelon-verify-kyc';
const enhanced = new EnhancedKyc({
senderId: string //required for otp verification
authToken: string
appId: string
domainId: string
otpLength: string
})
The onSend() function is an asynchronous function that sends an OTP (One Time Password) to a specified phone number using the enhanced.sendOtp() method. It takes a phoneNumber parameter as its input, which is passed as the phone property to the enhanced.sendOtp() method.
async function onSend() {
try {
const response = await enhanced.sendOtp({ phone: phone });
// handle successful sent code here
console.log(response);
} catch (error) {
//handle error here
console.log(error);
}
}
The onVerify() function is an asynchronous function that verifies an OTP (One Time Password) for a specified phone number using the enhanced.verifyOtp() method. It takes a code parameter as its input, which is passed as the verifyCode property to the enhanced.verifyOtp() method.
async function onVerify() {
try {
const response = await enhanced.verifyOtp({ verifyCode: code });
// handle successful verification here
console.log(response);
} catch (error) {
//handle error here
console.log(error);
}
}
The verification() method is designed to support various types of identification verification, including passports, national IDs, SSNIT, driver's licenses, TIN, and digital address verification, it is intended to provide a consistent and scalable way to verify multiple types of identification. Depending on the specific use case, the verification process for each type of identification may have different requirements and validation steps. However, this method can be used as a general-purpose function for handling these requirements.
async function onIDVerify () {
try {
const response = await enhanced.verification({
passport: {
id: "AB123456",
firstName: "John",
lastName: "Doe",
middleName: "",
dob: "01/01/1980"
}
});
// handle successful verification here
console.log(response);
} catch(error) {
// handle errors here
console.error(error);
}
};
async function verification() {
const formData = new FormData();
formData.append("nameOnCard", string);
formData.append("idNumber", string);
formData.append("idPhoto", File);
formData.append("userId", string); //optional
try {
const response = await config.ghanaCard(formData);
console.log(response);
} catch (error) {
console.log(error);
}
}
//digital address verification
digitalAddress: {
digitalAddress: "",
},
//driver license verification
driver_license: {
id: "",
fullName: "",
dob: ""
}
//tin number verification
tin: "",
ssnit: {
id: "",
fullName: "",
dob: ""
},
//passport verification
passport: {
id: "",
firstName: "",
lastName: "",
middleName: "",
dob: ""
},
//voter's id verification
voter: {
id: "",
fullName: "",
},
};