我正在尝试在 DocuSign 中添加补充/支持文档,每当我要签署文档时,这些文档应该出现在收件人查看请求(嵌入签名)中。我不明白为什么文档没有显示在那里。
我没有收到任何错误或任何此类错误。该过程工作正常,因为它创建了信封,并且用户能够请求收件人视图。唯一缺少的是补充文件。
// for testing we directly upload the file and convert to base64
$content_bytes = file_get_contents('../app/Support/DocuSign/sample.pdf');
$doc2_b64 = base64_encode($content_bytes);
# Create the document models
$document2 = new Document([ # create the DocuSign document object
'document_base64' => $doc2_b64,
'name' => 'sample', # can be different from actual file name
'file_extension' => 'pdf', # many different document types are accepted
'document_id' => '2', # a label used to reference the doc
'display' => 'modal',
'signer_must_acknowledge' => 'view',
]);
$clientSigner = $instance->createClientSigner($data);
$consultantSigner = $instance->createConsultantSigner();
// Recipients object:
$recipientsServerTemplate = new Recipients([
'signers' => [$clientSigner, $consultantSigner],
]);
// Create a composite template for the Server template + roles
$compTemplate = new CompositeTemplate([
'composite_template_id' => '1',
// Add supporting documents
// 'document' => $doc1,
'server_templates' => [
new ServerTemplate([
'sequence' => '1',
'template_id' => $instance->docuSignTemplate->template_id,
]),
],
// Add the roles via an inlineTemplate
'inline_templates' => [
new InlineTemplate([
'sequence' => '2',
'recipients' => $recipientsServerTemplate,
]),
],
]);
$envelopeDefinition = new EnvelopeDefinition();
$envelopeDefinition->setStatus('sent');
# The order in the docs array determines the order in the envelope
$envelopeDefinition->setDocuments([$document2]);
$envelopeDefinition->setCompositeTemplates([$compTemplate]);
return $envelopeDefinition;
您需要为补充文档创建第二个 CompositTemplate。
// Create a composite template for the supplemental document
$compTemplate2 = new CompositeTemplate([
'composite_template_id' => '2',
// Add supporting documents
'document' => $doc1
]);
// copy your code for the original $compTemplate here
$envelopeDefinition = new EnvelopeDefinition();
$envelopeDefinition->setStatus('sent');
# The order in the docs array determines the order in the envelope
$envelopeDefinition->setCompositeTemplates([$compTemplate, $compTemplate2]);
查看 GitHub 中的 PHP 代码 - https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/AddDocToTemplateService.php