LaravelPackages.net
Acme Inc.
Toggle sidebar
nidrax69/yousign-api-laravel

Package for using YousignApi with laravel > 7.x

12.760
1
2.0.2
About nidrax69/yousign-api-laravel

nidrax69/yousign-api-laravel is a Laravel package for package for using yousignapi with laravel > 7.x. It currently has 1 GitHub stars and 12.760 downloads on Packagist (latest version 2.0.2). Install it with composer require nidrax69/yousign-api-laravel. Discover more Laravel packages by nidrax69 or browse all Laravel packages to compare alternatives.

Last updated

YouSignApiLaravel

Latest Stable Version Total Downloads Latest Unstable Version License Donate

It's a library for Laravel 7 and PHP7 Not tested on previous version.

Library to use YouSign API from doc (dev.yousign.com) with Laravel

Installation

Install using composer

Now require the lib

composer require nidrax69/yousign-api-laravel

Add provider in config.app

'providers' => [
    Nidrax69\YousignApiLaravel\YousignApiLaravelServiceProvider::class,
];

'aliases' => [
    'YousignApiLaravel' => Nidrax69\YousignApiLaravel\Facade\YousignApiLaravel::class,
];

Complete informations inside your .env file (contact YouSign to get Credentials) and then

YOUSIGN_KEY=
YOUSIGN_API_URL=

Usage

Create Procedure with webhooks , files and members

use Nidrax69\YousignApiLaravel\YousignApiLaravel;

class DocumentController extends Controller
{

  public function sign(Request $request) {
    $client = new YousignApiLaravel();

    // see all possibilities at https://dev.yousign.com/
    $client->setProcedureKeyValue('name', 'Yousign');
    $client->setProcedureKeyValue('description', 'Description procedure');
    // to set default expiration date to the signature
    $client->setProcedureKeyValue('expiresAt', '2022-04-24');

    // add webhooks 
    // you can add different headers
    $webhookUrl = env('API_URL') . 'yousign/';
    $client->addWebhook('member.finished', $webhookUrl . 'signature', 'GET', array(
        "X-Custom-Header" => $type . '-signature',
    ));
    $client->addWebhook('procedure.refused', $webhookUrl . 'refused', 'GET', array(
        "X-Custom-Header" => $type . '-signature',
    ));
    // procedure created but not ready for signature
    $procedure = $client->createProcedure();

    // Allows you to define the content of SMS. {{code}} will be used to define the security code managed by Yousign.
    // up to 150 characters
    $client->addSmsContent('DIGITAL SIGNATURE - {{code}} is your security code to sign your documents.');

    // add files to procedure
    $file = $client->addFile($namefile, $document->url, $procedure['id']);

    // add member to sign the documents
    $member = $client->addMember($user->firstname, $user->lastname, $user->email, $user->phone, $procedure['id']);

    // to determine the last page of your file
    $lastPageNumber = $this->getNumPagesInPDF($document->url);

    $reason = "Signed by " . $user->firstname . " " . $user->lastname . " (Yousign)";
    
    // to determine position see https://placeit.yousign.fr/
    $fileObject = $client->addFileObject($file['id'], $member['id'], $position, $reason, $lastPageNumber);

    // start the signature process
    $client->launchProcedure($procedure['id']);
  }
}

Find the complete integration in source file

Comments