Docusign Embedded Signing(MVC 网站)- 标签未显示,文档以自由形式签名的形式出现

Docusign Embedded Signing(MVC website) - tags not showing up and the document is coming as free form signing

我正在尝试通过嵌入式签名将我的网站与 Docusign 集成。我非常成功 - 感谢 SO 的文档和指示)。

我的问题是我有一个网站,在初始注册时,我需要用户在他们继续在我的网站上购物之前对文件进行电子签名。因此,一旦他们登录,我就设置了一个 docusign 嵌入式签名体验 - 这将使他们无缝(无需登录 docusign 服务器等)到 Docusign - 签名文档中显示的位置 - 该文档很好 - 但标签是没有出现,它显示为自由形式签名。我的文档左侧有 "FIELDS",我需要将它们拖放到表单上(我已经用值填充了这些字段)。

真正的问题是 docusign 让我 "FINISH" 无需签名,因为文档显示为自由格式 - 请在下面找到我的代码 - 我正在使用 DocuSign REST API 创建嵌入式使用 /envelopes/{envelopeID}/views/recipient 调用为预定义文档模板签名。我正在使用 RESTSHARP 连接到 docusign。非常感谢您的帮助!

    protected const string IntegratorKey = "XX";
    protected const string Environment = "https://demo.docusign.net";
    protected const string templateRole = "Applicant";
    protected const string templateId = "XX"; 
    private static Logger logger = LogManager.GetCurrentClassLogger();
    protected const string AccountEmail = "XX@XX.com";
    protected const string AccountPassword = "***";
    private RestSharp.RestClient client = new RestClient();
    private RestSharp.RestRequest request;
    bool docuSignCallresult = false;

    //
    // GET: /Docusign/      
    public ActionResult launchDocusign(int id)
    {
        RestSettings.Instance.IntegratorKey = IntegratorKey;
        RestSettings.Instance.DocuSignAddress = Environment;
        RestSettings.Instance.WebServiceUrl = Environment + "/restapi/v2";

        Domain.Account currentAccount = null;
        using (var accountRepo = new AccountRepository())
        {
            currentAccount = accountRepo.AccountGet(id);
        }

        string RecipientEmail = currentAccount.Email;
        string RecipientName = currentAccount.FullName;

        Account docuSignAcct = GetDocusignAcctDetails();
        Envelope docuSignEnvelope = GetDocusignEnvelopeDetails(docuSignAcct,RecipientEmail,RecipientName);
        RecipientView rv = GetRecipientView(RecipientEmail, RecipientName);                                          

        client = new RestSharp.RestClient(Environment);
        request = new RestRequest("/restapi/{apiVersion}/accounts/{accountId}/envelopes/{envelopeId}/views/recipient");
        request.AddUrlSegment("apiVersion", "v2");
        request.AddUrlSegment("accountId", docuSignAcct.AccountId);
        request.AddUrlSegment("envelopeId", docuSignEnvelope.EnvelopeId);

        Mysite.Web.Models.DocuSignData.AuthenticationHeader header = new Mysite.Web.Models.DocuSignData.AuthenticationHeader();
        var jsonHeader = JsonConvert.SerializeObject(header);          

        request.AddHeader("X-DocuSign-Authentication", jsonHeader);
        request.Method = Method.POST;
        request.RequestFormat = DataFormat.Json;           
        request.AddJsonBody(rv);

        var response = client.Execute(request);          
        char[] charstoTrim = { '\r', '\n', ' ', '\'' };
        var json = response.Content.Trim(charstoTrim);
        var jo = JObject.Parse(json);
        var recipientUrl = jo["url"].ToString();
        return Redirect(recipientUrl);            
    }

    /// <summary>
    /// Get the recipient view to launch the docusign(Embedded signing experience)
    /// </summary>
    /// <param name="RecipientEmail"></param>
    /// <param name="RecipientName"></param>
    /// <returns></returns>

    private RecipientView GetRecipientView(string RecipientEmail, string RecipientName)
    {
        RecipientView rv = new RecipientView();
        rv.authenticationMethod = "email";
        rv.returnUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + "/MySiteController/MySiteActionMethod";
        rv.email = RecipientEmail;
        rv.userName = RecipientName;
        rv.clientUserId = "1";

        return rv;

    }

    /// <summary>
    /// Create an Envelope using the template on docusign 
    /// </summary>
    /// <param name="acct"></param>
    /// <param name="recipientEmail"></param>
    /// <param name="recipientName"></param>
    /// <returns></returns>

    private Envelope GetDocusignEnvelopeDetails(Account acct,string recipientEmail,string recipientName)
    {
        Envelope envelope = new Envelope();
        envelope.Login = acct;
        envelope.Status = "sent";
        envelope.EmailSubject = "Testing";
        envelope.TemplateId = templateId;
        envelope.TemplateRoles = new TemplateRole[]
        {
            new TemplateRole()
            {
              email = recipientEmail,
              name = recipientName,
              roleName = templateRole,
              clientUserId = "1"
            }
        };

        try
        {
            docuSignCallresult = envelope.Create();
        }
        catch (Exception ex)
        {
            logger.Error("Login to docusign failed due to {0} and the exception generated is {2}", envelope.RestError.message, ex.Message);
        }

        return envelope;

    }

    /// <summary>
    /// Access Docusign Account information 
    /// </summary>
    /// <returns></returns>
    private Account GetDocusignAcctDetails()
    {
        Account docuSignAcct = new Account();
        docuSignAcct.Email = AccountEmail;
        docuSignAcct.Password = AccountPassword;

        try
        {
            docuSignCallresult = docuSignAcct.Login();
        }
        catch (Exception ex)
        {
            logger.Error("Login to docusign failed due to {0} and the exception generated is {2}", docuSignAcct.RestError.message, ex.Message);
        }
        return docuSignAcct;
    }
}

}

正如 Jeff 在评论中提到的,这很可能是由于您没有将收件人与模板上的模板(占位符)角色正确匹配造成的。从您的代码看来,您正在发送值 Applicant 作为模板角色名称 - 这意味着您需要在 Web 控制台的模板中拥有一个名为 Applicant 的角色。

例如,在下面的屏幕截图中,角色名称是 Signer1

要修复登录到控制台并在模板上命名角色 "Applicant" 或它当前具有的任何名称,请将其复制到代码中并在 API 请求中发送。