oliviernival/yousign-client-api-v3-2024

2024年发布的yousign API V3客户端

v1.0.4 2024-09-06 08:17 UTC

This package is auto-updated.

Last update: 2024-09-06 08:18:16 UTC


README

yousign API V3 2024 PHP客户端

Yousign官方网站,文档

https://developers.yousign.com/docs/introduction-new

安装

通过composer

composer require oliviernival/yousign-client-api-v3-2024

使用

<?php
require_once '/path/to/vendor/autoload.php';
$apikey = "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"       => "john.doe@example.com",
        "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();

webhook

我们可以通过API创建最多5个webhook

这允许我们告诉Yousign在不同签名阶段发送包含信息的请求。因此,我们有创建在所有阶段或仅在某些阶段发出警报的webhook的能力。

// 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);