Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Docusign Bundle Laravel Package

cyllene-web/docusign-bundle

View on GitHub
Deep Wiki
Context7

Events

Sign events

When signing a document, DocuSign sends the user back to your application to the callback route. But usually you need to send custom data to that route. To do that you can subscribe to the PreSignEvent.

Even more useful, when DocuSign redirect the user to the callback route, you might need to grab some data from the Request and modify the Response sent. You could even replace the Response object. To do that you can subscribe to the DocumentSignatureCompletedEvent.

// src/EventSubscriber/PreSignSubscriber.php
namespace App\EventSubscriber;

use DocusignBundle\EnvelopeBuilder;
use DocusignBundle\Events\PreSignEvent;
use DocusignBundle\Events\PreSendEnvelopeEvent;
use DocusignBundle\Events\DocumentSignatureCompletedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class PreSignSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        // return the subscribed events, their methods and priorities
        return [
            PreSignEvent::class => 'preSign',
            PreSendEnvelopeEvent::class => 'preSendEnvelope',
            DocumentSignatureCompletedEvent::class => 'onDocumentSignatureCompleted'
        ];
    }

    public function preSign(PreSignEvent $preSign)
    {
        // Here you can add the parameters you want to be sent back to you by DocuSign in the callback.
        $envelopeBuilder = $preSign->getEnvelopeBuilder();
        $request = $preSign->getRequest();

        // $envelopeBuilder->addCallbackParameter([]);
        // $envelopeBuilder->setCallbackParameters();
        // ...
    }
    
    public function preSendEnvelope(PreSendEnvelopeEvent $preSendEnvelope)
    {
        // Here you can manipulate the EnvelopeBuilder and do some adjustment to the envelope before being sent to DocuSign.
        $envelopeBuilder = $preSendEnvelope->getEnvelopeBuilder();

        // $envelopeDefinition = $envelopeBuilder->getEnvelopeDefinition([]);
        // ...
        // $envelopeBuilder->setEnvelopeDefinition($envelopeDefinition);
    }

    public function onDocumentSignatureCompleted(DocumentSignatureCompletedEvent $documentSignatureCompleted)
    {
        $request = $documentSignatureCompleted->getRequest();
        $response = $documentSignatureCompleted->getResponse();

        // ... do whatever you want with the response.
    }
}

The PreSignEvent also lets you configure the EnvelopeBuilder to your needs:

public function preSign(PreSignEvent $preSign)
{
    $envelopeBuilder = $preSign->getEnvelopeBuilder();

    // Change the default signer name
    $envelopeBuilder->setDefaultSignerName('John DOE');
    // Change the default signer email
    $envelopeBuilder->setDefaultSignerEmail('john.doe@example.com');
    // Add a signer
    $envelopeBuilder->addSigner('Chuck Norris', 'chuck.norris@example.com');
    // Add a carbon copy
    $envelopeBuilder->addCarbonCopy('Jane Doe', 'jane.doe@example.com');
    // ... configure the EnvelopeBuilder to your needs
}

Webhook events

DocuSign calls a Webhook on your project, allowing you to handle the signed document, its status, etc.

Your Webhook url MUST BE in HTTPS.

Depending on the document status, several events are available, giving you access to the DocuSign request (as a \SimpleXMLElement) and the request.

// src/EventSubscriber/WebhookSubscriber.php
namespace App\EventSubscriber;

use DocusignBundle\Events\AuthenticationFailedEvent;
use DocusignBundle\Events\AutoRespondedEvent;
use DocusignBundle\Events\CompletedEvent;
use DocusignBundle\Events\DeclinedEvent;
use DocusignBundle\Events\DeliveredEvent;
use DocusignBundle\Events\SentEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class WebhookSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        // return the subscribed events, their methods and priorities
        return [
            AuthenticationFailedEvent::class => 'onAuthenticationFailed',
            AutoRespondedEvent::class => 'onAutoResponded',
            CompletedEvent::class => 'onCompleted',
            DeclinedEvent::class => 'onDeclined',
            DeliveredEvent::class => 'onDelivered',
            SentEvent::class => 'onSent',
        ];
    }

    // ...
}

Next: Customize the bundle

Go back

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/php-sdk
littlerocket/job-queue-bundle
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/opensearch-client
directorytree/opensearch-adapter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php