PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 1, 2022

[FIXED] How to setup a DocuSign handler on Symfony?

 February 01, 2022     docusignapi, php, symfony     No comments   

Issue

I actually use YouSign to sign registration PDFs when a user creates an account on the website of the company I work for.

We have loads of document to sign, multiple times, and want to switch to DocuSign because it allows more documents in each API calls.

I'm on Symfony 2.8 (Going for Symfony 3 soon), and I want to setup DocuSign before migrating.

Let's say I already have all the fields value variables assigned ($name, $wage, lastName...), and a PDF document created with all these values. I want to sign this document with DocuSign, how can I do ? I requested the DocuSign/eSign package but have no idea of how to use it.

I already checked all the example codes on GitHub and did not find any using a Symfony template.

Do you know how to integrate the classes and methods needed to send a PDF to DocuSign, sign it, and then get it back using the PHP wrapper in Symfony ?


Solution

Here is some PHP code you can use as a starting point. https://github.com/docusign/eg-03-php-auth-code-grant/blob/master/src/EG001EmbeddedSigning.php

Here is the code:

# 1. Create the envelope request object
        $envelope_definition = $this->make_envelope($envelope_args);
        # 2. call Envelopes::create API method
        # Exceptions will be caught by the calling function
        $config = new \DocuSign\eSign\Configuration();
        $config->setHost($args['base_path']);
        $config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
        $api_client = new \DocuSign\eSign\ApiClient($config);
        $envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
        $results = $envelope_api->createEnvelope($args['account_id'], $envelope_definition);
        $envelope_id = $results->getEnvelopeId();
        # 3. Create the Recipient View request object
        $authentication_method = 'None'; # How is this application authenticating
        # the signer? See the `authenticationMethod' definition
        # https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient
        $recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest([
            'authentication_method' => $authentication_method,
            'client_user_id' => $envelope_args['signer_client_id'],
            'recipient_id' => '1',
            'return_url' => $envelope_args['ds_return_url'],
            'user_name' => $envelope_args['signer_name'], 'email' => $envelope_args['signer_email']
        ]);
        # 4. Obtain the recipient_view_url for the signing ceremony
        # Exceptions will be caught by the calling function
        $results = $envelope_api->createRecipientView($args['account_id'], $envelope_id,
            $recipient_view_request);

we have a PHP library that would assist you here - https://github.com/docusign/docusign-php-client



Answered By - Inbar Gazit
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing