-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturbosign-basic.php
More file actions
131 lines (118 loc) · 5.08 KB
/
Copy pathturbosign-basic.php
File metadata and controls
131 lines (118 loc) · 5.08 KB
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
124
125
126
127
128
129
130
131
<?php
/**
* Example 2: Review Link - Template Anchors
*
* This example creates a review link first, then sends manually.
* Uses template anchors like {signature1} and {date1} in your PDF.
*
* Use this when: You want to review the document before sending
*/
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use TurboDocx\TurboSign;
use TurboDocx\Config\HttpClientConfig;
use TurboDocx\Types\Recipient;
use TurboDocx\Types\Field;
use TurboDocx\Types\SignatureFieldType;
use TurboDocx\Types\TemplateConfig;
use TurboDocx\Types\FieldPlacement;
use TurboDocx\Types\Requests\CreateSignatureReviewLinkRequest;
function reviewLinkExample(): void
{
TurboSign::configure(new HttpClientConfig(
apiKey: getenv('TURBODOCX_API_KEY') ?: 'your-api-key-here',
orgId: getenv('TURBODOCX_ORG_ID') ?: 'your-org-id-here',
senderEmail: getenv('TURBODOCX_SENDER_EMAIL') ?: 'support@yourcompany.com',
senderName: getenv('TURBODOCX_SENDER_NAME') ?: 'Your Company Name'
));
try {
$pdfFile = file_get_contents(__DIR__ . '/../../ExampleAssets/sample-contract.pdf');
echo "Creating review link with template anchors...\n\n";
$result = TurboSign::createSignatureReviewLink(
new CreateSignatureReviewLinkRequest(
recipients: [
new Recipient('John Doe', 'john@example.com', 1),
new Recipient('Jane Smith', 'jane@example.com', 2),
],
fields: [
// First recipient - using template anchors
new Field(
type: SignatureFieldType::FULL_NAME,
recipientEmail: 'john@example.com',
template: new TemplateConfig(
anchor: '{name1}',
placement: FieldPlacement::REPLACE,
size: ['width' => 100, 'height' => 30]
)
),
new Field(
type: SignatureFieldType::SIGNATURE,
recipientEmail: 'john@example.com',
template: new TemplateConfig(
anchor: '{signature1}',
placement: FieldPlacement::REPLACE,
size: ['width' => 100, 'height' => 30]
)
),
new Field(
type: SignatureFieldType::DATE,
recipientEmail: 'john@example.com',
template: new TemplateConfig(
anchor: '{date1}',
placement: FieldPlacement::REPLACE,
size: ['width' => 75, 'height' => 30]
)
),
// Second recipient
new Field(
type: SignatureFieldType::FULL_NAME,
recipientEmail: 'jane@example.com',
template: new TemplateConfig(
anchor: '{name2}',
placement: FieldPlacement::REPLACE,
size: ['width' => 100, 'height' => 30]
)
),
new Field(
type: SignatureFieldType::SIGNATURE,
recipientEmail: 'jane@example.com',
template: new TemplateConfig(
anchor: '{signature2}',
placement: FieldPlacement::REPLACE,
size: ['width' => 100, 'height' => 30]
)
),
new Field(
type: SignatureFieldType::DATE,
recipientEmail: 'jane@example.com',
template: new TemplateConfig(
anchor: '{date2}',
placement: FieldPlacement::REPLACE,
size: ['width' => 75, 'height' => 30]
)
),
],
file: $pdfFile,
documentName: 'Contract Agreement',
documentDescription: 'This document requires electronic signatures from both parties.'
)
);
echo "✅ Review link created!\n";
echo "Document ID: {$result->documentId}\n";
echo "Status: {$result->status}\n";
echo "Preview URL: {$result->previewUrl}\n";
if ($result->recipients !== null) {
echo "\nRecipients:\n";
foreach ($result->recipients as $recipient) {
echo " {$recipient['name']} ({$recipient['email']}) - {$recipient['status']}\n";
}
}
echo "\nYou can now:\n";
echo "1. Review the document at the preview URL\n";
echo "2. Send to recipients using: TurboSign::send(documentId);\n";
} catch (Exception $error) {
echo "Error: {$error->getMessage()}\n";
}
}
// Run the example
reviewLinkExample();