Docusign使用.net客户端进行嵌入式签名

时间:2015-08-06 12:52:03

标签: .net client docusignapi

我正在使用DocuSign-.NET-Client(https://github.com/docusign/DocuSign-.NET-Client)在我的网站中集成嵌入式签名流程。

我们的工作流程是为新用户创建信封,然后重定向他们以签署协议。信封成功创建。但在此之后,当我尝试重定向到签名页面时,它会直接将我重定向到返回页面。

以下是创建信封的代码。

public static void CreateEnvelope()
        {
            //****** PARAMS *************************************************
            string AccountEmail = "******";
            string AccountPassword = "******";
            string RecipientEmail = "******";
            string RecipientName = "******";
            string TemplateRoleName = "******";
            //*****************************************************************

            const string integratorKey = "*******************";
            const string environment = "https://demo.docusign.net";
            bool result = false;
            var envelope = new Envelope();

            RestSettings.Instance.IntegratorKey = integratorKey;
            RestSettings.Instance.DocuSignAddress = environment;
            RestSettings.Instance.WebServiceUrl = environment + "/restapi/v2";

            var account = new Account
            {
                Email = AccountEmail,
                Password = AccountPassword
            };


            if (!account.Login())
            {
                Debug.Print("Login API call failed for user {0}.\nError Code:  {1}\nMessage:  {2}", account.Email,
                    account.RestError.errorCode, account.RestError.message);

                return;
            }
            else
            {
                // create envelope object and assign login info
                envelope = new Envelope
                {
                    Login = account,
                    TemplateId = "***********************",
                    TemplateRoles = new[]
                    {
                        new TemplateRole()
                        {
                            email = RecipientEmail,
                            name = RecipientName,
                            roleName = TemplateRoleName,
                            clientUserId = "C1E7D8B6-084A-402F-9BA8-014535D1F6C8"

                        }
                    },
                    EmailSubject = "Request",
                    Status = "sent"
                };

                result = envelope.Create();

                if (envelope.RestError != null)
                {
                    Debug.Print("Error code:  {0}\nMessage:  {1}", envelope.RestError.errorCode, envelope.RestError.message);
                    return;
                }

                bool res = envelope.GetSenderView("https://demo.docusign.net");
                if (!res)
                {
                    if (envelope.RestError != null)
                        {
                            Console.WriteLine("Error code:  {0}\nMessage:  {1}", envelope.RestError.errorCode, envelope.RestError.message);
                                return false;
                        }
                        else
                        {
                                Console.WriteLine("Error encountered retrieving signing token, please review your envelope and recipient data.");
                                return false;
                        }
                }
                else
                {
                    // open the envelope's sending view
                        Process.Start(envelope.SenderViewUrl);
                 }
            }

            return;
        }

1 个答案:

答案 0 :(得分:0)

它自动进入重定向页面的原因是因为您已将信封的状态设置为“已发送”,告知DocuSign对重定向URL进行操作。

如果您希望发件人在发送之前查看草稿,请删除“已发送”状态。 如果要向他们展示签署文档的视图,请调用GetRecipientView()而不是GetSenderView()