-
Notifications
You must be signed in to change notification settings - Fork 42
/
EG001EmbeddedSigning.php
81 lines (73 loc) · 2.39 KB
/
EG001EmbeddedSigning.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* Example 001: Use embedded signing
*/
namespace DocuSign;
use DocuSign\Controllers\eSignBaseController;
use DocuSign\Services\Examples\eSignature\EmbeddedSigningService;
class EG001EmbeddedSigning extends eSignBaseController
{
const EG = "eg001"; # reference (and url) for this example
const FILE = __FILE__;
private int $signer_client_id = 1000; # Used to indicate that the signer will use embedded
# Signing. Represents the signer's userId within your application.
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
parent::controller();
}
/**
* Check the token
* Call the worker method
* Redirect the user to the signing
*
* @return void
*/
public function createController(): void
{
$this->checkDsToken();
# Call the worker method
# More data validation would be a good idea here
# Strip anything other than characters listed
$pdfDoc = $GLOBALS['DS_CONFIG']['doc_pdf'];
$envelopeIdAndReturnUrl = EmbeddedSigningService::worker(
$this->args,
$this->clientService,
self::DEMO_DOCS_PATH,
$pdfDoc
);
if ($envelopeIdAndReturnUrl) {
# 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: ' . $envelopeIdAndReturnUrl["redirect_url"]);
exit;
}
}
/**
* Get specific template arguments
*
* @return array
*/
public function getTemplateArgs(): array
{
$envelope_args = [
'signer_email' => $this->checkInputValues($_POST['signer_email']),
'signer_name' => $this->checkInputValues($_POST['signer_name']),
'signer_client_id' => $this->signer_client_id,
'ds_return_url' => $GLOBALS['app_url'] . 'index.php?page=ds_return'
];
return [
'account_id' => $_SESSION['ds_account_id'],
'base_path' => $_SESSION['ds_base_path'],
'ds_access_token' => $_SESSION['ds_access_token'],
'envelope_args' => $envelope_args
];
}
}