1. Go to this page and download the library: Download proofage/laravel-client 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/ */
use ProofAge\Laravel\Facades\ProofAge;
use ProofAge\Laravel\Resources\VerificationResource;
// Get workspace information
$workspace = ProofAge::workspace()->get();
// Create a verification
$verification = ProofAge::verifications()->create([
// Where the person's browser is sent after the flow: a page of your app, not a webhook.
// Decisions are POSTed to the workspace's webhook URL, set in the ProofAge console
// (see Webhook Security below).
'callback_url' => 'https://your-app.com/verification/done',
// Your identifiers, echoed back in every response and webhook. `metadata` is also accepted,
// but it is stored internally and never returned, so it cannot be used for correlation.
'external_id' => (string) $user->id,
'external_metadata' => ['plan' => 'pro'],
]);
// Send the person to the hosted verification flow at $verification['url'],
// e.g. redirect()->away($verification['url']); the decision arrives by webhook.
// Get verification details
$verification = ProofAge::verifications()->find('verification-id');
// Get age estimation details
$estimation = ProofAge::verifications('verification-id')->estimation();
// [
// 'verification_id' => '...',
// 'attempt_id' => '...',
// 'age_threshold' => [
// 'minimum' => 18,
// 'passed' => true,
// 'confidence' => 0.98,
// ],
// 'gender' => [
// 'value' => VerificationResource::GENDER_FEMALE, // 0 = female, 1 = male
// 'confidence' => 0.93,
// ],
// ]
// Accept consent: the id and text_sha256 must be exactly those of the active consent version,
// whose text (at $consent['url']) is what the person was shown. Anything else is rejected.
$consent = ProofAge::workspace()->getConsent();
ProofAge::verifications('verification-id')->acceptConsent([
'consent_version_id' => $consent['id'],
'text_sha256' => $consent['text_sha256'],
]);
// Upload media: images only. `type` is selfie or document; a document also
// needs `side` (front|back) and `document` (id|driver_license|passport|residence_permit).
ProofAge::verifications('verification-id')->uploadMedia([
'type' => 'selfie',
'file' => $request->file('selfie'),
]);
ProofAge::verifications('verification-id')->uploadMedia([
'type' => 'document',
'side' => 'front',
'document' => 'passport',
'file' => $request->file('passport_front'),
]);
// Submit verification; the decision arrives by webhook
ProofAge::verifications('verification-id')->submit();
use ProofAge\Laravel\ProofAgeClient;
$client = app(ProofAgeClient::class); // app(\ProofAge\Sdk\Client::class) resolves the same singleton
$workspace = $client->workspace()->get();
// Lower level: makeRequest() returns a ProofAge\Sdk\Http\Response
$response = $client->makeRequest('GET', 'workspace');
$response->status();
$response->json();
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use ProofAge\Laravel\ProofAgeClient;
use ProofAge\Sdk\Events\ResponseEvent;
use ProofAge\Sdk\Http\Request;
use ProofAge\Sdk\Http\Response;
$client = app(ProofAgeClient::class);
$client->pushMiddleware(fn (Request $request, callable $next): Response => $next(
$request->withHeader('X-Request-Id', (string) Str::uuid())
));
$client->onResponse(fn (ResponseEvent $e) => Log::info('proofage.response', [
'status' => $e->status(),
'attempt' => $e->attempt(),
'ms' => $e->durationMs(),
]));
use ProofAge\Laravel\Exceptions\AuthenticationException; // 401
use ProofAge\Laravel\Exceptions\ValidationException; // 422, getErrors()
use ProofAge\Sdk\Exceptions\TransportException; // connection refused, DNS, TLS, timeout
use ProofAge\Sdk\Exceptions\ProofAgeException; // every other non-2xx, and the base class of all of the above
try {
$verification = ProofAge::verifications()->create($data);
} catch (AuthenticationException $e) {
// 401: $e->getErrorCode()
} catch (ValidationException $e) {
// 422: $e->getErrors()
} catch (TransportException $e) {
// The API could not be reached; $e->getResponse() is null
} catch (ProofAgeException $e) {
// Everything else: $e->getCode() is the HTTP status, $e->getResponse() the ProofAge\Sdk\Http\Response
}