/** * Creates an embedded signing experience. */ function createAndSend() { global $_oneSigner; $status = ""; // Construct basic envelope $env = new Envelope(); $env->Subject = "DocuSign API SDK Sample"; $env->EmailBlurb = "This envelope demonstrates embedded signing"; $env->AccountId = $_SESSION["AccountID"]; $env->Recipients = constructRecipients($_oneSigner); $doc = new Document(); $doc->PDFBytes = file_get_contents("resources/Docusign_Demo_11.pdf"); $doc->Name = "Demo Document"; $doc->ID = "1"; $doc->FileExtension = "pdf"; $env->Documents = array($doc); $env->Tabs = addTabs(count($env->Recipients)); $api = getAPI(); try { $csParams = new CreateAndSendEnvelope(); $csParams->Envelope = $env; $status = $api->CreateAndSendEnvelope($csParams)->CreateAndSendEnvelopeResult; addEnvelopeID($status->EnvelopeID); getToken($status, 1); } catch (SoapFault $e) { $_SESSION["errorMessage"] = $e; header("Location: error.php"); } }
function embedSending($envelope) { $api = getAPI(); $ceParams = new CreateEnvelope(); $ceParams->Envelope = $envelope; try { $status = $api->CreateEnvelope($ceParams)->CreateEnvelopeResult; if ($status->Status == EnvelopeStatusCode::Created) { $rstParam = new RequestSenderToken(); $rstParam->AccountID = $envelope->AccountId; $rstParam->EnvelopeID = $status->EnvelopeID; $rstParam->ReturnURL = getCallbackURL("getstatusanddocs.php"); addEnvelopeID($status->EnvelopeID); $_SESSION["embedToken"] = $api->RequestSenderToken($rstParam)->RequestSenderTokenResult; header("Location: embedsending.php?envelopid=" . $status->EnvelopeID . "&accountID=" . $envelope->AccountId . "&source=Document"); } } catch (SoapFault $e) { $_SESSION["errorMessage"] = $e; header("Location: error.php"); } }
function embedSending($templateReferences, $envelopeInfo, $recipients) { $api = getAPI(); $ceParams = new CreateEnvelopeFromTemplates(); $ceParams->EnvelopeInformation = $envelopeInfo; $ceParams->Recipients = $recipients; $ceParams->TemplateReferences = $templateReferences; $ceParams->ActivateEnvelope = false; try { $status = $api->CreateEnvelopeFromTemplates($ceParams)->CreateEnvelopeFromTemplatesResult; if ($status->Status == EnvelopeStatusCode::Created) { $rstParam = new RequestSenderToken(); $rstParam->AccountID = $envelopeInfo->AccountId; $rstParam->EnvelopeID = $status->EnvelopeID; $rstParam->ReturnURL = getCallbackURL("getstatusanddocs.php"); addEnvelopeID($status->EnvelopeID); $_SESSION["embedToken"] = $api->RequestSenderToken($rstParam)->RequestSenderTokenResult; header("Location: embedsending.php?envelopid=" . $status->EnvelopeID . "&accountID=" . $envelope->AccountId . "&source=Document"); } } catch (SoapFault $e) { $_SESSION["errorMessage"] = $e; header("Location: error.php"); } }