Skip to content

Latest commit

 

History

76 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocuSign for Laravel 8, 9, 10, and 11

This package was developed to utilize e-contract/signatures directly within a Laravel based CRM.

Maintenance notice: This is a maintained fork of tjphippen/docusign, which is no longer maintained.

Latest Stable Version Total Downloads

For current endpoint documentation, see the DocuSign eSignature REST API reference.


Installation

Using Composer

Add the package to your project:

composer require dalmarcolucas/docusign

Or add the following to your composer.json file:

"dalmarcolucas/docusign": "^0.4"

Then run composer install or composer update to download and install.

Namespace compatibility: This package is maintained as dalmarcolucas/docusign, but retains the original Tjphippen\Docusign PHP namespace. The namespace is therefore correct in the manual registration examples below.

Service Provider Registration

The package supports Laravel 8 through 11 and uses auto-discovery, so the service provider and facade are registered automatically.

If auto-discovery is disabled, add the service provider to your config/app.php file within the providers array:

'providers' => [
    Tjphippen\Docusign\DocusignServiceProvider::class,
]

Facade Registration

The package includes an auto-registered facade which provides the static syntax for managing envelopes, recipients, etc. If you have issues or need to register it manually, add it to your aliases array in config/app.php:

'aliases' => [
    'Docusign' => Tjphippen\Docusign\Facades\Docusign::class,
]

Create configuration file using artisan

$ php artisan vendor:publish

The configuration file will be published to config/docusign.php which must be completed to make connections to the API.

JWT Authentication (Recommended)

DocuSign is phasing out legacy authentication (username/password). The recommended approach is OAuth 2.0 JWT Grant flow.

  1. Create an integration (app) in the DocuSign Admin Console
  2. Generate an RSA key pair and note your Integration Key (Client ID)
  3. Grant consent by visiting the consent URL (one-time step per user)
  4. Configure your config/docusign.php:
'auth_type' => 'jwt',
'client_id' => env('DOCUSIGN_CLIENT_ID'),        // Integration Key
'user_id' => env('DOCUSIGN_USER_ID'),             // User ID (GUID) to impersonate
'private_key' => env('DOCUSIGN_PRIVATE_KEY'),     // RSA private key (PEM string)
'auth_server' => 'account-d.docusign.com',        // Use 'account.docusign.com' for production
'account_id' => env('DOCUSIGN_ACCOUNT_ID'),
'environment' => 'demo',                          // Use 'na1', 'na2', etc. for production
'version' => 'v2.1',

See DocuSign JWT Grant Documentation for details.

Legacy Authentication (Deprecated)

'auth_type' => 'legacy',
'integrator_key' => '',
'email' => '',
'password' => '',

Examples

Get List of Users

Docusign::getUsers();

Get Individual User

Docusign::getUser($userId); 
Docusign::getUser($userId, true);  // When true, the full list of user information is returned for the user. 

Get Folders

Docusign::getFolders(); // By default only the list of template folders are returned
Docusign::getFolders(true);  // Will return normal folders plus template folders

Get Folder Envelope List

Docusign::getFolderEnvelopes($folderId);

See: All Parameters for this method.

Docusign::getFolderEnvelopes($folderId, array(
   'start_position' => 1, // Integer
   'from_date' => '', // date/Time
   'to_date' => '', // date/Time
   'search_text' => '', // String
   'status' => 'created', // Status
   'owner_name' => '', // username
   'owner_email' => '', // email
   );

Get List of Templates

Docusign::getTemplates();

Or with Additional Parameters.

Docusign::getTemplates(array(
   'folder' => 1, // String (folder name or folder ID)
   'folder_ids' => '', // Comma separated list of folder ID GUIDs.
   'include' => '', // Comma separated list of additional template attributes
    ...
   );

Get Template

Docusign::getTemplate($templateId);

Get Multiple Envelopes

$envelopes = array('49d91fa5-1259-443f-85fc-708379fd7bbe', '8b2d44a-41dc-4698-9233-4be0678c345c');
Docusign::getEnvelopes($envelopes);

Get Individual Envelope

Docusign::getEnvelope($envelopeId);

Get Envelope Recipient

Docusign::getEnvelopeRecipients($envelopeId);

To include tabs simply set the second parameter to true:

Docusign::getEnvelopeRecipients($envelopeId, true);

Get Envelope Custom Fields

Docusign::getEnvelopeCustomFields($envelopeId);

Get Tab Information for a Recipient

See: Tab Parameters

Docusign::getEnvelopeTabs($envelopeId, $recipientId);

Modify Tabs for a Recipient

This one is a bit tricky. The tabId is required and must be within set of arrays. See: [Tab Types and Parameters] (https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Tab%20Parameters.htm)

$tabs = ['textTabs' => [['tabId' => '270269f6-4a84-4ff9-86db-2a572eb73d99', 'value' => '123 Fake Street']]];
Docusign::updateRecipientTabs($envelopeId, $recipientId, $tabs);

Create/Send an Envelope from a Template

See: Send an Envelope or Create a Draft Envelope for full list of parameters/options.

Docusign::createEnvelope(array(
   'templateId'     => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', // Template ID
   'emailSubject'   => 'Demo Envelope Subject', // Subject of email sent to all recipients
   'status'         => 'created', // created = draft ('sent' will send the envelope!)
   'templateRoles'  => array(
        ['name'     => 'Contractor Name',
         'email'    => 'contractor@example.com',
         'roleName' => 'Contractor',
         'clientUserId'  => 1],
        ['name'     => 'Jane Someone',
         'email'    => 'demo@demo.com',
         'roleName' => 'Customer']),
    ));

Modify Draft Envelope Email Subject and Message

The updateEnvelope method can be used in a variety of ways..

Docusign::updateEnvelope($envelopeId, array(
    'emailSubject' => 'New Email Subject', // Required
    'emailBlurb' => 'Email message body text'
));

Post Recipient View

Returns embeded signing URL. [Reference] (https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Post%20Recipient%20View.htm)

Docusign::createRecipientView($envelopeId, array(
    'userName' => 'Signer Name',
    'email' => 'signer@example.com',
    'AuthenticationMethod' => 'email',
    'clientUserId' => 1, // Must create envelope with this ID
    'returnUrl' => 'http://your-site.tdl/returningUrl'
));

Send Draft Envelope

Docusign::updateEnvelope($envelopeId, ['status' => 'sent']);

Void Envelope

Docusign::updateEnvelope($envelopeId, array(
    'status' => 'voided',
    'voidedReason' => 'Just Testing'
));

Delete Envelope

Docusign::deleteEnvelope($envelopeId);

Change Log

v0.2.0

  • Updated Guzzle dependancy & namespace

v0.2.0

  • Added trait

v0.1.0

  • Released

About

DocuSign Rest API Wrapper for Laravel 5

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages