PHP code example of 3neti / hyperverge

1. Go to this page and download the library: Download 3neti/hyperverge 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/ */

    

3neti / hyperverge example snippets


use LBHurtado\HyperVerge\Services\SelfieLivenessService;

$service = app(SelfieLivenessService::class);
$result = $service->verify($base64Image);

if ($result->isLive) {
    // Selfie is live
}

use LBHurtado\HyperVerge\Services\FaceMatchService;

$service = app(FaceMatchService::class);
$result = $service->match($referenceImage, $selfieImage);

if ($result->isMatch) {
    echo "Confidence: {$result->confidence}";
}

use LBHurtado\HyperVerge\Services\LinkKYCService;

$service = app(LinkKYCService::class);
$session = $service->createSession([
    'redirectUrl' => 'https://yourapp.com/callback',
]);

use LBHurtado\HyperVerge\Services\ResultsService;

$service = app(ResultsService::class);
$result = $service->fetch($sessionId);

echo $result->applicationStatus;

use LBHurtado\HyperVerge\Traits\HasFaceVerification;

// Add trait to your model
class User extends Model implements HasMedia
{
    use InteractsWithMedia, HasFaceVerification;
}

// Enroll reference selfie
$user->enrollFace(
    selfie: $request->file('selfie'),
    checkLiveness: true,
    metadata: ['enrolled_at' => now(), 'ip' => $request->ip()]
);

$result = $user->verifyFace(
    selfie: $request->file('selfie'),
    context: ['action' => 'login', 'ip' => $request->ip()]
);

if ($result->verified) {
    Auth::login($user);
    echo "Match confidence: {$result->matchConfidence}";
} else {
    echo "Failed: {$result->failureReason}";
}

if ($user->hasReferenceSelfie()) {
    // User can verify by face
}

// Get statistics
$stats = $user->getFaceVerificationStats();
echo "Success rate: {$stats['success_rate']}%";

use LBHurtado\HyperVerge\Actions\Document\GenerateVerificationQRCode;

// Generate QR code with verification URL
$qrData = GenerateVerificationQRCode::run(
    url: 'https://yourapp.com/verify/campaign-uuid/transaction-id',
    size: 300,
    margin: 10
);

// Returns:
// [
//     'data_uri' => 'data:image/png;base64,...',  // For embedding in images
//     'file_path' => '/tmp/qr_abc123.png',        // Physical file path
//     'url' => 'https://...',                     // Original URL
//     'size' => 300,                              // QR dimensions
//     'margin' => 10,                             // QR margin
// ]

use LBHurtado\HyperVerge\Actions\Document\AddQRWatermarkToPDF;

// Add QR code to PDF (bottom-right corner by default)
$watermarkedPdf = AddQRWatermarkToPDF::run(
    pdfPath: $signedPdfPath,
    qrCodePath: $qrData['file_path']
);

// With custom options
$watermarkedPdf = AddQRWatermarkToPDF::run(
    pdfPath: $signedPdfPath,
    qrCodePath: $qrData['file_path'],
    page: -1,              // -1 = last page, 0 = all pages, 1+ = specific page
    position: 'bottom-right',
    size: 100,             // QR size in pixels
    opacity: 100           // 0-100% opacity
);

use LBHurtado\HyperVerge\Actions\Certificate\GenerateVerificationCertificate;

$certificatePath = GenerateVerificationCertificate::run(
    model: $submission,
    transactionId: $transactionId,
    options: [
        'verificationUrl' => route('verify', [$uuid, $transactionId]),
        'metadata' => [
            'campaign' => $campaign->name,
            'campaign_id' => $campaign->id,
        ],
    ]
);
// Certificate automatically 

use LBHurtado\HyperVerge\Actions\Document\MarkDocumentWithKYC;

// Signs document, adds QR watermark, stores in media library
$result = MarkDocumentWithKYC::run(
    model: $submission,
    transactionId: $transactionId,
    additionalMetadata: [
        'signer' => $submission->name,
        'purpose' => 'Identity Verification',
    ],
    tile: 1,  // Signature position (1-9 for multi-signer)
    logoPath: public_path('images/logo.png')
);

// Returns:
// [
//     'stamp' => $signatureMark,      // Media object for signature stamp
//     'signed_document' => $signedDoc, // Media object for signed PDF with QR
// ]

// config/hyperverge.php

'qr_code' => [
    'enabled' => true,
    'default_size' => 300,
    'margin' => 10,
    'error_correction' => 'H', // L, M, Q, H (7%, 15%, 25%, 30%)
],

'document_signing' => [
    'qr_watermark' => [
        'enabled' => true,
        'position' => 'bottom-right',  // Any 9 positions supported
        'size' => 100,                 // QR size in pixels (~0.33 inches at 300 DPI)
        'page' => -1,                  // -1 = last page, 0 = all, 1+ = specific
        'opacity' => 100,              // 0-100% opacity
    ],
],

   config('hyperverge.document_signing.qr_watermark.enabled')
   

   $qr = GenerateVerificationQRCode::run('https://example.com');
   dd(file_exists($qr['file_path']));
   
bash
php artisan vendor:publish --provider="LBHurtado\HyperVerge\HypervergeServiceProvider"
bash
cd packages/hyperverge-php
../../vendor/bin/pest