如何在Laravel中获取DocuSign发送给签署者的签署URL?
获取DocuSign签署者的签署URL解决方案
你之前尝试的getRecipientViewUrl方法并不正确,DocuSign的Envelope对象没有这个方法。要生成签署者的直接签署URL,需要通过RecipientView API来创建,具体步骤如下:
1. 确保构建信封时给签署者设置client_user_id
在你的buildEnvelope方法中,给签署者对象添加client_user_id参数,这个值用于关联后续的视图请求:
$signer = new Signer([ 'email' => 'signer@example.com', 'name' => '签署者姓名', 'recipient_id' => '1', 'client_user_id' => 'unique_client_id_123' // 自定义唯一标识,需和后续请求一致 ]);
2. 修改send方法,生成签署URL
替换你注释掉的代码部分,创建RecipientViewRequest并调用API获取链接:
// 替换原注释的代码块 try { $envelopeApi = new EnvelopesApi($apiClient); $result = $envelopeApi->createEnvelope($accountInfo[0]->getAccountId(), $envelopeDefenition); $envelopeId = $result->getEnvelopeId(); // 创建RecipientView请求 $recipientViewRequest = new RecipientViewRequest([ 'authentication_method' => 'email', 'client_user_id' => 'unique_client_id_123', // 和签署者的client_user_id一致 'recipient_id' => '1', 'return_url' => url('/sign-completed'), // 签署完成后跳转的URL 'user_name' => '签署者姓名', 'email' => 'signer@example.com' ]); // 获取签署URL $viewResponse = $envelopeApi->createRecipientView($accountInfo[0]->getAccountId(), $envelopeId, $recipientViewRequest); $signingUrl = $viewResponse->getUrl(); // 输出或使用签署URL dd($signingUrl); } catch (\Throwable $th) { return back()->withError($th->getMessage())->withInput(); }
关键注意事项
client_user_id必须在信封构建和视图请求中保持一致,否则API会返回错误。- 生成的签署URL和邮件中的签署链接功能完全一致,都是直接引导签署者进入签署页面,有效期默认较短(通常为5分钟),如果过期需要重新生成。
- 如果你确实需要获取DocuSign发送邮件中的原始链接,DocuSign API没有直接提供提取接口,因为该链接是DocuSign内部生成并发送的,但通过上述方法生成的链接可以替代使用。
内容的提问来源于stack exchange,提问作者Abdul Aleem
相关产品推荐
相关产品推荐

