PHP code example of oliviernival / yousign-client-api-v3-2024

1. Go to this page and download the library: Download oliviernival/yousign-client-api-v3-2024 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/ */

    

oliviernival / yousign-client-api-v3-2024 example snippets

 
composer 


ey = "votre-clef-yousign";
$mode = "prod"; // ou "dev" pour url de dev de yousign
$client = new NvlYousignClientApiV3\NvlYousignClientV3($apikey,$mode);
$opt = [
            "name" => "le nom de ma signature",
            "delivery_mode" => "email",
            "timezone" => "Europe/Paris",
        ];

// initialisation        
$reqSignature = $client->newSignatureRequest($opt);

// ajout du doc à signer
$addDoc = addDocument($pdfDocumentPath)

// on ajoute une personne qui doit signer

$signer = [
    "info" => [
        "first_name"  => "John",
        "last_name"   => "Doe",
        "email"       => "[email protected]",
        "phone_number"=> "+33700000000",
        "locale"      => "fr"
    ],
    "signature_authentication_mode" => "no_otp",
    "signature_level" => "electronic_signature",
    "fields" => [
        [
            "document_id"=> $client->getDocumentId(),
            "type"  => "signature",
            "height"=> 37,
            "width" => 85,
            "page"  => 1,
            "x"     => 0,
            "y"     => 0]
    ]
];

$addSigner = $client->addSigner($signer);

// on active la signature a partir de ce moment le document peut être signé par les personnes
        
$client->activateSignatureRequest();

// création du webhook

// webhook pour avoir tous les events :
// la V3 de Yousign permet la création de 5 Webhook differents
        
$params = [
    "sandbox"           => true,
    "auto_retry"        => true,
    "enabled"           => true,
    "subscribed_events" => ["*"],
    "endpoint"          => "https://mondomaine.com/routequirecoiteventyousign",
    "description"       => "all event "
];
$client->createWebhook($params);