-
Notifications
You must be signed in to change notification settings - Fork 41
/
EG002SigningViaEmail.php
99 lines (87 loc) · 2.84 KB
/
EG002SigningViaEmail.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Example 002: Remote signer, cc, envelope has three documents
*/
namespace DocuSign\Controllers\Examples\eSignature;
use DocuSign\Controllers\eSignBaseController;
use DocuSign\Services\Examples\eSignature\SigningViaEmailService;
use DocuSign\Services\ManifestService;
class EG002SigningViaEmail extends eSignBaseController
{
const EG = 'eg002'; # reference (and URL) for this example
const FILE = __FILE__;
/**
* Create a new controller instance.
* @return void
*/
public function __construct()
{
parent::__construct();
if (!$_SESSION["createDraft"]) {
parent::controller();
} else {
unset($_SESSION["createDraft"]);
}
}
/**
* 1. Check the token
* 2. Call the worker method
* 3. Redirect the user to the signing
*
* @return void
*/
public function createController(): void
{
$this->checkDsToken();
# 2. 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'];
$docxDoc = $GLOBALS['DS_CONFIG']['doc_docx'];
$envelopeResponse = SigningViaEmailService::signingViaEmail(
$this->args,
$this->clientService,
$this::DEMO_DOCS_PATH,
$docxDoc,
$pdfDoc
);
if ($envelopeResponse) {
$_SESSION["envelope_id"] = $envelopeResponse["envelope_id"]; # Save for use by other examples
# which need an envelope_id
$this->clientService->showDoneTemplateFromManifest(
$this->codeExampleText,
null,
ManifestService::replacePlaceholders(
"{0}",
$envelopeResponse["envelope_id"],
$this->codeExampleText["ResultsPageText"]
)
);
}
}
/**
* Get specific template arguments
*
* @return array
*/
public function getTemplateArgs(): array
{
$status = "sent";
if ($_SESSION["createDraft"]) {
$status = "created";
}
$envelope_args = [
'signer_email' => $this->checkEmailInputValue($_POST['signer_email']),
'signer_name' => $this->checkInputValues($_POST['signer_name']),
'cc_email' => $this->checkEmailInputValue($_POST['cc_email']),
'cc_name' => $this->checkInputValues($_POST['cc_name']),
'status' => $status
];
return [
'account_id' => $_SESSION['ds_account_id'],
'base_path' => $_SESSION['ds_base_path'],
'ds_access_token' => $_SESSION['ds_access_token'],
'envelope_args' => $envelope_args
];
}
}