Last active
July 11, 2018 13:29
-
-
Save Ergin008/d61fe71fe6305d5b6d8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set recipient information | |
$recipientName = "[RECIPIENT_NAME]"; | |
$recipientEmail = "[RECIPIENT_EMAIL]"; | |
// configure the document we want signed | |
$documentFileName = "[PATH/TO/DOCUMENT.PDF]"; | |
$documentName = "TestFile.pdf"; | |
// instantiate a new envelopeApi object | |
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient); | |
// Add a document to the envelope | |
$document = new DocuSign\eSign\Model\Document(); | |
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName))); | |
$document->setName($documentName); | |
$document->setDocumentId("1"); | |
// Create a |SignHere| tab somewhere on the document for the recipient to sign | |
$signHere = new \DocuSign\eSign\Model\SignHere(); | |
$signHere->setXPosition("100"); | |
$signHere->setYPosition("100"); | |
$signHere->setDocumentId("1"); | |
$signHere->setPageNumber("1"); | |
$signHere->setRecipientId("1"); | |
// add the signature tab to the envelope's list of tabs | |
$tabs = new DocuSign\eSign\Model\Tabs(); | |
$tabs->setSignHereTabs(array($signHere)); | |
// add a signer to the envelope | |
$signer = new \DocuSign\eSign\Model\Signer(); | |
$signer->setEmail($recipientEmail); | |
$signer->setName($recipientName); | |
$signer->setRecipientId("1"); | |
$signer->setTabs($tabs); | |
$signer->setClientUserId("1234"); // must set this to embed the recipient! | |
// Add a recipient to sign the document | |
$recipients = new DocuSign\eSign\Model\Recipients(); | |
$recipients->setSigners(array($signer)); | |
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition(); | |
$envelop_definition->setEmailSubject("[DocuSign PHP SDK] - Please sign this doc"); | |
// set envelope status to "sent" to immediately send the signature request | |
$envelop_definition->setStatus("sent"); | |
$envelop_definition->setRecipients($recipients); | |
$envelop_definition->setDocuments(array($document)); | |
// create and send the envelope! (aka signature request) | |
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null); | |
echo "$envelop_summary\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment