2017-10-11 96 views
0

我試圖讓2個用戶使用docusign嵌入式簽名簽名。我使用Docusign/github給出的示例代碼。我希望第二個用戶看到第一個用戶簽署了這個文檔,在此基礎上做一些解釋,當第一個簽名者簽署文檔時,我嘗試獲取信封ID,但是我得到一個錯誤。看起來第二個收件人有問題。有人會幫忙嗎?docusign嵌入式簽名中的多重簽名者問題

$username_docusign=$config['username_docusign']; 
$password_docusign=$config['password_docusign']; 
$integrator_key_docusign=$config['integrator_key_docusign']; 
$host_docusign=$config['host_docusign']; 
// create a new DocuSign configuration and assign host and header(s) 
$config = new DocuSign\eSign\Configuration(); 
$config->setSSLVerification(false); 
$config->setHost($host_docusign); 
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username_docusign . "\",\"Password\":\"" . $password_docusign . "\",\"IntegratorKey\":\"" . $integrator_key_docusign . "\"}"); 
///////////////////////////////////////////////////////////////////////// 
// STEP 1: Login() API 
///////////////////////////////////////////////////////////////////////// 
// instantiate a new docusign api client 
$apiClient = new DocuSign\eSign\ApiClient($config); 
// we will first make the Login() call which exists in the AuthenticationApi... 
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient); 
// optional login parameters 
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions(); 
// call the login() API 
$loginInformation = $authenticationApi->login($options); 
// parse the login results 
if(isset($loginInformation) && count($loginInformation) > 0) 
{ 
    // note: defaulting to first account found, user might be a 
    // member of multiple accounts 
    $loginAccount = $loginInformation->getLoginAccounts()[0]; 
    if(isset($loginInformation)) 
    { 
     $accountId = $loginAccount->getAccountId(); 
     if(!empty($accountId)) 
     { 
      echo "Account ID = $accountId\n"; 
     } 
    } 
} 
///////////////////////////////////////////////////////////////////////// 
// STEP 2: Create & Send Envelope with Embedded Recipient 
///////////////////////////////////////////////////////////////////////// 
// set recipient information 
$recipientName = "user1"; 
$recipientEmail = "email1"; 
// configure the document we want signed 



$recipientName2 = "user2"; 
$recipientEmail2 = "email2"; 

$documentFileName = "hhhh.pdf"; 
$documentName = "hhhh.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($document))); 
$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->setAnchorString("Sign here user1");//here my text in html 
$signHere->setAnchorXOffset("3"); 
$signHere->setAnchorYOffset("0"); 
$signHere->setAnchorUnits("inches"); 
$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('12345'); 

$signHere2 = new \DocuSign\eSign\Model\SignHere(); 

$signHere2->setAnchorString("Sign here user2");//here my text in html 
$signHere2->setAnchorXOffset("3"); 
$signHere2->setAnchorYOffset("0"); 
$signHere2->setAnchorUnits("inches"); 
$signHere2->setPageNumber("1"); 
$signHere2->setRecipientId("2"); 
// add the signature tab to the envelope's list of tabs 
$tabs2 = new DocuSign\eSign\Model\Tabs(); 
$tabs2->setSignHereTabs(array($signHere2)); 
// add a signer to the envelope 
$signer2 = new \DocuSign\eSign\Model\Signer(); 
$signer2->setEmail($recipientEmail2); 
$signer2->setName($recipientName2); 
$signer2->setRecipientId("2"); 
$signer2->setTabs($tabs2); 
$signer2->setClientUserId('123456'); 





// must set this to embed the recipient! 
// Add a recipient to sign the document 
$recipients = new DocuSign\eSign\Model\Recipients(); 
$recipients->setSigners(array($signer),array($signer2)); 
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition(); 
$envelop_definition->setEmailSubject("oggetto mail"); 
// 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); 

///////////////////////////////////////////////////////////////////////// 
// STEP 3: Request Recipient View (aka signing URL) 
///////////////////////////////////////////////////////////////////////// 
// instantiate a RecipientViewRequest object 
$recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest(); 
// set where the recipient is re-directed once they are done signing 
$recipient_view_request->setReturnUrl("http://www.elevationworld.com/adr/embedded.php?iddocumento_firmato=".$_GET['iddocumento']."&idutente_firmato=".$_SESSION['email']."&enevelope=".$envelop_summary->getEnvelopeId()); 
// configure the embedded signer 
if ($_GET['enevelope']=="") { 
$recipient_view_request->setUserName($recipientName); 
$recipient_view_request->setEmail($recipientEmail); 
// must reference the same clientUserId that was set for the recipient when they 
// were added to the envelope in step 2 
$recipient_view_request->setClientUserId('12345'); 
// used to indicate on the certificate of completion how the user authenticated 
$recipient_view_request->setAuthenticationMethod("email"); 
// generate the recipient view! (aka embedded signing URL) 
$signingView = $envelopeApi->createRecipientView($accountId, $envelop_summary->getEnvelopeId(), $recipient_view_request); 
$signurl= $signingView->getUrl(); 
    } else { 
    $recipient_view_request->setUserName($recipientName2); 
$recipient_view_request->setEmail($recipientEmail2); 
// must reference the same clientUserId that was set for the recipient when they 
// were added to the envelope in step 2 
$recipient_view_request->setClientUserId('12345'); 
// used to indicate on the certificate of completion how the user authenticated 
$recipient_view_request->setAuthenticationMethod("email"); 
// generate the recipient view! (aka embedded signing URL) 
$signingView = $envelopeApi->createRecipientView($accountId, $_GET['enevelope'], $recipient_view_request); 
$signurl= $signingView->getUrl(); 

    } 
header('Location: '.$signurl); 

回答

1

您是否在獲取簽名者2的recipientURL時出錯?我可以看到你已經創建signer2與clientuserId在STEP2 123456,但在STEP3,你試圖用12345

獲得URL與clientUserId在步驟2,你有

$signer2->setClientUserId('123456'); 

在STEP3,你逝去的

//添加到信封在步驟2

$recipient_view_request->setClientUserId('12345'); 

如果設置signer2正確clientUserId那麼我想問題會爲您解決。