-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsignatureRequestFormFields.php
More file actions
95 lines (87 loc) · 4.15 KB
/
signatureRequestFormFields.php
File metadata and controls
95 lines (87 loc) · 4.15 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form Fields Signature Request</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="//s3.amazonaws.com/cdn.hellosign.com/public/js/hellosign-embedded.LATEST.min.js"></script>
<link rel="stylesheet" type="text/css" href="newcss.css" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" href="/favicon-32x32.png"/>
<link rel="icon" type="image/png" href="/favicon-16x16.png"/>
<link rel="manifest" href="/manifest.json" />
<link rel="mask-icon" href="/safari-pinned-tab.svg"/>
</head>
<body>
<?php
require_once 'vendor/autoload.php';
$api_key = getenv('HS_APIKEY_PROD') ? getenv('HS_APIKEY_PROD') : '';
$client_id = getenv('HS_CLIENT_ID_PROD') ? getenv('HS_CLIENT_ID_PROD') : '';
// Instance of a client for you to use for calls
$client = new HelloSign\Client($api_key);
// Example call with logging for embedded requests
$request = new HelloSign\SignatureRequest;
$request->enableTestMode();
$request->setTitle("Testing Form Fields Per Document - Prod");
$request->setSubject('Embedded Signature Request with Form Fields');
$request->setMessage('Awesome, right?');
$request->addSigner('testing@testing.com', 'Signer Person, IV');
$request->setFormFieldsPerDocument(
array( //everything
array( //document 1
array( //component 1
"api_id" => "things_1",
"name" => "Name Here",
"type" => "text",
"x" => 220,
"y" => 85,
"width" => 253,
"height" => 16,
"required" => true,
"signer" => 0
),
array( //component 2
"api_id" => "things_2",
"name" => "Address Here",
"type" => "text",
"x" => 530,
"y" => 85,
"width" => 152,
"height" => 16,
"required" => true,
"signer" => 0
),
array( //component 3
"api_id" => "lotsof_2",
"name" => "",
"type" => "signature",
"x" => 90,
"y" => 315,
"width" => 223,
"height" => 30,
"required" => true,
"signer" => 0,
"page" => 2,
),
),
)
);
$request->addFileUrl("http://www.startupprofessionals.com/linked/non-disclosure-agreement-mutual-generic-blank.pdf");
// Turn it into an embedded request
$embedded_request = new HelloSign\EmbeddedSignatureRequest($request, $client_id);
// Send it to HelloSign
$response = $client->createEmbeddedSignatureRequest($embedded_request);
// wait for callback with signature_request_sent
//
// Grab the signature ID for the signature page that will be embedded in the page
$signatures = $response->getSignatures();
$signature_id = $signatures[0]->getId();
// Retrieve the URL to sign the document
$embedded_response = $client->getEmbeddedSignUrl($signature_id);
// Store it to use with the embedded.js HelloSign.open() call
$sign_url = $embedded_response->getSignUrl();
// call the html page with the embedded.js lib and HelloSign.open()
include('signerpage.php');
?>
</body>
</html>