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);
        }
        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);
        }
        /// <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);
        }
Exemple #4
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);
        }
        public void CreateCorrectViewTest()
        {
            try
            {
                // Create Envelope
                CreateEnvelopeTest();
                Assert.IsNotNull(TestConfig.EnvelopeId);

                // Start the embedded sending session
                ReturnUrlRequest urlRequest = new ReturnUrlRequest();
                urlRequest.ReturnUrl = TestConfig.DefaultReturnUrl;

                // Adding the envelopeId start sthe console with the envelope open
                CorrectViewRequest correctViewRequest = new CorrectViewRequest();
                correctViewRequest.ReturnUrl = TestConfig.DefaultReturnUrl;

                EnvelopesApi envelopesApi = new EnvelopesApi();
                ViewUrl      viewUrl      = envelopesApi.CreateCorrectView(TestConfig.AccountId, TestConfig.EnvelopeId, correctViewRequest);

                // Start the embedded signing session.
                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);
            }
        }
        /// <summary>
        /// Create an envelope and then create an embedded sending view for that envelope
        /// </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="docPdf">String of bytes representing the document (pdf)</param>
        /// <param name="docDocx">String of bytes representing the Word document (docx)</param>
        /// <param name="startingView">The sending view to show initially (either "tagging" or "recipient")</param>
        /// <param name="returnUrl">URL user will be redirected to after they sign</param>
        /// <returns>URL to embed in your application</returns>
        public static string SendEnvelopeUsingEmbeddedSending(string signerEmail, string signerName, string ccEmail, string ccName, string docDocx, string docPdf, string accessToken, string basePath, string accountId, string startingView, string returnUrl)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);

            // Step 1. Make the envelope with "created" (draft) status
            EnvelopeDefinition env        = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, docDocx, docPdf, "created");
            EnvelopeSummary    results    = envelopesApi.CreateEnvelope(accountId, env);
            string             envelopeId = results.EnvelopeId;

            // Step 2. create the sender view
            // Call the CreateSenderView API
            // Exceptions will be caught by the calling function
            ReturnUrlRequest viewRequest = new ReturnUrlRequest
            {
                ReturnUrl = returnUrl
            };
            ViewUrl result1 = envelopesApi.CreateSenderView(accountId, envelopeId, viewRequest);
            // Switch to Recipient and Documents view if requested by the user
            String redirectUrl = result1.Url;

            Console.WriteLine("startingView: " + startingView);
            if ("recipient".Equals(startingView))
            {
                redirectUrl = redirectUrl.Replace("send=1", "send=0");
            }
            return(redirectUrl);
        }
Exemple #7
0
        } // end createEmbeddedSigningViewTest()

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ViewUrl createEmbeddedConsoleViewTest()
        {
            // Enter your DocuSign credentials below.  Note: You only need a DocuSign account to SEND documents,
            // signing is always free and signers do not need an account.
            string username = "******";
            string password = "******";

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

            //===========================================================
            // Step 1: Login()
            //===========================================================

            // call the Login() API which sets the user's baseUrl and returns their accountId
            string accountId = loginApi(username, password);

            //===========================================================
            // Step 2: Create Embedded Console View (URL)
            //===========================================================

            ReturnUrlRequest urlRequest = new ReturnUrlRequest();

            urlRequest.ReturnUrl = "https://www.docusign.com/devcenter";

            // Adding the envelopeId start sthe console with the envelope open
            EnvelopesApi envelopesApi = new EnvelopesApi();
            ViewUrl      viewUrl      = envelopesApi.CreateConsoleView(accountId, null);

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

            return(viewUrl);
        } // end createEmbeddedConsoleViewTest()
        // ***DS.snippet.0.start
        private string DoWork(string accessToken, string basePath,
                              string accountId, string startingView, string dsReturnUrl, string envelopeId)
        {
            // Data for this method
            // startingView
            // accessToken
            // basePath
            // accountId
            // dsReturnUrl
            // envelopeId
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi       envelopesApi = new EnvelopesApi(config);
            ConsoleViewRequest viewRequest  = MakeConsoleViewRequest(dsReturnUrl,
                                                                     startingView, envelopeId);

            // Step 1. create the NDSE view
            // Call the CreateSenderView API
            // Exceptions will be caught by the calling function
            ViewUrl results     = envelopesApi.CreateConsoleView(accountId, viewRequest);
            string  redirectUrl = results.Url;

            return(redirectUrl);
        }
Exemple #9
0
        public CreateEnvelopeResponse CreateEnvelope(
            DocumentType type,
            string accountId,
            string userId,
            LoginType loginType,
            UserDetails additionalUser,
            string redirectUrl,
            string pingAction)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException(nameof(accountId));
            }
            if (userId == null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            string      rootDir     = _configuration.GetValue <string>(WebHostDefaults.ContentRootKey);
            UserDetails userDetails = _userService.GetUserDetails(accountId, userId, loginType);

            var templateHandler = GetTemplateHandler(type);
            EnvelopeTemplate   envelopeTemplate = templateHandler.BuildTemplate(rootDir);
            EnvelopeDefinition envelope         = templateHandler.BuildEnvelope(userDetails, additionalUser);

            if (type == DocumentType.I9 && loginType == LoginType.JWT)
            {
                EnableIDV(accountId, envelopeTemplate, "New Hire");
            }

            var listTemplates         = _docuSignApiProvider.TemplatesApi.ListTemplates(accountId);
            EnvelopeTemplate template = listTemplates?.EnvelopeTemplates?.FirstOrDefault(x => x.Name == templateHandler.TemplateName);

            if (template != null)
            {
                envelope.TemplateId = template.TemplateId;
            }
            else
            {
                TemplateSummary templateSummary = _docuSignApiProvider.TemplatesApi.CreateTemplate(accountId, envelopeTemplate);
                envelope.TemplateId = templateSummary.TemplateId;
            }
            EnvelopeSummary envelopeSummary = _docuSignApiProvider.EnvelopApi.CreateEnvelope(accountId, envelope);

            if (type != DocumentType.I9)
            {
                ViewUrl recipientView = _docuSignApiProvider.EnvelopApi.CreateRecipientView(
                    accountId,
                    envelopeSummary.EnvelopeId,
                    BuildRecipientViewRequest(
                        userDetails.Email,
                        userDetails.Name,
                        redirectUrl,
                        pingAction)
                    );
                return(new CreateEnvelopeResponse(recipientView.Url, envelopeSummary.EnvelopeId));
            }

            return(new CreateEnvelopeResponse(string.Empty, envelopeSummary.EnvelopeId));
        }
Exemple #10
0
        } // end createEmbeddedSigningViewTest()

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public ViewUrl createEmbeddedConsoleViewTest()
        {
            // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi)
            configureApiClient(BASE_URL);

            //===========================================================
            // Step 1:JWT Login()
            //===========================================================

            // call the JWT Configure and UserInfo API which sets the user's baseUrl and returns their accountId
            string accountId = JWTAuthLogin();

            //===========================================================
            // Step 2: Create Embedded Console View (URL)
            //===========================================================

            ReturnUrlRequest urlRequest = new ReturnUrlRequest();

            urlRequest.ReturnUrl = "https://www.docusign.com/devcenter";

            // Adding the envelopeId start sthe console with the envelope open
            EnvelopesApi envelopesApi = new EnvelopesApi();
            ViewUrl      viewUrl      = envelopesApi.CreateConsoleView(accountId, null);

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

            return(viewUrl);
        } // end createEmbeddedConsoleViewTest()
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>Loads service the root directories for file system and web access.</summary>
        protected void GetRootDirectories()
        {
            if (fileRootDir != null || relativeUrl != null)
            {
                return;
            }
            if (RootDirectory != null)
            {
                if (RootDirectory.StartsWith("$(SERVICEROOT)"))
                {
                    fileRootDir = (RootDirectory.Replace("$(SERVICEROOT)", context.ServiceFileRoot)).Replace('/', System.IO.Path.DirectorySeparatorChar);
                    relativeUrl = RootDirectory.Replace("$(SERVICEROOT)", context.ServiceWebRoot);
                }
                else
                {
                    fileRootDir = (context.SiteRootFolder + "/" + RootDirectory).Replace('/', System.IO.Path.DirectorySeparatorChar);
                    relativeUrl = RootDirectory;
                }
                relativeUrl = Regex.Replace(relativeUrl, "/+$", String.Empty);
            }
            if (IconUrl != null)
            {
                IconUrl = IconUrl.Replace("$(SERVICEROOT)", context.ServiceWebRoot);
            }
            if (ViewUrl != null)
            {
                ViewUrl = ViewUrl.Replace("$(SERVICEROOT)", context.ServiceWebRoot);
            }
        }
Exemple #12
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);
        }
Exemple #14
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());
        }
 public void SetUp()
 {
     _viewUrl        = new ViewUrl("http://valid/XmlStatusReport.aspx");
     _configSettings = new ConfigSettings {
         URL = _viewUrl.Url
     };
     _transformer = new BuildDataTransformer(_configSettings);
 }
        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 = "";
            }
        }
        public void CreateSenderView_CorrectInputParameters_ReturnViewUrl()
        {
            var envelopeStatusCreated = "created";

            CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(ref _testConfig, envelopeStatusCreated);

            var options = new ReturnUrlRequest
            {
                ReturnUrl = _testConfig.ReturnUrl
            };

            ViewUrl senderView = _envelopesApi.CreateSenderView(_testConfig.AccountId, _testConfig.EnvelopeId, options);

            Assert.IsNotNull(senderView?.Url);
        }
Exemple #18
0
        public ViewUrl EmbeddedConsoleView(String accountId)
        {
            ReturnUrlRequest urlRequest = new ReturnUrlRequest();

            urlRequest.ReturnUrl = "https://www.docusign.com";

            // Adding the envelopeId start sthe console with the envelope open
            EnvelopesApi envelopesApi = new EnvelopesApi();
            ViewUrl      viewUrl      = envelopesApi.CreateConsoleView(accountId, null);

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

            return(viewUrl);
        }
        public void CreateConsoleView_CorrectInputParameters_ReturnViewUrl()
        {
            CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(
                ref _testConfig);

            var consoleViewRequest = new ConsoleViewRequest
            {
                EnvelopeId = _testConfig.EnvelopeId,
                ReturnUrl  = _testConfig.ReturnUrl
            };

            ViewUrl viewUrl = _envelopesApi.CreateConsoleView(_testConfig.AccountId, consoleViewRequest);

            Assert.IsNotNull(viewUrl?.Url);
        }
Exemple #20
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);
        }
        public void JwtCreateEmbeddedConsoleViewTest()
        {
            JwtRequestSignatureOnDocumentTest();

            // Adding the envelopeId start sthe console with the envelope open
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);

            ConsoleViewRequest consoleViewRequest = new ConsoleViewRequest();

            consoleViewRequest.EnvelopeId = testConfig.EnvelopeId;
            consoleViewRequest.ReturnUrl  = testConfig.ReturnUrl;

            ViewUrl viewUrl = envelopesApi.CreateConsoleView(testConfig.AccountId, consoleViewRequest);

            Assert.IsNotNull(viewUrl);
            Assert.IsNotNull(viewUrl.Url);
        }
        public void JwtCreateEmbeddedSendingViewTest()
        {
            JwtRequestSignatureOnDocumentTest("created");

            ReturnUrlRequest options = new ReturnUrlRequest();

            options.ReturnUrl = testConfig.ReturnUrl;

            // |EnvelopesApi| contains methods related to envelopes and envelope recipients
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);

            // generate the embedded sending URL
            ViewUrl senderView = envelopesApi.CreateSenderView(testConfig.AccountId, testConfig.EnvelopeId, options);

            Assert.IsNotNull(senderView);
            Assert.IsNotNull(senderView.Url);
        }
Exemple #23
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);
        }
Exemple #24
0
        // ***DS.snippet.0.start
        private string DoWork(string signerEmail, string signerName, string ccEmail,
                              string ccName, string accessToken, string basePath,
                              string accountId, string startingView, string dsReturnUrl)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // startingView
            // 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 with "created" (draft) status
            // Using eg002 to create the envelope with "created" status
            RequestItemsService.Status = "created";
            controller2 = new Eg002SigningViaEmailController(Config, RequestItemsService);
            EnvelopeSummary results    = controller2.DoWork(signerEmail, signerName, ccEmail, ccName);
            String          envelopeId = results.EnvelopeId;

            // Step 2. create the sender view
            // Call the CreateSenderView API
            // Exceptions will be caught by the calling function
            ReturnUrlRequest viewRequest = new ReturnUrlRequest
            {
                ReturnUrl = dsReturnUrl
            };
            ViewUrl result1 = envelopesApi.CreateSenderView(accountId, envelopeId, viewRequest);
            // Switch to Recipient and Documents view if requested by the user
            String redirectUrl = result1.Url;

            Console.WriteLine("startingView: " + startingView);
            if ("recipient".Equals(startingView))
            {
                redirectUrl = redirectUrl.Replace("send=1", "send=0");
            }
            return(redirectUrl);
        }
Exemple #25
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);
            }
        }
Exemple #26
0
        /// <summary>
        /// Generates a URL to be use to embedded a view of an envelope in your application
        /// </summary>
        /// <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="startingView">The sending view to show initially (either "tagging" or "recipient")</param>
        /// <param name="returnUrl">Url user will be redirected to after they sign</param>
        /// <param name="envelopeId">The required envelopeId</param>
        /// <returns>URL for the embedded console for this envelope</returns>
        public static string CreateEmbeddedConsoleView(string accessToken, string basePath,
                                                       string accountId, string startingView, string returnUrl, string envelopeId)
        {
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            EnvelopesApi       envelopesApi = new EnvelopesApi(apiClient);
            ConsoleViewRequest viewRequest  = MakeConsoleViewRequest(returnUrl,
                                                                     startingView, envelopeId);

            // Step 1. create the NDSE view
            // Call the CreateSenderView API
            // Exceptions will be caught by the calling function
            ViewUrl results     = envelopesApi.CreateConsoleView(accountId, viewRequest);
            string  redirectUrl = results.Url;

            return(redirectUrl);
        }
        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);
        }
Exemple #28
0
        public IActionResult DocuSign()
        {
            if (s_accountId == "")
            {
                ViewData["Message"] = "You need to sign in before signing documents.";
                return(View("Login"));
            }

            if (s_envelopeId == "")
            {
                ViewData["Message"] = "No Documents to sign";
                return(View("Index"));
            }

            DocuSignDemo.DocuSignDemo demo = new DocuSignDemo.DocuSignDemo();

            SignRequestModel signRequest = new SignRequestModel();

            signRequest.Username       = s_username;
            signRequest.Password       = s_password;
            signRequest.RecipientName  = s_recipientName;
            signRequest.RecipientEmail = s_recipientEmail;
            signRequest.EnvelopeId     = s_envelopeId;
            signRequest.AccountId      = s_accountId;


            ViewUrl recipientView = demo.SignDocument(ref signRequest);

            //Test Working Console Code
            //ViewUrl recipientView = demo.SignDocument(s_envelopeId);
            if (recipientView != null)
            {
                //return recipientView;
                return(Redirect(recipientView.Url));
                //return View();
            }
            else
            {
                ViewData["Message"] = signRequest.Message;
                return(View("Sign"));
            }
        }
        public void LegacyCreateEmbeddedConsoleViewTest()
        {
            LegacyRequestSignatureOnDocumentTest();

            // Adding the envelopeId start sthe console with the envelope open
            EnvelopesApi envelopesApi = new EnvelopesApi(testConfig.ApiClient.Configuration);

            ConsoleViewRequest consoleViewRequest = new ConsoleViewRequest();

            consoleViewRequest.EnvelopeId = testConfig.EnvelopeId;
            consoleViewRequest.ReturnUrl  = testConfig.ReturnUrl;

            ViewUrl viewUrl = envelopesApi.CreateConsoleView(testConfig.AccountId, consoleViewRequest);

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

            Assert.IsNotNull(viewUrl);
            Assert.IsNotNull(viewUrl.Url);
        }
Exemple #30
0
        public ViewUrl EmbeddedSenderView(String accountId, String envelopeId)
        {
            ReturnUrlRequest options = new ReturnUrlRequest();

            options.ReturnUrl = "https://www.docusign.com";

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

            // generate the embedded sending URL
            ViewUrl senderView = envelopesApi.CreateSenderView(accountId, envelopeId, options);

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

            // Start the embedded sending session
            System.Diagnostics.Process.Start(senderView.Url);

            return(senderView);
        }