-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Hi, I'm using the library inside a Laravel project where I'm trying to generate the signing url for a specific signer.
Before this, the envelope is created using the api as well, calling the createSenderView endpoint, passing all of the envelope definitions.
TL;DR
The createRecipientView endpoint only works passing the client_user_id correct. The same that was passed within the envelope creation endpoint (createRecipientView).
Since I'm using a template_id, I also pass the Templates Roles to the envelope definitions. Inside the templates roles I can pass the client_user_id, but if the person that is finishing the envelope deletes the signers and creates new ones even with the same data (Name and Email) the client_user_id will be null. And with this field null, when I try to get the embedded signing url, calling the createRecipientView, passing the signer's name, email and client_user_id = null returned by DocuSign, the loaded envelope does not have the signature field, seems to be in a review mode.
I also tried using the user_id from DocuSign and got the same thing.
Creating the preview and send envelope url
$envelopeSigners = [
resolve(TemplateRole::class)
->setRoleName('signer')
->setClientUserId($sender->id)
->setName($sender->name)
->setEmail($sender->email),
];
$clientId = null;
foreach ($signers as $signer) {
if (data_get($signer, 'is_client')) {
$clientId = data_get($signer, 'user_id');
}
$envelopeSigners[] = resolve(TemplateRole::class)
->setRoleName('signer')
->setClientUserId(data_get($signer, 'user_id'))
->setName(data_get($signer, 'name'))
->setEmail(data_get($signer, 'email'));
}
$envelopeDefinition = resolve(EnvelopeDefinition::class)
->setStatus('created')
->setTemplateId($template->template_id)
->setTemplateRoles($envelopeSigners);
$customFields = [];
$senderUserIdField = app(TextCustomField::class);
$senderUserIdField->setName(CustomFieldsKeys::SenderUserIdKey)
->setShow('false')
->setValue(user()->id);
$customFields[] = $senderUserIdField;
$meetingIdFields = app(TextCustomField::class);
$meetingIdFields->setName(CustomFieldsKeys::MeetingIdCustomFieldKey)
->setShow('false')
->setValue($meeting->id);
$customFields[] = $meetingIdFields;
if ($clientId) {
$clientIdField = app(TextCustomField::class);
$clientIdField->setName(CustomFieldsKeys::ClientIdCustomFieldKey)
->setShow('false')
->setValue($clientId);
$customFields[] = $clientIdField;
}
$envelopeField = app(CustomFields::class);
$envelopeField->setTextCustomFields($customFields);
$envelopeDefinition->setCustomFields($envelopeField);
try {
$response = $this->envelopesApi
->createEnvelope(
account_id: $this->accountId,
envelope_definition: $envelopeDefinition,
);
$options = app(ReturnUrlRequest::class);
$options->setReturnUrl(route('docusign.envelope-callback'));
return $this->envelopesApi->createSenderView($this->accountId, $response->getEnvelopeId(), $options)->getUrl();Creating the embedded signing url
$request = app(RecipientViewRequest::class)
->setAuthenticationMethod('None')
->setEmail($signer->email)
->setUserName($signer->name)
->setClientUserId($signer->docusign_user_id) // If that's null it never works
->setReturnUrl($returnUrl)
->setFrameAncestors([
config('app.url'),
config('services.docusign.signing_link_frame_ancestor'),
])
->setMessageOrigins([
config('services.docusign.signing_link_frame_ancestor'),
]);
try {
return $this->envelopesApi
->createRecipientView(
account_id: $this->accountId,
envelope_id: $envelope->envelope_id,
recipient_view_request: $request,
)
->getUrl();