Coder Social home page Coder Social logo

Comments (2)

iyyappanpwilco avatar iyyappanpwilco commented on June 14, 2024
args = $this->getTemplateArgs(); $this->clientService = new SignatureClientService($this->args); $this->routerService = new RouterService(); parent::controller($this->eg, $this->routerService, basename(__FILE__)); } /** * 1. Check the token * 2. Call the worker method * * @return void * @throws ApiException for API problems and perhaps file access \Exception, too */ public function createController(): void { $minimum_buffer_min = 3; if ($this->routerService->ds_token_ok($minimum_buffer_min)) { # 1. Call the worker method # More data validation would be a good idea here # Strip anything other than characters listed // $envelope_id = $this->worker($this->args); $results = $this->worker($this->args); if ($results) { $_SESSION['pause_envelope_id'] = false; # Redirect the user to the embedded signing # Don't use an iFrame! # State can be stored/recovered using the framework's session or a # query parameter on the returnUrl (see the make recipient_view_request method) header('Location: ' . $results["redirect_url"]); exit; } // if ($envelope_id) { // $_SESSION['pause_envelope_id'] = false; // $this->clientService->showDoneTemplate( // "Envelope unpaused", // "Envelope unpaused", // "The envelope workflow has been resumed and the envelope // has been sent to a second recipient!
// Envelope ID {$envelope_id}." // ); // } } else { $this->clientService->needToReAuth($this->eg); } } /** * Do the work of the example * 1. Create the envelope request object * 2. Send the envelope * * @param $args array * @return string * @throws ApiException for API problems and perhaps file access \Exception, too */ public function worker($args): array { // echo '
';
        
        # Step 3 Start
       

        # Update resend envelope parameter
        
       
        //return  $envelope_id;
        try {
            $env = new EnvelopeDefinition([
                'workflow' => new Workflow(['workflow_status' => 'in_progress']
            ),
            //'status' => "sent"
            ]);
            $envelope_api = $this->clientService->getEnvelopeApi();
            $envelope_option = new UpdateOptions();
            $envelope_option -> setAdvancedUpdate('true');
           // $envelope_option -> setResendEnvelope('true');
        # Step 3 End
        # Step 4 Start
        # Call Envelopes::update API method to unpause signature workflow
      //  $env->setStatus("sent");
        $signer1 = new Signer([ # The signer1
            'email' => 'xxxxx',
            'name' => 'xxx',
            'recipient_id' => "1",
            'routing_order' => "1",
            'role_name' => 'signer1',
            'client_user_id' => 'xxxxxx'
    ]);

    $signer2 = new Signer([ # The signer2
        'email' => 'xxx',
        'name' => 'xxx',
        'recipient_id' => "2",
        'routing_order' => "2",
        'role_name' => 'signer2',
        'client_user_id' => 'xxxxx'
    ]);
    
    $sign_here1 = new SignHere([
        'document_id' => "1",
        'page_number' => "1",
        'tab_label' => "Sign Here",
        'x_position' => "200",
        'y_position' => "200",
    ]);
   
    $sign_here2 = new SignHere([
        'document_id' => "1",
        'page_number' => "1",
        'tab_label' => "Sign Here",
        'x_position' => "300",
        'y_position' => "200",
    ]);
   
    # Add the tabs model (including the sign_here tabs) to the signer
    # The Tabs object takes arrays of the different field/tab types
    $signer1->setTabs(
        new Tabs([
            'sign_here_tabs' => [$sign_here1, ],
        ])
    );
   
    $signer2->setTabs(
        new Tabs([
            'sign_here_tabs' => [$sign_here2, ],
        ])
    );
   
        $recipients = new Recipients([
            'signers' => [$signer1, $signer2, ],
        ]) ;
        $env->setRecipients($recipients);
    
      // $env->setTemplateRoles([$signer1, $signer2]);
        $authentication_method = 'None';
        
        $recipient_view_request = $this->clientService->getRecipientViewRequest(
            $authentication_method,
            $args['receipent_arguments']);
         
            $envelope = $envelope_api->update(
                $args['account_id'],
                $args['pause_envelope_id'],
                $envelope=$env,
                $options=$envelope_option
            );
            
            $envelope_id = $envelope['envelope_id'];
             //  $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id,
             //  $recipient_view_request);
              //  return ['envelope_id' => $envelope_id,'ServiceStatus' =>'Success', 'redirect_url' => $results['url']];
          # 4. Obtain the recipient_view_url for the embedded signing
                # Exceptions will be caught by the calling function
              // $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id, $recipient_view_request);
                 $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id,
                 $recipient_view_request);
                return ['envelope_id' => $envelope_id, 'redirect_url' => $results['url']];
        } catch (ApiException $e) {
            $this->clientService->showErrorTemplate($e);
            exit;
        }
           // $results = $envelope_api->createRecipientView($args['account_id'], $envelope_id,
           // $recipient_view_request);
          //  return ['envelope_id' => $envelope_id,'ServiceStatus' =>'Success', 'redirect_url' => $results['url']];

 
    
            # 4. Obtain the recipient_view_url for the embedded signing
            # Exceptions will be caught by the calling function
           // $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id, $recipient_view_request);
    
    //         return ['envelope_id' => $envelope_id, 'redirect_url' => $results['url']];
    // } catch (ApiException $e) {
    //     $this->clientService->showErrorTemplate($e);
    //     exit;
    // }
    }

    /**
     * Get specific template arguments
     *
     * @return array
     */
    private function getTemplateArgs(): array
    {
        $signer2_name  = preg_replace('/([^\w \-\@\.\,])+/', '', $_SESSION['signer2_name']);
        $signer2_email = preg_replace('/([^\w \-\@\.\,])+/', '', $_SESSION['signer2_email']);
        $receipent_arguments =[
            'signer_email' => 'xxxxxx',
            'signer_name' => 'xxxx',
            'signer_client_id' =>'xxxxx',
            'ds_return_url' => $GLOBALS['app_url'] . 'index.php?page=ds_return',
            'recipient_id' => '2',
            'routing_order' => '2',
            'role_name' => 'signer2',
        ];
        $args = [      
            'account_id' => $_SESSION['ds_account_id'],
            'base_path' => $_SESSION['ds_base_path'],
            'ds_access_token' => $_SESSION['ds_access_token'],
            'pause_envelope_id' => 'xxxx',
            'receipent_arguments' => $receipent_arguments,
        ];
       return $args;
    }
}

from code-examples-php.

iyyappanpwilco avatar iyyappanpwilco commented on June 14, 2024

args = $this->getTemplateArgs(); $this->clientService = new SignatureClientService($this->args); $this->routerService = new RouterService(); parent::controller($this->eg, $this->routerService, basename(FILE)); } /** * 1. Check the token * 2. Call the worker method * * @return void * @throws ApiException for API problems and perhaps file access \Exception, too / public function createController(): void { $minimum_buffer_min = 3; if ($this->routerService->ds_token_ok($minimum_buffer_min)) { # 1. Call the worker method # More data validation would be a good idea here # Strip anything other than characters listed // $envelope_id = $this->worker($this->args); $results = $this->worker($this->args); if ($results) { $_SESSION['pause_envelope_id'] = false; # Redirect the user to the embedded signing # Don't use an iFrame! # State can be stored/recovered using the framework's session or a # query parameter on the returnUrl (see the make recipient_view_request method) header('Location: ' . $results["redirect_url"]); exit; } // if ($envelope_id) { // $_SESSION['pause_envelope_id'] = false; // $this->clientService->showDoneTemplate( // "Envelope unpaused", // "Envelope unpaused", // "The envelope workflow has been resumed and the envelope // has been sent to a second recipient!
// Envelope ID {$envelope_id}." // ); // } } else { $this->clientService->needToReAuth($this->eg); } } /
* * Do the work of the example * 1. Create the envelope request object * 2. Send the envelope * * @param $args array * @return string * @throws ApiException for API problems and perhaps file access \Exception, too */ public function worker($args): array { // echo '

';

    # Step 3 Start
   

    # Update resend envelope parameter
    
   
    //return  $envelope_id;
    try {
        $env = new EnvelopeDefinition([
            'workflow' => new Workflow(['workflow_status' => 'in_progress']
        ),
        //'status' => "sent"
        ]);
        $envelope_api = $this->clientService->getEnvelopeApi();
        $envelope_option = new UpdateOptions();
        $envelope_option -> setAdvancedUpdate('true');
       // $envelope_option -> setResendEnvelope('true');
    # Step 3 End
    # Step 4 Start
    # Call Envelopes::update API method to unpause signature workflow
  //  $env->setStatus("sent");
    $signer1 = new Signer([ # The signer1
        'email' => 'xxxxx',
        'name' => 'xxx',
        'recipient_id' => "1",
        'routing_order' => "1",
        'role_name' => 'signer1',
        'client_user_id' => 'xxxxxx'
]);

$signer2 = new Signer([ # The signer2
    'email' => 'xxx',
    'name' => 'xxx',
    'recipient_id' => "2",
    'routing_order' => "2",
    'role_name' => 'signer2',
    'client_user_id' => 'xxxxx'
]);

$sign_here1 = new SignHere([
    'document_id' => "1",
    'page_number' => "1",
    'tab_label' => "Sign Here",
    'x_position' => "200",
    'y_position' => "200",
]);

$sign_here2 = new SignHere([
    'document_id' => "1",
    'page_number' => "1",
    'tab_label' => "Sign Here",
    'x_position' => "300",
    'y_position' => "200",
]);

# Add the tabs model (including the sign_here tabs) to the signer
# The Tabs object takes arrays of the different field/tab types
$signer1->setTabs(
    new Tabs([
        'sign_here_tabs' => [$sign_here1, ],
    ])
);

$signer2->setTabs(
    new Tabs([
        'sign_here_tabs' => [$sign_here2, ],
    ])
);

    $recipients = new Recipients([
        'signers' => [$signer1, $signer2, ],
    ]) ;
    $env->setRecipients($recipients);

  // $env->setTemplateRoles([$signer1, $signer2]);
    $authentication_method = 'None';
    
    $recipient_view_request = $this->clientService->getRecipientViewRequest(
        $authentication_method,
        $args['receipent_arguments']);
     
        $envelope = $envelope_api->update(
            $args['account_id'],
            $args['pause_envelope_id'],
            $envelope=$env,
            $options=$envelope_option
        );
        
        $envelope_id = $envelope['envelope_id'];
         //  $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id,
         //  $recipient_view_request);
          //  return ['envelope_id' => $envelope_id,'ServiceStatus' =>'Success', 'redirect_url' => $results['url']];
      # 4. Obtain the recipient_view_url for the embedded signing
            # Exceptions will be caught by the calling function
          // $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id, $recipient_view_request);
             $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id,
             $recipient_view_request);
            return ['envelope_id' => $envelope_id, 'redirect_url' => $results['url']];
    } catch (ApiException $e) {
        $this->clientService->showErrorTemplate($e);
        exit;
    }
       // $results = $envelope_api->createRecipientView($args['account_id'], $envelope_id,
       // $recipient_view_request);
      //  return ['envelope_id' => $envelope_id,'ServiceStatus' =>'Success', 'redirect_url' => $results['url']];



        # 4. Obtain the recipient_view_url for the embedded signing
        # Exceptions will be caught by the calling function
       // $results = $this->clientService->getRecipientView($args['account_id'], $envelope_id, $recipient_view_request);

//         return ['envelope_id' => $envelope_id, 'redirect_url' => $results['url']];
// } catch (ApiException $e) {
//     $this->clientService->showErrorTemplate($e);
//     exit;
// }
}

/**
 * Get specific template arguments
 *
 * @return array
 */
private function getTemplateArgs(): array
{
    $signer2_name  = preg_replace('/([^\w \-\@\.\,])+/', '', $_SESSION['signer2_name']);
    $signer2_email = preg_replace('/([^\w \-\@\.\,])+/', '', $_SESSION['signer2_email']);
    $receipent_arguments =[
        'signer_email' => 'xxxxxx',
        'signer_name' => 'xxxx',
        'signer_client_id' =>'xxxxx',
        'ds_return_url' => $GLOBALS['app_url'] . 'index.php?page=ds_return',
        'recipient_id' => '2',
        'routing_order' => '2',
        'role_name' => 'signer2',
    ];
    $args = [      
        'account_id' => $_SESSION['ds_account_id'],
        'base_path' => $_SESSION['ds_base_path'],
        'ds_access_token' => $_SESSION['ds_access_token'],
        'pause_envelope_id' => 'xxxx',
        'receipent_arguments' => $receipent_arguments,
    ];
   return $args;
}

}

from code-examples-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.