PHP code example of shaggyrec / sumsubphp

1. Go to this page and download the library: Download shaggyrec/sumsubphp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shaggyrec / sumsubphp example snippets


use Shaggyrec\SumSubClient\SumSubClient;

$sumSub = SumSubClient::getInstance('App Token', 'APP Secret');

$sumSub->getAccessToken('userId', 'levelName');

$sumSub->getAccessToken('userId', 'levelName');

$sumSub->createApplicant(
    'externalUserId',
    'phone',
    'email',
    new FixedInfo(
        [
            firstName => 'firstName', 
            lastName => '',
            middleName => '',
            firstNameEn => '',
            lastNameEn => '',
            middleNameEn => '',
            legalName => '',
            gender => 'M',
            dob => '',
            placeOfBirth => '',
            country => '',
            nationality => '',
            addresses => [],
        ],
    )
    'levelName',
);

$sumSub->changeLevel('applicantId', 'levelName');

use Shaggyrec\Sumsubphp\DTO\FileMetadata;

$sumSub->addDoc(
    '$applicantId',
    new FileMetadata(
        [
            'idDocType' => 'PASSPORT', 
            'country' => 'USA',
            'firstName' => '',
            'middleName' => '',
            'lastName' => '',
            'issuedDate' => '2015-01-02',
            'number' => '40111234567',
            'dob' => '2000-02-01',
            'placeOfBirth' => 'London'
    ],
    $content, // A binary photo of a document
);

$sumSub->getApplicantById('applicantId');

$sumSub->getApplicantByExternalUserId('yourId');


use Shaggyrec\Sumsubphp\DTO\FixedInfo;

$sumSub->changeProvidedInfo(
    'applicantId',
    new FixedInfo(
        [
            firstName => 'firstName', 
            lastName => '',
            middleName => '',
            firstNameEn => '',
            lastNameEn => '',
            middleNameEn => '',
            legalName => '',
            gender => 'M',
            dob => '',
            placeOfBirth => '',
            country => '',
            nationality => '',
            addresses => [],
        ],
    ),
);

$sumSub->getApplicantStatus('applicantId'); 

$sumSub->getRequiredIdDocsStatus('applicantId');

$sumSub->requestCheck(
    'applicantId',
    'reason', // optional
);

$sumSub->getDocumentImage(
    'inspectionId', // Inspection ID (it's a part of an applicant
    'imageId'
);

$sumSub->addToBlacklist('applicantId', 'note')

$sumSub->resetSingleVerificationStep('applicantId', 'step');


$sumSub->resetApplicant('applicantId'); 
 
$sumSub->setRiskLevel(
    'applicantId',
    'riskLevel', // unknown|low|medium|high
    '$comment', // Any string
);
 
$sumSub->markImageDeleted('inspectionId', 'imageId');
 
$sumSub->addTags('applicantId', ['tag1', 'tagg2]);

use Shaggyrec\SumSubClient\WebhookHandler;

...
// to verify sender
WebhookHandler::verifySender('x-payload-digest header', $webhookBody, 'secret key')

// to get WebhookResponse object
$webhookResponse = WebhookHandler::handle($webhookBody);

use Shaggyrec\SumSubClient\WebhookHandler;

... 

/** @var Psr\Http\Message\RequestInterface $webhookBody */
$webhookBody;
$webhookResponse = WebhookHandler::handleWithVerification($webhookBody, 'SECRET KEY');