API client for Yousign · French eSignature solution.

Last update: Jul 27, 2022

CyrilBochet/YousignApiClient

README translation

Client API pour Yousign · solution de signature électronique française.

Sommaire

Procédure simple

use YousignApiClient\YousignApiClient;

// Votre clé API
$apikey = 'API_KEY';
$env = 'test';

$client = new YousignApiClient($apikey, $env);


// Nouvelle procédure
$client->newProcedure('test.pdf');

$members = array(
   array(
       'firstname' => 'Cyril',
       'lastname' => 'Bochet',
       'email' => '[email protected]',
       'phone' => '0102030405',
       'fileObjects' => array(
           array(
           'file' => $client->getIdfile(),
               'page' => 1,
               'position' => "202,205,389,284",
               'mention' => "Lu et approuvé",
               "mention2" => ""
           )
       )
       // Autre membre, etc.
   )
);

$client->addMembersToProcedure($members, 'Procédure test', 'Signature test.');

Procédure avancée

En créant une procédure avancée vous pouvez utiliser des webhooks.

Exemple : Yousign peut vous envoyer une notifcation webhook lorsqu'une personne signe votre document.

Vous pouvez mettre en place une URL qui va traiter la notification envoyée par Yousign.
Ensuite vous traiter la requête selon vos besoins. (mail, enregistrement du statut de la procédure, etc.)
Une procédure avancée vous permet également de créer des notifications mails.

Exemple : vous pouvez créer une notification lorsqu'une personne refuse de signer votre document. (déclencheur : "procedure.refused")

use YousignApiClient\YousignApiClient;

// Votre clé API
$apikey = 'API_KEY';
$env = 'test';

$client = new YousignApiClient($apikey, $env);


// Paramètres de la procédure
$parameters = array(
    'name' => "Ma procédure avancée",
    'description' => "Création d'une procédure avancée.",
    'start' => false
);

// Création de la procédure
// Liste des déclencheurs (mails et webhooks) : "procedure.started", "procedure.finished", "procedure.refused", "member.started", "member.finished"
    
    $emails = [
        "member.started" => array(
            "subject" => "Hey! You are invited to sign!",
            "message" => "Hello <tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> <tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag>, <br><br> You have ben invited to sign a document, please click on the following button to read it: <tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag>",
            "to" => ["@member"]),
        "procedure.refused" => array(
            "subject" => "John, created a procedure.",
            "message" => "The content of this email is totally awesome.",
            "to" => ["@creator", "@members"]),
            //etc.
    ];
    
    $webhooks = [
        "member.started" => array(
            "url" => "https://testyousign.requestcatcher.com",
            "method" => "POST",
            "headers" => array(
                "X-Custom-Header" => 'test'
            )),
            //etc.
    ];


$client->newAdvancedProcedure($parameters);

$filePath = 'file.pdf';
$fileName = 'file.pdf';


// On ajoute le fichier à signer
$client->advancedProcedureAddFile($filePath, $fileName);

// On définit le·s différent·s emplacement·s de signature
$emplacementsSignature = array(
  [
    'position' => '64,71,245,142',
    'page' => 2,
    'mention' => 'Certifié exact et sincère.',
    'mention2' => '',
    'reason' => ''
  ],
  [
    'position' => '87,297,270,369',
    'page' => 12,
    'mention' => 'Je certifie avoir bien reçu le document.',
    'mention2' => '',
    'reason' => ''
  ]
);

// On ajoute le·s membre·s à la procédure
$member = $client->advancedProcedureAddMember($prenom, $nom, $mail, $tel, $type);

// On ajoute les emplacements de signature à la procédure
foreach ($emplacementsSignature as $emplacement) {
   $client->advancedProcedureFileObject($emplacement["position"], $emplacement["page"], $emplacement["mention"], $emplacement["mention2"], $emplacement["reason"]);
}

// On lance la procédure
$client->advancedProcedureStart();

Téléchargement d'un fichier

// Pour l'exemple je télécharge le fichier directement après avoir lancé la procédure, mais en utilisant les webhooks vous pouvez le télécharger à n'importe quel moment.
// le fichier que l'on souhaite télécharger
$file = $client->advancedProcedureAddFile($filePath, $fileName);
$client->advancedProcedureStart();

// On récupère le fichier en base64 ou en binaire
$binary=false;
$client->downloadFile($file['id'], $binary);

Récupérer les utilisateurs

$client->getUsers();

Gestion des tags (message du mail)

Syntax Description
<tag data-tag-type=\"button\" data-tag-name=\"url\" data-tag-title=\"Access to documents\">Access to documents</tag> Show a stylized link to access to the procedure. If the recipent is a member, it will be redirect to the sign view. url params is required but you can change as your convenience the string "Access to documents"
<tag data-tag-type=\"string\" data-tag-name=\"recipient.firstname\"></tag> It will display the firstname of the recipient.
<tag data-tag-type=\"string\" data-tag-name=\"recipient.lastname\"></tag> It will display the lastname of the recipient.
<tag data-tag-name="procedure.files" data-tag-type="list"></tag> It will list files that have been added to a procedure.
<tag data-tag-name="procedure.members" data-tag-type="list"></tag> It will list members of a procedure.
<tag data-tag-name="procedure.expiresAt" data-tag-type="date" data-tag-date-format="SHORT" data-tag-time-format="NONE" data-tag-locale="fr_FR"></tag> It will display the expiration date formatted like that : 04/31/2018. Allowed values for data-tag-date-format and data-tag-time-format: **NONE**: Does not display the element // **FULL**: Tuesday, April 12, 1952 AD or 3:30:42pm PST // **LONG**: January 12, 1952 or 3:30:32pm // **MEDIUM**: Jan 12, 1952 // **SHORT** (default value for both parameters): 12/13/52 ou 3:30pm

Liens utiles / Useful links

Pour connaitre les coordonnées d'un emplacement de signature : https://placeit.yousign.fr

Documentation complète de l'API Yousign : https://dev.yousign.com

GitHub

https://github.com/CyrilBochet/YousignApiClient
You might also like...

Google PHP API Client Services

Google PHP API Client Services

Aug 7, 2022

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP. Including adding reviews to a store's products. It is used to import and export reviews through the API. This is the official package built and developed by A2Reviews, Inc.

Sep 25, 2021

PHP Client for the GoFlink API

GoFlink PHP API Client This project is an unofficial library to communicate with the GoFlink API from your PHP project. Documentation about the API is

Dec 30, 2021

A PHP client for the official Kizeo Forms API V3+. 📌

Kizeo Forms API V3+ - PHP This is a Swagger generated doc for Kizeo REST API 3. You can find additionnal documentation here : Online documentation. Th

Oct 26, 2021

⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Aug 6, 2022

Shopee Open API v2 Client build with php

Shopee PHP Client This is a Shopee PHP Client, currently supported for API V2 in ShopeeOpenPlatform Composer Install composer require haistar/shopee-p

Jun 14, 2022

Private Packagist API Client

Private Packagist API Client Table of Contents Private Packagist API Client Table of Contents Requirements Install Basic usage of private-packagist/ap

Jul 8, 2022

Spikkl API client for Laravel

Spikkl for Laravel Spikkl-php-laravel-client incorporates the Spikkl API into your Laravel or Lumen project. Requirements Get yourself a free Spikkl a

Jul 17, 2022

GitLab PHP API Client

GitLab PHP API Client

GitLab PHP API Client We present a modern GitLab API v4 client for PHP. This is strongly based on php-github-api by KnpLabs. With this in mind, we now

Aug 4, 2022
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Aug 14, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Feb 14, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Jul 27, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Jul 21, 2022
API client for ThePay - payment gate API
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

May 23, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

Aug 13, 2022
A simple Object Oriented PHP Client for Termii SMS API

Termii Client A simple Object Oriented PHP Client for Termii SMS API. Uses Termii API. Requirements PHP >= 7.2 Guzzlehttp ~6|~7 Installation Via Compo

Feb 24, 2022
Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Aug 4, 2022
php 8 client for the lemon.markets api

lemon.markets php client This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be fo

Dec 21, 2021
PHP client for Microsoft Azure Face API.

Microsoft Azure Face API PHP client A PHP library that utilizes Azure Face REST API. Requirements PHP >= 7.4 Installation composer require darmen/php-

May 20, 2022