/
create-batch-signing.php
124 lines (97 loc) · 2.6 KB
/
create-batch-signing.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/lib.php';
/**
*
* PARAMETERS
*
*/
$signers = [];
$files = [];
/**
*
* CHANGE THIS
*
* File token provided by file upload response.
*/
$file['token'] = '45f943fcc30399e2ec4ea7d3473c5c52105ea3e2';
array_push($files, $file); // For 'pdf' type only one file is supported.
/**
* Signed document format. Check documentation for all available options.
*/
$type = 'pdf';
/**
* Signing name. Will be displayed as the main title.
*/
$signingName = 'Agreement';
/**
* Unique user identifier from your system.
*/
$signerUID = 'o880jxigih';
$signer['id'] = $signerUID;
/**
* Name
*/
$signer['name'] = 'Tester';
/**
* Surname
*/
$signer['surname'] = 'Surname';
/**
* Phone number. Optional.
*/
$signer['phone'] = '+37060000666';
/**
* Personal code. Optional.
*/
$signer['code'] = '50001018865';
/**
* Signing purpose. Availabe options listed in documentation.
*/
$signer['signing_purpose'] = 'signature';
array_push($signers, $signer); // Add as many signers as you need.
/**
*
* MAKING API REQUESTS
*
*/
/**
* Create multiple signings
*/
$action = 'signing/create';
$signings = [];
for ($i = 1 ; $i <= 2; $i++) {
$createResponse = request(getApiUrlByAction($action), [
'type' => $type,
'name' => $signingName,
'signers' => $signers,
'files' => $files,
'postback_url' => $postbackUrl,
], REQUEST_POST);
if ($createResponse['status'] != 'ok') {
echo "Signing could not be created." . PHP_EOL;
exit;
}
$signings[] = [
'token' => $createResponse['token'],
'signer_token' => $createResponse['signers']['o880jxigih'],
];
}
$action = 'signing/createbatch';
$batchSigningCreateResponse = request(getApiUrlByAction($action), [
'signings' => $signings
]);
/**
* Important!
* Signing URL formation.
*/
$batchSigningUrl = trim($apiUrl, '/') . "/signing/batch/" . $batchSigningCreateResponse['token'];
$sequentialSigningUrl = trim($apiUrl, '/') . "/signing/sequence/" . $batchSigningCreateResponse['token'];
echo "Batch signing successfully created." . PHP_EOL;
echo "View and sign it here: " . PHP_EOL . PHP_EOL;
echo $batchSigningUrl . PHP_EOL . PHP_EOL . PHP_EOL;
echo "Sequential signing successfully created as well." . PHP_EOL;
echo "View and sign it here: " . PHP_EOL . PHP_EOL;
echo $sequentialSigningUrl . PHP_EOL . PHP_EOL;
echo "Signing url formation: " . trim($apiUrl, '/') . "/signing/batch/<BATCH_SIGNING_TOKEN> or " . trim($apiUrl, '/') . "/signing/sequence/<BATCH_SIGNING_TOKEN>" . PHP_EOL;
echo "SIGNING_TOKEN: token received with 'signing/createbatch' API call response." . PHP_EOL;