avetrust / sdk
SDK PHP officiel d'AveTrust — vérification d'identité (eKYC) : sessions, résultats, webhooks signés, sandbox.
v0.1.0
2026-08-03 16:26 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpunit/phpunit: ^11.0
README
SDK PHP officiel d'AveTrust — vérification d'identité de niveau forensique (eKYC). Sessions, résultats, webhooks signés, sandbox.
Installation
composer require avetrust/sdk
PHP ≥ 8.1.
Démarrage rapide
use AveTrust\AveTrust;
$av = new AveTrust('sk_test_…'); // clé test → sandbox
$v = $av->verifications->create([
'checks' => ['DOCUMENT', 'LIVENESS', 'FACE_MATCH'],
'callbackUrl' => 'https://mon-app/kyc/webhook',
'simulate' => 'approved', // ignoré hors sandbox
]);
$av->verifications->sendLink($v['id'],
channel: 'EMAIL', to: 'client@exemple.com',
link: "https://verify-test.avetrust.net/s/{$v['token']}");
Recevoir le résultat (webhook)
Vérifiez toujours la signature (corps brut) :
$payload = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_AVETRUST_SIGNATURE'] ?? null;
try {
$event = $av->webhooks->constructEvent($payload, $sig, getenv('AVETRUST_WEBHOOK_SECRET'));
} catch (\AveTrust\Exception\SignatureVerificationException) {
http_response_code(400); exit;
}
if (!$event['livemode']) { http_response_code(200); exit; } // sandbox
if ($event['data']['decision']['outcome'] === 'APPROVED') {
activateAccount($event['data']['externalUserId'] ?? null);
}
Sandbox
Clé sk_test_… : aucun appel réel, gratuit, verdict déterministe via simulate. Webhooks avec livemode => false.
Erreurs typées
use AveTrust\Exception\{AuthenticationException, RateLimitException, AveTrustException};
try {
$av->verifications->create();
} catch (AuthenticationException) { /* clé invalide */ }
catch (RateLimitException) { /* quota */ }
catch (AveTrustException $e) { error_log("$e->errorCode $e->status"); }
API
| Méthode | Description |
|---|---|
verifications->create($params) | Crée une session (id + token) |
verifications->retrieve($id) / result($id) / list($params) | Lecture |
verifications->sendLink($id, channel:, to:, link:) | Lien hébergé |
verifications->decide($id, $outcome, $note) | Décision manuelle |
apiKeys->list() / create($name, $env) / revoke($id) | Clés |
webhooks->constructEvent($payload, $sig, $secret) | Vérifie + décode |
Licence
© AveTrust — usage réservé.