0.1.0 • Published 11 months ago

pavelon-enhanced-kyc v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago
import EnhancedKyc from 'pavelon-enhanced-kyc';

const enhanced = new EnhancedKyc({
  senderId?: string  //required for phone verification
  privateKey: string
  accessKey: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.send_verification_code() method. It takes a phonenumber parameter as its input, which is passed as the phone property to the enhanced.phonenumber() method.

  async function onSend() {
    try {
      const response = await enhanced.send_verification_code({ phonenumber: '<string>' });
        //handle successful sent code here
      
      console.log(response);
      
    } catch (error) {
     //handle error here
     
      console.log(error);
    }
  }
  

Define the verify_verification_code Method: Assume enhanced is an instance of a class that has the verify_verification_code method. This method is expected to take an object with code and phonenumber properties and return a Promise that resolves with the response.

  async function onVerify() {
    try {
      const response = await enhanced.verify_verification_code({ code: '<string>', phonenumber: '<string>' });
    // handle successful verification here
      
      console.log(response);
      
    } catch (error) {
     //handle error here
     
      console.log(error);
    }
  }
  

The handleGhanCardVerification function is an asynchronous function designed to verify Ghana card details by calling the ghana_card_verification method from the enhanced object. It handles both the success and failure cases of the verification process.

async function handleGhanCardVerification () {

  try {
    // Make an API call to verify the Ghana card details
    const response = await enhanced.ghana_card_verification({
      firstName: "<string>",       // The first name of the cardholder
      middleName: "<string>",      // The middle name of the cardholder
      lastName: "<string>",        // The last name of the cardholder
      idNumber: "<string>",        // The ID number on the Ghana card
      dateOfBirth: "<string>",     // The date of birth of the cardholder
      frontImage: "File",          // The file representing the front image of the Ghana card
      backImage: "File",           // The file representing the back image of the Ghana card
      userId: "<string>",          // The user ID associated with the verification request
      referenceNumber: "<string>"  // A reference number for the verification process
    });
    // handle successful verification here
    
    console.log(response);
    
  } catch(error) {
    // handle errors here
    
    console.error(error);
  
  }
};
0.1.0

11 months ago