You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过邮箱/ID生成自定义链接,引导CodeIgniter用户签署DocuSign文档?

解决方案:CodeIgniter 跳转 DocuSign 快速启动应用实现第三方签署
  • 核心思路:生成无需DocuSign登录的专属签署链接,在CodeIgniter应用中直接提供给用户跳转,无需合并两个应用。

步骤1:在DocuSign快速启动应用中生成签署链接

创建文档信封(envelope)时,为指定的签署人生成直接签署的URL,而非依赖登录会话。示例代码如下:

// 初始化DocuSign API客户端(确保已配置好API密钥、账号ID等)
$apiClient = new DocuSign\eSign\Client\ApiClient();
$apiClient->setOAuthBasePath("https://account-d.docusign.com");
$apiClient->configureJWTAuthorizationFlow($privateKey, $oauthHost, $clientId, $userId, 3600);

$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
$accountId = "你的DocuSign账号ID";
$envelopeId = "已创建的文档信封ID";

// 构建签署人视图请求
$recipientViewRequest = new DocuSign\eSign\Model\RecipientViewRequest();
$recipientViewRequest->setUserName("签署人姓名");
$recipientViewRequest->setEmail("签署人邮箱");
$recipientViewRequest->setRecipientId("1"); // 需与创建信封时指定的recipientId一致
$recipientViewRequest->setReturnUrl("http://localhost/affiniks_staging/affiniks/app/sign-finish"); // 签署完成后跳转回CI应用的页面
$recipientViewRequest->setAuthenticationMethod("none"); // 跳过DocuSign登录验证

// 生成签署URL
$viewUrl = $envelopeApi->createRecipientView($accountId, $envelopeId, $recipientViewRequest);
$signUrl = $viewUrl->getUrl(); // 这就是直接打开签署页面的链接

步骤2:在CodeIgniter应用中传递签署链接

  • 将生成的$signUrl存储到数据库,关联CI应用的用户ID和对应的DocuSign信封ID。
  • 在CI应用的用户页面,直接输出该链接:
    // 从数据库获取当前用户对应的签署链接
    $signUrl = $this->db->where('user_id', $currentUserId)->get('docusign_sign_links')->row()->sign_url;
    echo '<a href="'.$signUrl.'" target="_blank">点击签署文档</a>';
    

步骤3:处理签署完成后的回调

在CI应用的sign-finish页面,可通过DocuSign返回的参数(如envelopeId)验证签署状态:

$envelopeId = $this->input->get('envelopeId');
// 调用DocuSign API查询信封状态
$envelopeInfo = $envelopeApi->getEnvelope($accountId, $envelopeId);
if ($envelopeInfo->getStatus() === 'completed') {
    // 更新本地用户的签署状态为已完成
    $this->db->where('user_id', $currentUserId)->update('users', ['sign_status' => 'completed']);
}

关键注意事项

  • 不要使用DocuSign应用内部的登录后链接,必须通过createRecipientView API生成专属签署链接。
  • 确保两个应用的DocuSign API配置一致(使用相同的账号、密钥),避免权限问题。
  • 签署链接有有效期,若过期需重新生成。

内容的提问来源于stack exchange,提问作者Aneesha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 04:30:19