public static ViewUrl getRecipientUrl(EnvelopesApi envelopesApi, string accountId, EnvelopeDefinition envDef, string envelopeId, Signer recipient)
        {
            // set the url where you want the recipient to go once they are done signing
            // - this can be used by your app to watch the URL and detect when signing has completed (or was canceled)
            var returnUrl = new RecipientViewRequest();

            //Get Config settings from App.config
            DocuSignConfig configSettings = new DocuSignConfig();

            returnUrl.ReturnUrl = configSettings.LOCAL_RETURN_URL + "pop/" + envelopeId;

            returnUrl.AuthenticationMethod = "email";

            // recipient information must match embedded recipient info we provided
            returnUrl.UserName     = recipient.Name;
            returnUrl.Email        = recipient.Email;
            returnUrl.RecipientId  = recipient.RecipientId;
            returnUrl.ClientUserId = recipient.ClientUserId;

            RecipientViewRequest recipipentViewRequest = new RecipientViewRequest();
            ViewUrl viewUrl = new ViewUrl();

            viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, returnUrl);
            return(viewUrl);
        }
Beispiel #2
0
        public ViewUrl EmbeddedSigning(String accountId, String envelopeId)
        {
            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "https://www.docusign.com/",
                ClientUserId         = "1001", // must match clientUserId of the embedded recipient
                AuthenticationMethod = "email",
                UserName             = "******",
                Email = "{USER_EMAIL}"
            };

            // instantiate an envelopesApi object
            EnvelopesApi envelopesApi = new EnvelopesApi();

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions);

            // print the JSON response
            Console.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));
            Trace.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));

            // Start the embedded signing session
            System.Diagnostics.Process.Start(recipientView.Url);

            return(recipientView);
        }
        /// <summary>
        /// Creates a new envelope, adds a single document and a signle recipient (signer) and generates a url that is used for embedded signing.
        /// </summary>
        /// <param name="signerEmail">Email address for the signer</param>
        /// <param name="signerName">Full name of the signer</param>
        /// <param name="signerClientId">A unique ID for the embedded signing session for this signer</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="docPdf">String of bytes representing the document (pdf)</param>
        /// <param name="returnUrl">URL user will be redirected to after they sign</param>
        /// <param name="pingUrl">URL that DocuSign will be able to ping to incdicate signing session is active</param>
        /// <returns>The envelopeId (GUID) of the resulting Envelope and the URL for the embedded signing</returns>
        public static (string, string) SendEnvelopeForEmbeddedSigning(string signerEmail, string signerName, string signerClientId,
                                                                      string accessToken, string basePath, string accountId, string docPdf, string returnUrl, string pingUrl = null)
        {
            // Step 1. Create the envelope definition
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, signerClientId, docPdf);

            // Step 2. Call DocuSign to create the envelope
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelope);
            string          envelopeId   = results.EnvelopeId;

            // Step 3. create the recipient view, the Signing Ceremony
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, returnUrl, signerClientId, pingUrl);
            // call the CreateRecipientView API
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            // Step 4. Redirect the user to the Signing Ceremony
            // Don't use an iFrame!
            // State can be stored/recovered using the framework's session or a
            // query parameter on the returnUrl (see the makeRecipientViewRequest method)
            string redirectUrl = results1.Url;

            // returning both the envelopeId as well as the url to be used for embedded signing
            return(envelopeId, redirectUrl);
        }
Beispiel #4
0
        private RecipientViewRequest MakeRecipientViewRequest(string signerEmail, string signerName,
                                                              string dsReturnUrl)
        {
            // Data for this method
            // signerEmail
            // signerName
            // dsReturnUrl
            // signerClientId -- class global

            RecipientViewRequest viewRequest = new RecipientViewRequest
            {
                // Set the url where you want the recipient to go once they are done signing
                // should typically be a callback route somewhere in your app.
                ReturnUrl = dsReturnUrl,

                // How has your app authenticated the user? In addition to your app's
                // authentication, you can include authenticate steps from DocuSign.
                // Eg, SMS authentication
                AuthenticationMethod = "none",

                // Recipient information must match embedded recipient info
                // we used to create the envelope.
                Email        = signerEmail,
                UserName     = signerName,
                ClientUserId = signerClientId
            };

            // DocuSign recommends that you redirect to DocuSign for the
            // Signing Ceremony. There are multiple ways to save state.

            return(viewRequest);
        }
        /// <summary>
        /// Creates a composite template that includes both a template and a document
        /// </summary>
        /// <param name="signerEmail">Email address for the signer</param>
        /// <param name="signerName">Full name of the signer</param>
        /// <param name="ccEmail">Email address for the cc recipient</param>
        /// <param name="ccName">Name of the cc recipient</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="item">Item to order for the document that is generated</param>
        /// <param name="quantity">Quantity to order for the document that is generated</param>
        /// <param name="returnUrl">URL user will be redirected to after they sign</param>
        /// <param name="signerClientId">A unique ID for the embedded signing session for this signer</param>
        /// <param name="templateId">The templateId for the tempalte to use to create an envelope</param>
        /// <returns>URL for embedded signing session for the newly created envelope</returns>
        public static string CreateEnvelopeFromCompositeTemplate(string signerEmail, string signerName, string ccEmail,
                                                                 string ccName, string accessToken, string basePath,
                                                                 string accountId, string item, string quantity, string returnUrl, string signerClientId, string templateId)
        {
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi envelopesApi = new EnvelopesApi(config);

            // Step 1. Make the envelope request body
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, item, quantity, signerClientId, templateId);

            // Step 2. call Envelopes::create API method
            // Exceptions will be caught by the calling function
            EnvelopeSummary results    = envelopesApi.CreateEnvelope(accountId, envelope);
            string          envelopeId = results.EnvelopeId;

            Console.WriteLine("Envelope was created. EnvelopeId " + envelopeId);

            // Step 3. create the recipient view, the Signing Ceremony
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, returnUrl, signerClientId);
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            return(results1.Url);
        }
        public void JwtCreateEmbeddedSigningViewTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = testConfig.ReturnUrl,
                ClientUserId         = "1234", // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = testConfig.RecipientName,
                Email = testConfig.RecipientEmail
            };

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(testConfig.AccountId, testConfig.EnvelopeId, viewOptions);

            Assert.IsNotNull(recipientView);

            // Start the embedded signing session
            System.Diagnostics.Process.Start(recipientView.Url);

            Assert.IsNotNull(recipientView.Url);
        }
Beispiel #7
0
        public static string CreateEnvelopeFromHTML(
            string signerEmail,
            string signerName,
            string ccEmail,
            string ccName,
            string signerClientId,
            string accessToken,
            string basePath,
            string accountId,
            string returnUrl,
            string pingUrl = null)
        {
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, signerClientId);

            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            EnvelopesApi    envelopesApi    = new EnvelopesApi(apiClient);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelope);
            string          envelopeId      = envelopeSummary.EnvelopeId;

            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, returnUrl, signerClientId, pingUrl);

            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            return(viewUrl.Url);
        }
Beispiel #8
0
        public string CreateRecipientView(string envelopeId, RecipientViewRequest viewRequest)
        {
            var envelopesApi  = new EnvelopesApi(_ApiClient);
            var recipientView = envelopesApi.CreateRecipientView(AccountId, envelopeId, viewRequest);

            return(recipientView.Url);
        }
Beispiel #9
0
        public static ViewUrl createEmbeddedSigningViewTest()
        {
            DocuSignHelper.configureApiClient(Constants.DocuSignConstants.DemoPath);
            string accountId = DocuSignHelper.loginApi(Config.AppSettings["USERNAME"], Config.AppSettings["PASSWORD"]);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK Jacel] - Please sign this doc";

            Document doc = new Document();

            doc.DocumentBase64 = Constants.DocuSignConstants.base64pdf;
            doc.Name           = "SamplePDF.pdf";
            doc.DocumentId     = "1";

            envDef.Documents = new List <Document>();
            envDef.Documents.Add(doc);

            Signer signer = new Signer();

            signer.Email        = "*****@*****.**";
            signer.Name         = "Steph Curry";
            signer.RecipientId  = "1";
            signer.ClientUserId = "1234";

            envDef.Recipients         = new Recipients();
            envDef.Recipients.Signers = new List <Signer>();
            envDef.Recipients.Signers.Add(signer);

            signer.Tabs = new Tabs();
            SignHere signHere = new SignHere();

            signHere.DocumentId  = "1";
            signHere.PageNumber  = "1";
            signHere.RecipientId = "1";
            signHere.XPosition   = "100";
            signHere.YPosition   = "100";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Status = "sent";

            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "https://www.docusign.com/devcenter",
                ClientUserId         = "1234", // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = envDef.Recipients.Signers[0].Name,
                Email = envDef.Recipients.Signers[0].Email
            };

            ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewOptions);

            Console.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));

            return(new ViewUrl());
        }
Beispiel #10
0
        /// <summary>
        /// Views the request.
        /// </summary>
        /// <param name="returnUrl">The return URL.</param>
        /// <param name="clientUserId">The client user identifier.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="email">The email.</param>
        /// <returns>RecipientViewRequest.</returns>
        public RecipientViewRequest ViewRequest(string returnUrl, string clientUserId, string userName, string email)
        {
            var agentViewOptions = new RecipientViewRequest
            {
                ReturnUrl            = $"{Settings.Default.BaseUrl}{returnUrl}",
                AuthenticationMethod = "email",
                ClientUserId         = clientUserId, // must match clientUserId set in Roles
                UserName             = userName,
                Email = email
            };

            return(agentViewOptions);
        }
        /// <summary>
        /// This code comes from
        /// https://developers.docusign.com/esign-rest-api/code-examples/code-example-embedded-signing
        /// https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/Controllers/Eg001EmbeddedSigningController.cs
        /// </summary>
        private RecipientViewRequest MakeRecipientViewRequest(HttpRequest request, SampleCustomer customer, string envelopeId)
        {
            // Construct the return url that Docusign will use when the signing ceremony is over
            var returnUrlFromConfig = this.Configuration["DocuSign:returnUrlForEmbeddedSigning"];
            var relativePath        = returnUrlFromConfig ?? "Docusign/EmbeddedSigningProcessor";

            if (relativePath.StartsWith('/'))  // strip leading slash
            {
                relativePath = relativePath.Substring(1);
            }

            string returnUrl =
                $"{request.Scheme}://{request.Host}/{relativePath}?email={customer.Email}&envelopeId={envelopeId}";

            // Set the url where you want the recipient to go once they are done signing
            // should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily.
            RecipientViewRequest viewRequest = new RecipientViewRequest
            {
                ReturnUrl = returnUrl,

                // How has your app authenticated the user? In addition to your app's
                // authentication, you can include authenticate steps from DocuSign.
                // Eg, SMS authentication
                AuthenticationMethod = "none",

                // Recipient information must match embedded recipient info
                // we used to create the envelope.
                Email        = customer.Email,
                UserName     = customer.Name,
                ClientUserId = customer.SignerId,

                // DocuSign recommends that you redirect to DocuSign for the
                // Signing Ceremony. There are multiple ways to save state.
                // To maintain your application's session, use the pingUrl
                // parameter. It causes the DocuSign Signing Ceremony web page
                // (not the DocuSign server) to send pings via AJAX to your
                // app,
                PingFrequency = "600",  // seconds

                // NOTE: The pings will only be sent if the pingUrl is an https address
                PingUrl = $"{request.Scheme}://{request.Host}"  // optional setting
            };

            return(viewRequest);
        }
        protected void getUrl_Click(object sender, EventArgs e)
        {
            var client  = new RestClient("https://demo.docusign.net/restapi");
            var request = new RestRequest("/v2/accounts/3910586/envelopes?from_date=2017-10-10&status=sent&custom_field=orderId=" + txtOrderId.Text.ToUpper(), Method.GET);

            request.AddHeader("X-DocuSign-Authentication", "<DocuSignCredentials><Username>[email protected]</Username><Password>docusign</Password><IntegratorKey>fdc86660-3188-4286-ae42-f73e0f221b2b</IntegratorKey></DocuSignCredentials>");
            IRestResponse response = client.Execute(request);
            JObject       o        = JObject.Parse(response.Content);

            if ((string)o["resultSetSize"] != "0")
            {
                string dsEnvelopeId = (string)o["envelopes"][0]["envelopeId"];

                if (Configuration.Default.DefaultHeader.Count < 1)
                {
                    // we set the api client in global config when we configured the client
                    ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");
                    Configuration.Default.ApiClient = apiClient;
                    string dsAuthHeader = "<DocuSignCredentials><Username>[email protected]</Username><Password>docusign</Password><IntegratorKey>fdc86660-3188-4286-ae42-f73e0f221b2b</IntegratorKey></DocuSignCredentials>";
                    Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", dsAuthHeader);
                }
                ;
                Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
                Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", "<DocuSignCredentials><Username>[email protected]</Username><Password>docusign</Password><IntegratorKey>fdc86660-3188-4286-ae42-f73e0f221b2b</IntegratorKey></DocuSignCredentials>");

                EnvelopesApi envelopesApi = new EnvelopesApi();

                Recipients signers = envelopesApi.ListRecipients("3910586", dsEnvelopeId);

                RecipientViewRequest viewOptions = new RecipientViewRequest()
                {
                    ReturnUrl            = "https://innov8ive.app/uscc/signer2start.aspx?eid=" + dsEnvelopeId,
                    ClientUserId         = signers.Signers[0].ClientUserId,
                    AuthenticationMethod = "email",
                    UserName             = signers.Signers[0].Name,
                    Email = signers.Signers[0].Email
                };

                ViewUrl recipientView = envelopesApi.CreateRecipientView("3910586", dsEnvelopeId, viewOptions);

                Response.Redirect(recipientView.Url);
            }
            else
            {
                txtOrderId.Attributes.Add("placeholder", "ID not found");
                orderIdDiv.Attributes.Add("Class", "col-sm-2 col-xs-4 has-error");
                txtOrderId.Text = "";
            }
        }
Beispiel #13
0
        public string CreateRecipientView(string signerEmail, string signerName, string envelopeId)
        {
            var viewRequest = new RecipientViewRequest
            {
                ReturnUrl = dsReturnUrl + "?state=123&envelopeId=" + envelopeId,

                AuthenticationMethod = "none",

                Email        = signerEmail,
                UserName     = signerName,
                ClientUserId = signerClientId,
            };

            return(_client.CreateRecipientView(envelopeId, viewRequest));
        }
Beispiel #14
0
        public ViewUrl GetViewUrl(EnvelopesApi envelopesApi, EnvelopeDefinition envelopeDefinition, EnvelopeSummary envelopeSummary)
        {
            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "http://localhost:49899/Finished",
                ClientUserId         = "123",
                AuthenticationMethod = "email",
                UserName             = envelopeDefinition.Recipients.Signers[0].Name,
                Email = envelopeDefinition.Recipients.Signers[0].Email
            };

            ViewUrl url = envelopesApi.CreateRecipientView("4003313", envelopeSummary.EnvelopeId, viewOptions);

            return(url);
        }
Beispiel #15
0
        public ViewUrl CreateRecipientView(EmbededUserModel embededUserInfo, string returnUrl)
        {
            var envelopeApi = PrepareApi();
            var view        = new RecipientViewRequest()
            {
                UserName             = embededUserInfo.Name,
                Email                = embededUserInfo.Mail,
                RecipientId          = embededUserInfo.RecipientId,
                ClientUserId         = embededUserInfo.ClientUserId,
                AuthenticationMethod = "email",
                ReturnUrl            = returnUrl
            };

            return(envelopeApi.CreateRecipientView(AccountID, embededUserInfo.EnvelopeId, view));
        }
        private static RecipientViewRequest MakeRecipientViewRequest(string signerEmail, string signerName, string returnUrl, string signerClientId, string pingUrl = null)
        {
            // Data for this method
            // signerEmail
            // signerName
            // dsPingUrl -- class global
            // signerClientId -- class global
            // dsReturnUrl -- class global


            RecipientViewRequest viewRequest = new RecipientViewRequest();

            // Set the url where you want the recipient to go once they are done signing
            // should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily.
            viewRequest.ReturnUrl = returnUrl + "?state=123";

            // How has your app authenticated the user? In addition to your app's
            // authentication, you can include authenticate steps from DocuSign.
            // Eg, SMS authentication
            viewRequest.AuthenticationMethod = "none";

            // Recipient information must match embedded recipient info
            // we used to create the envelope.
            viewRequest.Email        = signerEmail;
            viewRequest.UserName     = signerName;
            viewRequest.ClientUserId = signerClientId;

            // DocuSign recommends that you redirect to DocuSign for the
            // Signing Ceremony. There are multiple ways to save state.
            // To maintain your application's session, use the pingUrl
            // parameter. It causes the DocuSign Signing Ceremony web page
            // (not the DocuSign server) to send pings via AJAX to your
            // app,
            // NOTE: The pings will only be sent if the pingUrl is an https address
            if (pingUrl != null)
            {
                viewRequest.PingFrequency = "600";   // seconds
                viewRequest.PingUrl       = pingUrl; // optional setting
            }

            return(viewRequest);
        }
Beispiel #17
0
        // ***DS.snippet.0.start
        private string DoWork(string signerEmail, string signerName,
                              string accessToken, string basePath, string accountId, string fileName)
        {
            // Data for this method
            // signerEmail
            // signerName
            // accessToken
            // basePath
            // accountId

            // dsPingUrl -- class global
            // signerClientId -- class global
            // dsReturnUrl -- class global

            // Step 1. Create the envelope definition

            // fileName = DownloadFileViaRestAPI(fileName);
            //     fileName = Config.docPdf;
            fileName = "wwwroot/World_Wide_Corp_lorem.pdf";
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, fileName);

            // Step 2. Call DocuSign to create the envelope
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var             envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelope);
            string          envelopeId   = results.EnvelopeId;

            // Save for future use within the example launcher
            RequestItemsService.EnvelopeId = envelopeId;

            // Step 3. create the recipient view, the Signing Ceremony
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, envelopeId);
            // call the CreateRecipientView API
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            // Step 4. Redirect the user to the Signing Ceremony
            // Don't use an iFrame!
            // State can be stored/recovered using the framework's session or a
            // query parameter on the returnUrl (see the makeRecipientViewRequest method)
            string redirectUrl = results1.Url;

            return(redirectUrl);
        }
Beispiel #18
0
        public void EmbeddedSigningTest()
        {
            try
            {
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();
                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                envDef.Status       = "sent";
                envDef.EmailSubject = "Please Sign my C# SDK Envelope";
                string clientUserId = "1234";
                envDef.Recipients.Signers[0].ClientUserId = clientUserId;

                EnvelopesApi envelopesApi = new EnvelopesApi();

                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envelopeSummary);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(envelopeSummary.EnvelopeId));


                // get a URL that can be placed in a browser or embedded in an IFrame
                string returnUrl = TestConfig.DefaultReturnUrl;
                RecipientViewRequest recipientView = new RecipientViewRequest()
                {
                    ReturnUrl            = returnUrl,
                    ClientUserId         = clientUserId,
                    AuthenticationMethod = "email",
                    UserName             = envDef.Recipients.Signers[0].Name,
                    Email = envDef.Recipients.Signers[0].Email
                };

                ViewUrl viewUrl = envelopesApi.CreateRecipientView(TestConfig.AccountId, envelopeSummary.EnvelopeId, recipientView);
                Assert.IsNotNull(viewUrl);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(viewUrl.Url));
                Trace.WriteLine("ViewUrl is " + viewUrl);

                /// Start a browser to Sign
                System.Diagnostics.Process.Start(viewUrl.Url);
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
        public void CreateRecipientView_CorrectInputParameters_ReturnViewUrl()
        {
            CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(
                ref _testConfig);

            var viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = _testConfig.ReturnUrl,
                ClientUserId         = "1234",
                AuthenticationMethod = "email",
                UserName             = _testConfig.RecipientName,
                Email = _testConfig.RecipientEmail
            };

            ViewUrl recipientView = _envelopesApi.CreateRecipientView(_testConfig.AccountId, _testConfig.EnvelopeId, viewOptions);

            Assert.IsNotNull(recipientView?.Url);
        }
Beispiel #20
0
        private RecipientViewRequest BuildRecipientViewRequest(string signerEmail, string signerName, string returnUrl, string pingUrl)
        {
            RecipientViewRequest viewRequest = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl,
                AuthenticationMethod = "none",
                Email        = signerEmail,
                UserName     = signerName,
                ClientUserId = _signerClientId
            };

            if (pingUrl != null)
            {
                viewRequest.PingFrequency = "600";
                viewRequest.PingUrl       = pingUrl;
            }

            return(viewRequest);
        }
        // Step 4 start
        private static RecipientViewRequest MakeRecipientViewRequest(
            string hostEmail,
            string hostName,
            string returnUrl,
            string pingUrl = null)
        {
            var recipientViewRequest = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl + "?state=123",
                AuthenticationMethod = "none",
                Email    = hostEmail,
                UserName = hostName
            };

            if (pingUrl != null)
            {
                recipientViewRequest.PingFrequency = "600";
                recipientViewRequest.PingUrl       = pingUrl;
            }
            return(recipientViewRequest);
        }
        protected void continue_Click(object sender, EventArgs e)
        {
            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", envelope.dsAuthHeader);

            EnvelopesApi envelopesApi = new EnvelopesApi();

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "https://innov8ive.app/hmd/status.aspx",
                ClientUserId         = envelope.dsSigner2CID, // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = envelope.dsSigner2Name,
                Email = envelope.dsSigner2Email
            };

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(envelope.dsAccountId, envelope.dsEnvelopeId, viewOptions);

            Response.Redirect(recipientView.Url);
        }
        /// <summary>
        /// Creates a new envelope, adds a single document and an in-person signer and generates a url that is used for embedded signing.
        /// </summary>
        /// <param name="hostEmail">Email address for the host</param>
        /// <param name="hostName">Full name of the host</param>
        /// <param name="signerEmail">Email address for the signer</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="docPdf">String of bytes representing the document (pdf)</param>
        /// <param name="returnUrl">URL user will be redirected to after they sign</param>
        /// <param name="pingUrl">URL that DocuSign will be able to ping to incdicate signing session is active</param>
        /// <returns>The URL for the embedded signing</returns>
        public static string SendEnvelopeForInPersonSigning(string hostEmail, string hostName, string signerEmail, string accessToken,
                                                            string basePath, string accountId, string docPdf, string returnUrl, string pingUrl = null)
        {
            EnvelopeDefinition envelopeDefinition = PrepareEnvelope(hostEmail, hostName, signerEmail, docPdf);

            // Step 3 start
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);

            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);
            // Step 3 end
            // Step 5 start
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(hostEmail, hostName, returnUrl, pingUrl);
            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewRequest);

            // Step 5 end

            return(viewUrl.Url);
        }
Beispiel #24
0
        protected void continue_Click(object sender, EventArgs e)
        {
            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", "<DocuSignCredentials><Username>[email protected]</Username><Password>docusign</Password><IntegratorKey>fdc86660-3188-4286-ae42-f73e0f221b2b</IntegratorKey></DocuSignCredentials>");

            EnvelopesApi envelopesApi = new EnvelopesApi();

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl            = "https://innov8ive.app/uscc/customerfinish.aspx",
                ClientUserId         = "1", // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName             = "******",
                Email = "*****@*****.**"
            };

            string dsEnvelopeId = Request.QueryString["eid"];

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView("3910586", dsEnvelopeId, viewOptions);

            Response.Redirect(recipientView.Url);
        }
Beispiel #25
0
        // ***DS.snippet.0.start
        private string DoWork(string signerEmail, string signerName, string ccEmail,
                              string ccName, string accessToken, string basePath,
                              string accountId, string item, string quantity, string dsReturnUrl)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // item
            // quantity
            // accessToken
            // basePath
            // accountId
            // dsReturnUrl
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi envelopesApi = new EnvelopesApi(config);

            // Step 1. Make the envelope request body
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, item, quantity);

            // Step 2. call Envelopes::create API method
            // Exceptions will be caught by the calling function
            EnvelopeSummary results    = envelopesApi.CreateEnvelope(accountId, envelope);
            String          envelopeId = results.EnvelopeId;

            Console.WriteLine("Envelope was created. EnvelopeId " + envelopeId);

            // Step 3. create the recipient view, the Signing Ceremony
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName, dsReturnUrl);
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            return(results1.Url);
        }
Beispiel #26
0
        private static RecipientViewRequest MakeRecipientViewRequest(
            string signerEmail,
            string signerName,
            string returnUrl,
            string signerClientId,
            string pingUrl = null)
        {
            RecipientViewRequest viewRequest = new RecipientViewRequest();

            viewRequest.ReturnUrl            = returnUrl + "?state=123";
            viewRequest.AuthenticationMethod = "none";

            viewRequest.Email        = signerEmail;
            viewRequest.UserName     = signerName;
            viewRequest.ClientUserId = signerClientId;

            if (pingUrl != null)
            {
                viewRequest.PingFrequency = "600";
                viewRequest.PingUrl       = pingUrl;
            }

            return(viewRequest);
        }
Beispiel #27
0
        /// <summary>
        /// Returns a URL to the recipient view UI. Returns a URL that allows you to embed the recipient view of the DocuSign UI in your applications. This call cannot be used to view draft envelopes, since those envelopes have not been sent. \n\nImportant: iFrames should not be used for embedded operations on mobile devices due to screen space issues. For iOS devices DocuSign recommends using a WebView. \n\nAn entry is added into the Security Level section of the DocuSign Certificate of Completion that reflects the `securityDomain` and `authenticationMethod` properties used to verify the user identity.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipientViewRequest">TBD Description</param>
		/// <returns>5ViewUrl</returns>
        public ViewUrl CreateRecipientView (string accountId, string envelopeId, RecipientViewRequest recipientViewRequest)
        {
             ApiResponse<ViewUrl> response = CreateRecipientViewWithHttpInfo(accountId, envelopeId, recipientViewRequest);
             return response.Data;
        }
Beispiel #28
0
        /// <summary>
        /// Returns a URL to the recipient view UI. Returns a URL that allows you to embed the recipient view of the DocuSign UI in your applications. This call cannot be used to view draft envelopes, since those envelopes have not been sent. \n\nImportant: iFrames should not be used for embedded operations on mobile devices due to screen space issues. For iOS devices DocuSign recommends using a WebView. \n\nAn entry is added into the Security Level section of the DocuSign Certificate of Completion that reflects the `securityDomain` and `authenticationMethod` properties used to verify the user identity.
        /// </summary>
	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipientViewRequest">TBD Description</param>
		/// <returns>8Task of ApiResponse (ViewUrl)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<ViewUrl>> CreateRecipientViewAsyncWithHttpInfo (string accountId, string envelopeId, RecipientViewRequest recipientViewRequest)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null) throw new ApiException(400, "Missing required parameter 'accountId' when calling CreateRecipientView");
            // verify the required parameter 'envelopeId' is set
            if (envelopeId == null) throw new ApiException(400, "Missing required parameter 'envelopeId' when calling CreateRecipientView");
            
    
            var path_ = "/v2/accounts/{accountId}/envelopes/{envelopeId}/views/recipient";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (accountId != null) pathParams.Add("accountId", Configuration.ApiClient.ParameterToString(accountId)); // path parameter
            if (envelopeId != null) pathParams.Add("envelopeId", Configuration.ApiClient.ParameterToString(envelopeId)); // path parameter
            

						
			
			

            
            
            postBody = Configuration.ApiClient.Serialize(recipientViewRequest); // http body (model) parameter
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling CreateRecipientView: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling CreateRecipientView: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<ViewUrl>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (ViewUrl) Configuration.ApiClient.Deserialize(response, typeof(ViewUrl)));
            
        }
Beispiel #29
0
        /// <summary>
        /// Returns a URL to the recipient view UI. Returns a URL that allows you to embed the recipient view of the DocuSign UI in your applications. This call cannot be used to view draft envelopes, since those envelopes have not been sent. \n\nImportant: iFrames should not be used for embedded operations on mobile devices due to screen space issues. For iOS devices DocuSign recommends using a WebView. \n\nAn entry is added into the Security Level section of the DocuSign Certificate of Completion that reflects the `securityDomain` and `authenticationMethod` properties used to verify the user identity.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="envelopeId">The envelopeId Guid of the envelope being accessed.</param> <param name="recipientViewRequest">TBD Description</param>
		/// <returns>7Task of ViewUrl</returns>
        public async System.Threading.Tasks.Task<ViewUrl> CreateRecipientViewAsync (string accountId, string envelopeId, RecipientViewRequest recipientViewRequest)
        {
             ApiResponse<ViewUrl> response = await CreateRecipientViewAsyncWithHttpInfo(accountId, envelopeId, recipientViewRequest);
             return response.Data;

        }
        public async Task <IActionResult> OnPostAsync()
        {
            // Embedded Signing Ceremony
            // 1. Create envelope request obj
            // 2. Use the SDK to create and send the envelope
            // 3. Create Envelope Recipient View request obj
            // 4. Use the SDK to obtain a Recipient View URL
            // 5. Redirect the user's browser to the URL

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object
            EmbeddedSigning pageInfo = new EmbeddedSigning
            {
                signerName    = "Tanny Ng",
                signerEmail   = "*****@*****.**",
                signerId      = "1000",
                signerRouting = "1",
                accessToken   = "eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2Iiwia2lkIjoiNjgxODVmZjEtNGU1MS00Y2U5LWFmMWMtNjg5ODEyMjAzMzE3In0.AQoAAAABAAUABwCALdLYwezWSAgAgG315gTt1kgCAC5WseC6Pj1BpkJ7B9-e_VQVAAEAAAAYAAkAAAAFAAAAKwAAAC0AAAAvAAAAMQAAADIAAAA4AAAAMwAAADUAAAANACQAAABmMGYyN2YwZS04NTdkLTRhNzEtYTRkYS0zMmNlY2FlM2E5NzgSAAEAAAALAAAAaW50ZXJhY3RpdmUwAIAAodfB7NZINwDkybNa7LwrS5p6OhdY9kFz.LHHS7H4GTayO31-USuesGb--00NMcrOqO0KnzoKMhM55ClXR2vw2OzKShqI3yhIjHc0CyGoyOtNrEW0MN0o8rRZuctb5hNtR9RAtbuNZ-hITpjyL9LBFZWxV91dYAmlgrBAcM2LtrZTWHolkqGLUNQMpD_vI8BqqT3UEO9zBL5OUz4WwSZgBoCmdejMVq-zOq-ALPpD6YoX0HoHiZHVl4_DTwTiJ_lB6I3z72fh3-i6f7iD_kaJyc2nA5jAtRXVGvX_gNUPhA4aDIZ8tJ8TTZW9hbgQ2BkFlwm69xqvRjMUuQlg6xnfW7vlvtI6tQ7GAUlVhQS5KX9FveUDYogidQw"
            };

            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Petition Sample", FileExtension = "pdf", DocumentId = docId
            };

            Document[] documents = new Document[] { document };

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email        = pageInfo.signerEmail,
                Name         = pageInfo.signerName,
                ClientUserId = pageInfo.signerId,
                RecipientId  = pageInfo.signerId,
                RoutingOrder = pageInfo.signerRouting
            };

            // Create the sign here tab (signing field on the document)
            SignHere signHereTab = new SignHere
            {
                DocumentId  = docId,
                PageNumber  = "1",
                RecipientId = pageInfo.signerId,
                TabLabel    = "Sign Here Tab",
                XPosition   = "195",
                YPosition   = "147"
            };

            SignHere[] signHereTabs = new SignHere[] { signHereTab };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                SignHereTabs = new List <SignHere>(signHereTabs)
            };
            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipients = new Recipients {
                Signers = new List <Signer>(signers)
            };
            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = "Please sign the document",
                Documents    = new List <Document>(documents),
                Recipients   = recipients,
                Status       = "sent"
            };

            // 2. Use the SDK to create and send the envelope
            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + pageInfo.accessToken);
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient.Configuration);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            // 3. Create Envelope Recipient View request obj
            string envelopeId = results.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl, ClientUserId = pageInfo.signerId,
                AuthenticationMethod = "none",
                UserName             = pageInfo.signerName, Email = pageInfo.signerEmail
            };

            // 4. Use the SDK to obtain a Recipient View URL
            ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, envelopeId, viewOptions);

            // 5. Redirect the user's browser to the URL
            return(Redirect(viewUrl.Url));
        }
        public static void Execute()
        {
            // Enter your DocuSign credentials
            string Username = "******";
            string Password = "******";
            string IntegratorKey = "[INTEGRATOR_KEY]";

            // specify the document we want signed
            string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]";

            // Enter recipient (signer) name and email address
            string recipientName = "[SIGNER_NAME]";
            string recipientEmail = "[SIGNER_EMAIL]";

            // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
            string basePath = "https://demo.docusign.net/restapi";

            // instantiate a new api client
            ApiClient apiClient = new ApiClient(basePath);

            // set client in global config so we don't need to pass it to each API object
            Configuration.Default.ApiClient = apiClient;

            string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

            // we will retrieve this from the login() results
            string accountId = null;

            // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object
            AuthenticationApi authApi = new AuthenticationApi();
            LoginInformation loginInfo = authApi.Login();

            // user might be a member of multiple accounts
            accountId = loginInfo.LoginAccounts[0].AccountId;

            Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());

            // Read a file from disk to use as a document
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // Add a document to the envelope
            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";

            envDef.Documents = new List<Document>();
            envDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.Name = recipientName;
            signer.Email = recipientEmail;
            signer.RecipientId = "1";

            // must set |clientUserId| to embed the recipient
            signer.ClientUserId = "1234";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            SignHere signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "100";
            signHere.YPosition = "150";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // Use the EnvelopesApi to create and send the signature request
            EnvelopesApi envelopesApi = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl = "https://www.docusign.com/devcenter",
                ClientUserId = "1234",  // must match clientUserId set in step #2!
                AuthenticationMethod = "email",
                UserName = recipientName,
                Email = recipientEmail
            };

            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(accountId, envelopeSummary.EnvelopeId, viewOptions);

            // print the JSON response
            Console.WriteLine("ViewUrl:\n{0}", JsonConvert.SerializeObject(recipientView));

            // Start the embedded signing session!
            System.Diagnostics.Process.Start(recipientView.Url);
        }
Beispiel #32
0
    protected void createEnvelope()
    {
        // Set up the envelope
        CreateEnvelopeRequest createEnvelopeRequest = new CreateEnvelopeRequest();

        createEnvelopeRequest.emailSubject = "Template Example";
        createEnvelopeRequest.status       = "sent";
        createEnvelopeRequest.emailBlurb   = "Example of how template functionality works";

        // Define first signer
        Signer signer = new Signer();

        signer.email        = email.Value;
        signer.name         = firstname.Value + " " + lastname.Value;
        signer.recipientId  = 1;
        signer.routingOrder = "1";
        signer.roleName     = "Signer1";
        signer.clientUserId = RandomizeClientUserID();  // First signer is embedded

        // Add tabs for the signer
        signer.tabs = new Tabs();
        signer.tabs.signHereTabs = new List <SignHereTab>();
        SignHereTab signHereTab = new SignHereTab();

        signHereTab.documentId   = "1";
        signHereTab.tabId        = "1";
        signHereTab.anchorString = tab1AnchorText.Value;
        signHereTab.name         = tabName.Value;
        signer.tabs.signHereTabs.Add(signHereTab);

        signer.tabs.dateSignedTabs = new List <DateSignedTab>();
        DateSignedTab dateSignedTab = new DateSignedTab();

        dateSignedTab.documentId   = "1";
        dateSignedTab.tabId        = "2";
        dateSignedTab.anchorString = tab2AnchorText.Value;
        dateSignedTab.name         = tab2Name.Value;
        signer.tabs.dateSignedTabs.Add(dateSignedTab);

        // Define a document
        Document document = new Document();

        document.documentId         = "1";
        document.name               = "Sample Form";
        document.transformPdfFields = "true";

        // Define an inline template
        InlineTemplate inline1 = new InlineTemplate();

        inline1.sequence           = "2";
        inline1.recipients         = new Recipients();
        inline1.recipients.signers = new List <Signer>();
        inline1.recipients.signers.Add(signer);


        // Add the inline template to a CompositeTemplate
        CompositeTemplate compositeTemplate1 = new CompositeTemplate();

        compositeTemplate1.inlineTemplates = new List <InlineTemplate>();
        compositeTemplate1.inlineTemplates.Add(inline1);
        compositeTemplate1.document = document;

        // Add compositeTemplate to the envelope
        createEnvelopeRequest.compositeTemplates = new List <CompositeTemplate>();
        createEnvelopeRequest.compositeTemplates.Add(compositeTemplate1);


        string output = JsonConvert.SerializeObject(createEnvelopeRequest);

        // Specify a unique boundary string that doesn't appear in the json or document bytes.
        string Boundary = "MY_BOUNDARY";

        // Set the URI
        HttpWebRequest request = HttpWebRequest.Create(ConfigurationManager.AppSettings["DocuSignServer"] + "/restapi/v2/accounts/" + ConfigurationManager.AppSettings["API.TemplatesAccountID"] + "/envelopes") as HttpWebRequest;

        // Set the method
        request.Method = "POST";

        // Set the authentication header
        request.Headers["X-DocuSign-Authentication"] = GetSecurityHeader();

        // Set the overall request content type aand boundary string
        request.ContentType = "multipart/form-data; boundary=" + Boundary;
        request.Accept      = "application/json";

        // Start forming the body of the request
        Stream reqStream = request.GetRequestStream();

        // write boundary marker between parts
        WriteStream(reqStream, "\n--" + Boundary + "\n");

        // write out the json envelope definition part
        WriteStream(reqStream, "Content-Type: application/json\n");
        WriteStream(reqStream, "Content-Disposition: form-data\n");
        WriteStream(reqStream, "\n"); // requires an empty line between the header and the json body
        WriteStream(reqStream, output);

        // write out the form bytes for the first form
        WriteStream(reqStream, "\n--" + Boundary + "\n");
        WriteStream(reqStream, "Content-Type: application/pdf\n");
        WriteStream(reqStream, "Content-Disposition: file; filename=\"Sample_Form\"; documentId=1\n");
        WriteStream(reqStream, "\n");
        String filename = uploadFile.Value;

        if (File.Exists(Server.MapPath("~/App_Data/" + filename)))
        {
            // Read the file contents and write them to the request stream
            byte[] buf = new byte[4096];
            int    len;
            // read contents of document into the request stream
            FileStream fileStream = File.OpenRead(Server.MapPath("~/App_Data/" + filename));
            while ((len = fileStream.Read(buf, 0, 4096)) > 0)
            {
                reqStream.Write(buf, 0, len);
            }
            fileStream.Close();
        }


        // wrte the end boundary marker - ensure that it is on its own line
        WriteStream(reqStream, "\n--" + Boundary + "--");
        WriteStream(reqStream, "\n");

        try
        {
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                byte[] responseBytes = new byte[response.ContentLength];
                using (var reader = new System.IO.BinaryReader(response.GetResponseStream()))
                {
                    reader.Read(responseBytes, 0, responseBytes.Length);
                }
                string responseText = Encoding.UTF8.GetString(responseBytes);
                CreateEnvelopeResponse createEnvelopeResponse = new CreateEnvelopeResponse();

                createEnvelopeResponse = JsonConvert.DeserializeObject <CreateEnvelopeResponse>(responseText);
                if (createEnvelopeResponse.status.Equals("sent"))
                {
                    // Now that we have created the envelope, get the recipient token for the first signer
                    String url = Request.Url.AbsoluteUri;
                    RecipientViewRequest recipientViewRequest = new RecipientViewRequest();
                    recipientViewRequest.authenticationMethod = "email";
                    recipientViewRequest.clientUserId         = signer.clientUserId;
                    recipientViewRequest.email = email.Value;
                    if (!Request.Browser.IsMobileDevice)
                    {
                        recipientViewRequest.returnUrl = url.Substring(0, url.LastIndexOf("/")) + "/EmbeddedSigningComplete0.aspx?envelopeID=" + createEnvelopeResponse.envelopeId;
                    }
                    else
                    {
                        recipientViewRequest.returnUrl = url.Substring(0, url.LastIndexOf("/")) + "/ConfirmationPage.aspx?envelopeID=" + createEnvelopeResponse.envelopeId;
                    }
                    recipientViewRequest.userName = firstname.Value + " " + lastname.Value;

                    HttpWebRequest request2 = HttpWebRequest.Create(ConfigurationManager.AppSettings["DocuSignServer"] + "/restapi/v2/accounts/" + ConfigurationManager.AppSettings["API.TemplatesAccountID"] + "/envelopes/" + createEnvelopeResponse.envelopeId + "/views/recipient") as HttpWebRequest;
                    request2.Method = "POST";

                    // Set the authenticationheader
                    request2.Headers["X-DocuSign-Authentication"] = GetSecurityHeader();

                    request2.Accept      = "application/json";
                    request2.ContentType = "application/json";

                    Stream reqStream2 = request2.GetRequestStream();

                    WriteStream(reqStream2, JsonConvert.SerializeObject(recipientViewRequest));
                    HttpWebResponse response2 = request2.GetResponse() as HttpWebResponse;

                    responseBytes = new byte[response2.ContentLength];
                    using (var reader = new System.IO.BinaryReader(response2.GetResponseStream()))
                    {
                        reader.Read(responseBytes, 0, responseBytes.Length);
                    }
                    string response2Text = Encoding.UTF8.GetString(responseBytes);

                    RecipientViewResponse recipientViewResponse = new RecipientViewResponse();
                    recipientViewResponse = JsonConvert.DeserializeObject <RecipientViewResponse>(response2Text);
                    Session.Add("envelopeID", createEnvelopeResponse.envelopeId);

                    // If it's a non-touch aware device, show the signing session in an iFrame
                    if (!Request.Browser.IsMobileDevice)
                    {
                        if (!Request.Browser.Browser.Equals("InternetExplorer") && (!Request.Browser.Browser.Equals("Safari")))
                        {
                            docusignFrame.Visible = true;
                            docusignFrame.Src     = recipientViewResponse.url;
                        }
                        else // Handle IE differently since it does not allow dynamic setting of the iFrame width and height
                        {
                            docusignFrameIE.Visible = true;
                            docusignFrameIE.Src     = recipientViewResponse.url;
                        }
                    }
                    // For touch aware devices, show the signing session in main browser window
                    else
                    {
                        Response.Redirect(recipientViewResponse.url);
                    }
                }
            }
        }
        catch (WebException ex)
        {
            if (ex.Status == WebExceptionStatus.ProtocolError)
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                using (var reader = new System.IO.StreamReader(ex.Response.GetResponseStream(), UTF8Encoding.UTF8))
                {
                    string       errorMess = reader.ReadToEnd();
                    log4net.ILog logger    = log4net.LogManager.GetLogger(typeof(demos_AnchorTextREST));
                    logger.Info("\n----------------------------------------\n");
                    logger.Error("DocuSign Error: " + errorMess);
                    logger.Error(ex.StackTrace);
                    Response.Write(ex.Message);
                }
            }
            else
            {
                log4net.ILog logger = log4net.LogManager.GetLogger(typeof(demos_AnchorTextREST));
                logger.Info("\n----------------------------------------\n");
                logger.Error("WebRequest Error: " + ex.Message);
                logger.Error(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
    }
Beispiel #33
0
        public IActionResult Create(string signerEmail, string signerName, string ccEmail, string ccName)
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be
                // restarted automatically. But since it should be rare to have a token issue
                // here, we'll make the user re-enter the form data after authentication
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            // The envelope will be sent first to the signer; after it is signed,
            // a copy is sent to the cc person
            //
            // Read files from a local directory
            // The reads could raise an exception if the file is not available!
            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            // Step 3: Create Tabs and CustomFields
            // Set the values for the fields in the template
            // List item
            List colorPicker = new List
            {
                Value      = "green",
                DocumentId = "1",
                PageNumber = "1",
                TabLabel   = "list"
            };

            // Checkboxes
            Checkbox ckAuthorization = new Checkbox
            {
                TabLabel = "ckAuthorization",
                Selected = "true"
            };
            Checkbox ckAgreement = new Checkbox
            {
                TabLabel = "ckAgreement",
                Selected = "true"
            };

            RadioGroup radioGroup = new RadioGroup
            {
                GroupName = "radio1",
                // You only need to provide the readio entry for the entry you're selecting
                Radios = new List <Radio> {
                    new Radio {
                        Value = "white", Selected = "true"
                    }
                }
            };

            Text includedOnTemplate = new Text
            {
                TabLabel = "text",
                Value    = "Jabberywocky!"
            };

            // We can also add a new tab (field) to the ones already in the template
            Text addedField = new Text
            {
                DocumentId = "1",
                PageNumber = "1",
                XPosition  = "280",
                YPosition  = "172",
                Font       = "helvetica",
                FontSize   = "size14",
                TabLabel   = "added text field",
                Height     = "23",
                Width      = "84",
                Required   = "false",
                Bold       = "true",
                Value      = signerName,
                Locked     = "false",
                TabId      = "name"
            };

            // Add the tabs model (including the SignHere tab) to the signer.
            // The Tabs object wants arrays of the different field/tab types
            // Tabs are set per recipient/signer
            Tabs tabs = new Tabs
            {
                CheckboxTabs = new List <Checkbox> {
                    ckAuthorization, ckAgreement
                },
                RadioGroupTabs = new List <RadioGroup> {
                    radioGroup
                },
                TextTabs = new List <Text> {
                    includedOnTemplate, addedField
                },
                ListTabs = new List <List> {
                    colorPicker
                }
            };

            // Create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            TemplateRole signer = new TemplateRole
            {
                Email        = signerEmail,
                Name         = signerName,
                RoleName     = "signer",
                ClientUserId = signerClientId, // Change the signer to be embedded
                Tabs         = tabs            //Set tab values
            };

            TemplateRole cc = new TemplateRole
            {
                Email    = ccEmail,
                Name     = ccName,
                RoleName = "cc"
            };

            // Create an envelope custom field to save our application's
            // data about the envelope
            TextCustomField customField = new TextCustomField
            {
                Name     = "app metadata item",
                Required = "false",
                Show     = "true", // Yes, include in the CoC
                Value    = "1234567"
            };

            CustomFields cf = new CustomFields
            {
                TextCustomFields = new List <TextCustomField> {
                    customField
                }
            };

            // Step 4: Create the envelope definition
            EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition
            {
                // Uses the template ID received from example 08
                TemplateId = RequestItemsService.TemplateId,
                Status     = "Sent",
                // Add the TemplateRole objects to utilize a pre-defined
                // document and signing/routing order on an envelope.
                // Template role names need to match what is available on
                // the correlated templateID or else an error will occur
                TemplateRoles = new List <TemplateRole> {
                    signer, cc
                },
                CustomFields = cf
            };

            // Step 5: Call the eSignature REST API
            var             envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeAttributes);

            // Step 6: Create the View Request
            RequestItemsService.EnvelopeId = results.EnvelopeId;
            RecipientViewRequest viewRequest = new RecipientViewRequest();

            // Set the URL where you want the recipient to go once they are done signing;
            // this should typically be a callback route somewhere in your app.
            // The query parameter is included as an example of how
            // to save/recover state information during the redirect to
            // the DocuSign signing ceremony. It's usually better to use
            // the session mechanism of your web framework. Query parameters
            // can be changed/spoofed very easily
            viewRequest.ReturnUrl = dsReturnUrl + "?state=123";

            // How has your app authenticated the user? In addition to your app's authentication,
            // you can include authentication steps from DocuSign; e.g., SMS authentication
            viewRequest.AuthenticationMethod = "none";

            // Recipient information must match the embedded recipient info
            // that we used to create the envelope
            viewRequest.Email        = signerEmail;
            viewRequest.UserName     = signerName;
            viewRequest.ClientUserId = signerClientId;

            // DocuSign recommends that you redirect to DocuSign for the
            // signing ceremony. There are multiple ways to save state.
            // To maintain your application's session, use the PingUrl
            // parameter. It causes the DocuSign Signing Ceremony web page
            // (not the DocuSign server) to send pings via AJAX to your app
            viewRequest.PingFrequency = "600"; // seconds
                                               // NOTE: The pings will only be sent if the pingUrl is an HTTPS address
            viewRequest.PingUrl = dsPingUrl;   // Optional setting

            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, results.EnvelopeId, viewRequest);
            //***********
            // Don't use an iframe with embedded signing requests!
            //***********
            // State can be stored/recovered using the framework's session or a
            // query parameter on the return URL (see the makeRecipientViewRequest method)
            string redirectUrl = results1.Url;

            return(Redirect(redirectUrl));
        }
Beispiel #34
0
    protected void createEnvelopeResponsive()
    {
        // Set up the envelope
        CreateEnvelopeRequest createEnvelopeRequest = new CreateEnvelopeRequest();

        createEnvelopeRequest.emailSubject = "Business Credit Card Approval";
        createEnvelopeRequest.status       = "sent";
        createEnvelopeRequest.emailBlurb   = "Please review & DocuSign your business credit cards approval";

        // Define first signer
        Signer signer = new Signer();

        signer.email        = Email.Value;
        signer.name         = firstName.Value + ' ' + lastName.Value;
        signer.recipientId  = 1;
        signer.routingOrder = "1";
        signer.roleName     = "signer";
        signer.clientUserId = RandomizeClientUserID();


        //// Add tabs for the signer
        signer.tabs = new Tabs();
        signer.tabs.dateSignedTabs = new List <DateSignedTab>();
        DateSignedTab dateSignedTab = new DateSignedTab();

        dateSignedTab.documentId  = "1";
        dateSignedTab.pageNumber  = "1";
        dateSignedTab.font        = "arial";
        dateSignedTab.fontSize    = "size12";
        dateSignedTab.fontColor   = "black";
        dateSignedTab.recipientId = "1";
        dateSignedTab.tabLabel    = "clientDateSigned";
        signer.tabs.dateSignedTabs.Add(dateSignedTab);


        signer.tabs.signHereTabs = new List <SignHereTab>();
        SignHereTab signHereTab = new SignHereTab();

        signHereTab.stampType   = "signature";
        signHereTab.name        = "SignHere";
        signHereTab.tabLabel    = "clientSignature";
        signHereTab.scaleValue  = "1";
        signHereTab.optional    = "false";
        signHereTab.recipientId = "1";
        signer.tabs.signHereTabs.Add(signHereTab);

        signer.tabs.textTabs = new List <TextTab>();
        TextTab texttab2 = new TextTab();

        texttab2.isPaymentAmount              = "false";
        texttab2.validationMessage            = "";
        texttab2.validationPattern            = "";
        texttab2.shared                       = "false";
        texttab2.requireInitialOnSharedChange = "false";
        texttab2.requireAll                   = "false";
        texttab2.value    = firstName.Value + " " + lastName.Value + "/" + title.Value;
        texttab2.required = "true";
        texttab2.locked   = "true";
        texttab2.concealValueOnDocument = "false";
        texttab2.disableAutoSize        = "false";
        texttab2.maxLength   = "4000";
        texttab2.tabLabel    = "Approver";
        texttab2.font        = "arial";
        texttab2.bold        = "false";
        texttab2.italic      = "false";
        texttab2.underline   = "false";
        texttab2.fontColor   = "black";
        texttab2.fontSize    = "size12";
        texttab2.documentId  = "1";
        texttab2.recipientId = "1";
        texttab2.width       = "100";
        texttab2.height      = "11";
        signer.tabs.textTabs.Add(texttab2);

        TextTab texttab3 = new TextTab();

        texttab3.isPaymentAmount              = "false";
        texttab3.validationMessage            = "";
        texttab3.validationPattern            = "";
        texttab3.shared                       = "false";
        texttab3.requireInitialOnSharedChange = "false";
        texttab3.requireAll                   = "false";
        texttab3.value    = businessName.Value;
        texttab3.required = "true";
        texttab3.locked   = "true";
        texttab3.concealValueOnDocument = "false";
        texttab3.disableAutoSize        = "false";
        texttab3.maxLength   = "4000";
        texttab3.tabLabel    = "BusinessName";
        texttab3.font        = "arial";
        texttab3.bold        = "false";
        texttab3.italic      = "false";
        texttab3.underline   = "false";
        texttab3.fontColor   = "black";
        texttab3.fontSize    = "size12";
        texttab3.documentId  = "1";
        texttab3.recipientId = "1";
        texttab3.width       = "60";
        texttab3.height      = "11";
        signer.tabs.textTabs.Add(texttab3);



        createEnvelopeRequest.recipients = new Recipients();

        createEnvelopeRequest.recipients.signers = new List <Signer>();
        createEnvelopeRequest.recipients.signers.Add(signer);

        // Define a document
        Document document = new Document();

        document.documentId     = "1";
        document.name           = "Business Credit Card Approval";
        document.htmlDefinition = new HtmlDefinition();
        // Read in the HTML file
        document.htmlDefinition.source = File.ReadAllText(Server.MapPath("~/App_Data/") + "digbankingdemo.html");

        // Define display anchors
        document.htmlDefinition.displayAnchors = new List <DisplayAnchor>();
        DisplayAnchor displayAnchor = new DisplayAnchor();

        displayAnchor.startAnchor                = "responsive_table_start";
        displayAnchor.endAnchor                  = "responsive_table_end";
        displayAnchor.removeEndAnchor            = true;
        displayAnchor.removeStartAnchor          = true;
        displayAnchor.caseSensitive              = true;
        displayAnchor.displaySettings            = new DisplaySettings();
        displayAnchor.displaySettings.display    = "responsive_table_single_column";
        displayAnchor.displaySettings.tableStyle = "margin-bottom: 20px;width:100%;max-width:816px;margin-left:auto;margin-right:auto;";
        displayAnchor.displaySettings.cellStyle  = "text-align:left;border:solid 0px #000;margin:0px;padding:0px;";
        document.htmlDefinition.displayAnchors.Add(displayAnchor);

        createEnvelopeRequest.documents = new List <Document>();
        createEnvelopeRequest.documents.Add(document);
        createEnvelopeRequest.brandId = ConfigurationManager.AppSettings["MomentumBrandID"];



        // Set up Connect
        createEnvelopeRequest.eventNotification = getConnectSetup();


        string output = JsonConvert.SerializeObject(createEnvelopeRequest);

        // Set the URI
        HttpWebRequest request = HttpWebRequest.Create(ConfigurationManager.AppSettings["DocuSignServer"] + "/restapi/vdev/accounts/" + ConfigurationManager.AppSettings["API.AccountId"] + "/envelopes") as HttpWebRequest;

        // Set the method
        request.Method = "POST";

        // Set the authentication header
        request.Headers["X-DocuSign-Authentication"] = GetSecurityHeader();

        // Set the overall request content type aand boundary string
        request.ContentType = "application/json";
        request.Accept      = "application/json";

        // Start forming the body of the request
        Stream reqStream = request.GetRequestStream();


        WriteStream(reqStream, "\n"); // requires an empty line between the header and the json body
        WriteStream(reqStream, output);



        try
        {
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

            if (response.StatusCode == HttpStatusCode.Created)
            {
                byte[] responseBytes = new byte[response.ContentLength];
                using (var reader = new System.IO.BinaryReader(response.GetResponseStream()))
                {
                    reader.Read(responseBytes, 0, responseBytes.Length);
                }
                string responseText = Encoding.UTF8.GetString(responseBytes);
                CreateEnvelopeResponse createEnvelopeResponse = new CreateEnvelopeResponse();

                createEnvelopeResponse = JsonConvert.DeserializeObject <CreateEnvelopeResponse>(responseText);
                if (createEnvelopeResponse.status.Equals("sent"))
                {
                    // Now that we have created the envelope, get the recipient token for the first signer
                    String url = Request.Url.AbsoluteUri;
                    RecipientViewRequest recipientViewRequest = new RecipientViewRequest();
                    recipientViewRequest.authenticationMethod = "email";
                    recipientViewRequest.clientUserId         = signer.clientUserId;
                    recipientViewRequest.email     = Email.Value;
                    recipientViewRequest.returnUrl = url.Substring(0, url.LastIndexOf("/")) + "/ConfirmationScreen.aspx";
                    recipientViewRequest.userName  = firstName.Value + " " + lastName.Value;

                    HttpWebRequest request2 = HttpWebRequest.Create(ConfigurationManager.AppSettings["DocuSignServer"] + "/restapi/v2/accounts/" + ConfigurationManager.AppSettings["API.TemplatesAccountID"] + "/envelopes/" + createEnvelopeResponse.envelopeId + "/views/recipient") as HttpWebRequest;
                    request2.Method = "POST";

                    // Set the authenticationheader
                    request2.Headers["X-DocuSign-Authentication"] = GetSecurityHeader();

                    request2.Accept      = "application/json";
                    request2.ContentType = "application/json";

                    Stream reqStream2 = request2.GetRequestStream();

                    WriteStream(reqStream2, JsonConvert.SerializeObject(recipientViewRequest));
                    HttpWebResponse response2 = request2.GetResponse() as HttpWebResponse;

                    responseBytes = new byte[response2.ContentLength];
                    using (var reader = new System.IO.BinaryReader(response2.GetResponseStream()))
                    {
                        reader.Read(responseBytes, 0, responseBytes.Length);
                    }
                    string response2Text = Encoding.UTF8.GetString(responseBytes);

                    RecipientViewResponse recipientViewResponse = new RecipientViewResponse();
                    recipientViewResponse = JsonConvert.DeserializeObject <RecipientViewResponse>(response2Text);
                    Session.Add("envelopeID", createEnvelopeResponse.envelopeId);

                    Response.Redirect(recipientViewResponse.url);
                }
            }
        }
        catch (WebException ex)
        {
            if (ex.Status == WebExceptionStatus.ProtocolError)
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                using (var reader = new System.IO.StreamReader(ex.Response.GetResponseStream(), UTF8Encoding.UTF8))
                {
                    string       errorMess = reader.ReadToEnd();
                    log4net.ILog logger    = log4net.LogManager.GetLogger(typeof(BusinessCCApproval));
                    logger.Info("\n----------------------------------------\n");
                    logger.Error("DocuSign Error: " + errorMess);
                    logger.Error(ex.StackTrace);
                    Response.Write(ex.Message);
                }
            }
            else
            {
                log4net.ILog logger = log4net.LogManager.GetLogger(typeof(BusinessCCApproval));
                logger.Info("\n----------------------------------------\n");
                logger.Error("WebRequest Error: " + ex.Message);
                logger.Error(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
    }
        public void EmbeddedSigningTest()
        {
            try
            {
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();
                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                envDef.Status = "sent";
                envDef.EmailSubject = "Please Sign my C# SDK Envelope";
                string clientUserId = "1234";
                envDef.Recipients.Signers[0].ClientUserId = clientUserId;

                EnvelopesApi envelopesApi = new EnvelopesApi();

                EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(envelopeSummary);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(envelopeSummary.EnvelopeId));

                // get a URL that can be placed in a browser or embedded in an IFrame
                string returnUrl = TestConfig.DefaultReturnUrl;
                RecipientViewRequest recipientView = new RecipientViewRequest()
                {
                    ReturnUrl = returnUrl,
                    ClientUserId = clientUserId,
                    AuthenticationMethod = "email",
                    UserName = envDef.Recipients.Signers[0].Name,
                    Email = envDef.Recipients.Signers[0].Email
                };

                ViewUrl viewUrl = envelopesApi.CreateRecipientView(TestConfig.AccountId, envelopeSummary.EnvelopeId, recipientView);
                Assert.IsNotNull(viewUrl);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(viewUrl.Url));
                Trace.WriteLine("ViewUrl is " + viewUrl);

                /// Start a browser to Sign
                System.Diagnostics.Process.Start(viewUrl.Url);
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }