2017-10-11 318 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那么我想问题会为您解决。