PAN Verification In Laravel Using Sighzy API

Hello, everyone some day ago we are working with one project and in this project we are required verify PAN card details. user simple put us PAN no., Name, birth date and pind code and system return to response with this PAN card details is verify or not. so, we are done this type functionality with sighzy API. this provide best API for verify PAN details API.

So, we are share with you how to integrate sighzy API in your laravel application. because they are provide document but many devloper still confuse how to integrate it in laravel application. so we are here provide very easy and best way of integration in laravel application.

You Need Following Things

Before start write PAN verify code you must be need one sighzy developer account. so, go on this link and create it https://signzy.com/. after create developer account you got username and password which we are use in PAN verify code for Authentication.

In PAN verification we are write following 3 diffrent API login

1. Create Authentication

2. Create Identity

3. Verify PAN Card

So, we are show here step by step all proccess. how to verify PAN Card.

Step - 1 : Create Authentication

First you need to create authentication for get Authentication userId and Id which we are also use in our Identity


public function ApiAuth()
{
    $data = array(
        'username' => 'username',
        'password' => 'password',
    );

    $data_string = json_encode($data);

    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://signzy.tech/api/v2/patrons/login",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30000,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $data_string,
        CURLOPT_HTTPHEADER => array(
            "accept: */*",
            "accept-language: en-US,en;q=0.8",
            "content-type: application/json"
        ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        return false;
    } else {
        return json_decode($response);
    }
}

Step - 2 : Create Identity

After create Authentication successfully now we are create Identity for PAN. How to create it please show below code.


public function Identity($Auth, $IdentityName) 
{
    $data = [
        'type' => $IdentityName,
        'callbackUrl' => 'http://localhost:8000/verify-aadharcard',
        'email' => 'test@gmail.com',
        'images' => [
            
        ],
    ];

    $curl = curl_init();

    curl_setopt_array($curl, array(        
        CURLOPT_URL => "https://signzy.tech/api/v2/patrons/".$Auth->userId."/identities",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30000,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => json_encode($data),
        CURLOPT_HTTPHEADER => array(
            "accept: */*",
            "accept-language: en-US,en;q=0.8",
            "authorization:".$Auth->id,
            "content-type: application/json"
        ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        return false;
    } else {
        return json_decode($response);
    }

}

Step - 3 : PAN Verification

After done Authentication and create Identity for pan we are write PAN verification code look like this. We also use above two function in PAN verification code.


public function verifyPanCard(Request $request) 
{
    // Create Authentication fo PAN API
    $Auth = $this->ApiAuth();
    if($Auth == false) {
        \Session::put('errors', 'Your Aadhaar API Credentials Wrong!!');
        return back();
    }
    
    // Create Identity fo PAN API
    $Identity =  $this->Identity($Auth, 'businessPan');
    
    if(isset($Identity->error)) {
        \Session::put('error', 'Your Aadhaar API Identity Wrong!!');
        return back();
    }
    if($Identity == false) {
        \Session::put('error', 'Your Aadhaar API Identity Wrong!!');
        return back();
    }
    
    $data1 = [
        'service' => 'Identity',
        'itemId' => $Identity->id,
        'accessToken' => $Identity->accessToken,
        'task' => 'verification',
        'essentials' => [
            'name' => 'NAME ON PAN',
            'number' => 'PAN No.',
            'fuzzy' => "true",
        ],
    ];


    $curl = curl_init();

    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://signzy.tech/api/v2/snoops",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30000,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => json_encode($data1),
        CURLOPT_HTTPHEADER => array(
            "accept: */*",
            "accept-language: en-US,en;q=0.8",
            "content-type: application/json"
        ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        echo "cURL Error #:" . $err;
    } else {
        $data = json_decode($response);
        dd($data);
    }
}

If you face any problem then please write a comment or give some suggestions for improvement. Thanks...

 Prev post

Next post