samurayjedi/laravel-docusign

Docusign laravel integration as middleware.

v1.0 2024-10-06 23:21 UTC

This package is not auto-updated.

Last update: 2025-03-24 23:59:06 UTC


README

Its a package that i have create to make me easier integrate docusign through my projects.

How to install

simple as run:

composer require samurayjedi/laravel-docusign

Configure

First ensure the .env file exits in your project, then run:

php artisan docusign:setup

This create the middleware '~/app/Http/Middleware/IsAllowedByDocuSign.php', it redirect to docusign passing as parameter our app integration data and as return url the actual/requested route, if docusing 'consent', redirect to the return url, if is the first time running the app, docusign ask you if you want grant permissions to the 'x' app works with you account, once its done, the future request will be transparent.

In addition, the command add to your '~/bootstrap/app.php' the following lines for register the previous middleware:

// ...
->withMiddleware(function (Middleware $middleware) {
    $middleware->appendToGroup('auth.docusign', [
        \App\Http\Middleware\IsAllowedByDocusign::class,
    ]);

    //
})
// ...

Important note: the command finds '->withMiddleware(function (Middleware $middleware) {' coincidence into the file and append, into the brackets, the middleware, in my uses, it works fine every time, but i recommend you backup your '~/bootstrap/app.php' before running the command, if you have made changes to the file.

Futhermore, the artisan command create '~/routes/docusign.php', it contains:

Route::middleware(['web', 'auth', 'auth.docusign'])->group(function () {
    
});

Inside i put my routes that need docusign consent (both GET and POST).

Finally and the most important (and boresome) part, the command too puth into your .env file the following lines:

DS_CLIENT_ID=Your_integration_key
DS_CLIENT_SECRET=Your_secret_key
DS_AUTHORIZATION_SERVER=account-d.docusign.com
DS_IMPERSONATED_USER_ID=Your_user_ID
DS_PRIVATE_KEY_FILE=private_dev.key
ALLOW_SILENT_AUTHENTICATION=true
DS_BRAND_ID=Your_brand_id
ADMIN_NAMES=samurayjedi,kroqgar
ADMIN_EMAILS=samurayjedi_example@gmail.com,kroqgar_example@gmail.com

to get each one, login to you docusign developer account and enter in 'App & Keys':

App & Keys

create a app:

App & Keys

DS_CLIENT_SECRET is found:

App & Keys

Create RSA keys pair:

App & Keys

And copy public and private key and put it into a file, put the private key file into '~/storage/docusign/', and change this line with the name of your file:

// ...
DS_PRIVATE_KEY_FILE=private_dev.key
// ...

For my app to work in local, I had to put all this uris, i don't remember well, but in production i believe i had to change 'localhost' with the domain:

App & Keys

Finally, save the changes.

Still missing the DS_CLIENT_ID, it is found:

App & Keys

DS_IMPERSONATED_USER_ID is found:

App & Keys

DS_BRAND_ID, is required create a brand, got to Brands -> Add Brand and fill the form:

App & Keys

when all its done, copy the brand id:

App & Keys

Its done, docusign its integrated to your app finally!!! (in theory :p)