-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembeddedSigRequest.php
More file actions
79 lines (76 loc) · 3.79 KB
/
embeddedSigRequest.php
File metadata and controls
79 lines (76 loc) · 3.79 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
<?php
require_once ('vendor/autoload.php'); //if you're using Composer, or
//require_once ('./vendor/hellosign/hellosign-php-sdk/HelloSign.php'); //if not using Composer and assuming the SDK is installed in the 'vendor' folder
include("auth.php"); // where $api_key and $client_id are set
$client = new HelloSign\Client($api_key);
$request = new HelloSign\SignatureRequest;
$request->enableTestMode();
$request->setSubject('My First embedded signature request with a template');
$request->setMessage('Awesome, right?');
$request->addSigner('jack@example.com', 'Jack');
$request->addSigner('jill@example.com', 'Jill');
$request->addFile("./nda.pdf"); //assuming there's a simple test file in the root of the application
// $client_id = 'YOUR_CLIENT_ID';
$embedded_request = new HelloSign\EmbeddedSignatureRequest($request, $client_id);
$response = $client->createEmbeddedSignatureRequest($embedded_request);
$signatures = $response->getSignatures(); //this method gets the signatures object in the response
$signature_id = $signatures[0]->getId(); //this method get the signature_id of the first signer in the signatures object
// Retrieve the URL to sign the document
$response = $client->getEmbeddedSignUrl($signature_id);
// Store it to use with the embedded.js HelloSign.open() call
$sign_url = $response->getSignUrl();
?>
<!DOCTYPE html>
<html>
<head>
<title>Embedded Signing Hardcoded</title>
<script type="text/javascript" src="//s3.amazonaws.com/cdn.hellosign.com/public/js/hellosign-embedded.LATEST.min.js"></script>
</head>
<body>
<script>
HelloSign.init("<?php echo $client_id ?>");
HelloSign.open({
url: "<?php echo $sign_url ?>",
allowCancel: true,
skipDomainVerification: true,
uxVersion: 2,
whiteLabelingOptions: {
"header_background_color": "#00adbb",
"primary_button_color": "#43454d",
"primary_button_text_color": "#ffffff",
"primary_button_color_hover": "#43454d",
"primary_button_text_color_hover": "#ffffff",
"link_color": "#00adbb",
"page_background_color": "#f4f7f9",
"secondary_button_color": "#43454d",
"secondary_button_text_color": "#ffffff",
"legal_version": "terms2"
},
messageListener: function (eventData) {
(console.log(">-*>-*>-*> Got message data: " + JSON.stringify(eventData)));
if (eventData.event == HelloSign.EVENT_SIGNED) {
HelloSign.close();
console.log(eventData.signature_id) + "this is the signature_id";
} else if (eventData.event == HelloSign.EVENT_CANCELED) {
HelloSign.close();
console.log(eventData);
} else if (eventData.event == HelloSign.EVENT_ERROR) {
HelloSign.close();
alert("There Was An Error And Stuff!");
console.log(eventData);
} else if (eventData.event == HelloSign.EVENT_SENT) {
HelloSign.close();
console.log(eventData);
console.log(eventData.signature_request_id);
} else if (eventData.event == HelloSign.EVENT_TEMPLATE_CREATED) {
HelloSign.close();
console.log(eventData);
} else if (eventData.event == HelloSign.EVENT_DECLINED) {
HelloSign.close();
console.log(eventData);
}
}
});
</script>
</body>
</html>