public void JwtRequestSignatureFromTemplateTest()
        {
            EnvelopeDefinition envDef = new EnvelopeDefinition();

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

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            TemplateRole tRole = new TemplateRole();

            tRole.Email    = testConfig.RecipientEmail;
            tRole.Name     = testConfig.RecipientName;
            tRole.RoleName = testConfig.TemplateRoleName;

            List <TemplateRole> rolesList = new List <TemplateRole>()
            {
                tRole
            };

            // add the role to the envelope and assign valid templateId from your account
            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = testConfig.TemplateId;

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

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

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
        // ***DS.snippet.0.start
        public EnvelopeSummary DoWork(string signerEmail, string signerName, string signerCountryCode, string signerPhoneNumber, string ccEmail, string ccName, string ccCountryCode, string ccPhoneNumber)
        {
            // Data for this method
            // signerEmail
            // signerName
            // signerCountryCode
            // signerPhoneNumber
            // ccEmail
            // ccName
            // ccCountryCode
            // ccPhoneNumber
            var accessToken = RequestItemsService.User.AccessToken;
            var basePath    = RequestItemsService.Session.BasePath + "/restapi";
            var accountId   = RequestItemsService.Session.AccountId;

            EnvelopeDefinition env = MakeEnvelope(signerEmail, signerName, signerCountryCode, signerPhoneNumber, ccEmail, ccName, ccCountryCode, ccPhoneNumber);
            var apiClient          = new ApiClient(basePath);

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

            RequestItemsService.EnvelopeId = results.EnvelopeId;
            return(results);
        }
Пример #3
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 CreateEnvelope_CorrectInputParametersAndTemplateReference_ReturnEnvelopeSummary()
        {
            var envDef = new EnvelopeDefinition
            {
                EmailSubject = "[DocuSign C# SDK] - Please sign this doc"
            };

            var tRole = new TemplateRole
            {
                Email    = _testConfig.RecipientEmail,
                Name     = _testConfig.RecipientName,
                RoleName = _testConfig.TemplateRoleName
            };

            var rolesList = new List <TemplateRole>()
            {
                tRole
            };

            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = _testConfig.TemplateId;

            envDef.Status = "sent";

            EnvelopeSummary envelopeSummary = _envelopesApi.CreateEnvelope(_testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary?.EnvelopeId);

            this._testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
Пример #5
0
        public static void InsertFormAndEnvelopeInfo(Student student, EnvelopeSummary envelopeSumm, int batchRunId)
        {
            string insertProcedure = "dbo.sp_InsertFormAndEnvelopeInfo_Demo";

            using (SqlConnection SQLCon = new SqlConnection(ConfigurationManager.AppSettings["DocuSign_DB_CONNSTRING"]))
            {
                try
                {
                    SqlCommand SQLcmd = new SqlCommand(insertProcedure, SQLCon)
                    {
                        CommandType = CommandType.StoredProcedure
                    };


                    //  Create the input paramenters
                    SQLcmd.Parameters.AddWithValue("@batchRunId", batchRunID);
                    SQLcmd.Parameters.AddWithValue("@formId", formID);
                    SQLcmd.Parameters.AddWithValue("@studentId", student.StudentId);
                    SQLcmd.Parameters.AddWithValue("@courseId", student.CourseId);
                    SQLcmd.Parameters.AddWithValue("@envelopeId", envelopeSumm.EnvelopeId);
                    SQLcmd.Parameters.AddWithValue("@envelopeStatus", envelopeSumm.Status);
                    SQLcmd.Parameters.AddWithValue("@statusDate", Convert.ToDateTime(envelopeSumm.StatusDateTime));
                    SQLcmd.Parameters.AddWithValue("@receipientRoleId", 1); // Student = 1, DME = 2, Preceptor = 3

                    SQLcmd.Connection = SQLCon;
                    SQLCon.Open();
                    SQLcmd.ExecuteNonQuery();
                }
                finally
                {
                    SQLCon.Close();
                    SQLCon.Dispose();
                }
            }
        }
Пример #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                ViewData["results"] = $"Informações não preenchidas";

                return(new PageResult());
            }


            // Constants need to be set:
            string accessToken = config.Value.AccessToken;
            string accountId   = config.Value.AccountId;


            string signerName = EnvelopeTemplateInfo.Name;

            string signerEmail = EnvelopeTemplateInfo.Email;

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email       = signerEmail, Name = signerName,
                RecipientId = "1", RoutingOrder = "1"
            };

            // 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  = EnvelopeTemplateInfo.AssuntoEmail,
                EmailBlurb    = EnvelopeTemplateInfo.CorpoEmail,
                TemplateId    = EnvelopeTemplateInfo.ModeloId,
                TemplateRoles = new List <TemplateRole> {
                    new TemplateRole {
                        Email = signerEmail, Name = signerName, RoleName = "Teste"
                    }
                },
                Status = "sent"
            };

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

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

            EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            ViewData["results"] = $"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}";

            return(new PageResult());
        }
Пример #7
0
        public static void GetStudentRotationInfo()
        {
            SqlConnection   conn = null;
            SqlDataReader   rdr  = null;
            string          sendDatesProcedure = "sp_DocuSignFormSendDates_Demo";
            Student         student            = new Student();
            EnvelopeSummary envelopeSumm       = new EnvelopeSummary();

            try
            {
                conn = new SqlConnection(ConfigurationManager.AppSettings["SMSDB_CONNSTRING2"]);
                conn.Open();

                var cmd = new SqlCommand(sendDatesProcedure, conn)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@StartDate", startDate);

                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    student.StudentId          = rdr["StudentID"].ToString();
                    student.StudentFirstName   = rdr["StudentFirstName"].ToString();
                    student.StudentLastName    = rdr["StudentLastName"].ToString();
                    student.StudentName        = rdr["StudentName"].ToString();
                    student.StudentPicturePath = rdr["StudentPicturePath"].ToString();
                    student.CourseId           = rdr["CourseUID"].ToString();

                    //FOR QA - Uncomment for PROD
                    //student.StudentEmailSchool  = rdr["StudentEmailSchool"].ToString();
                    //****************************************************************************************************
                    //FOR Testing - Comment out for PROD
                    student.StudentEmailSchool = "*****@*****.**";
                    //****************************************************************************************************

                    student.CourseId         = rdr["CourseUID"].ToString();
                    student.ClinicalRotation = rdr["CourseTitle"].ToString();
                    student.CreditWeeks      = rdr["CourseCreditWeeks"].ToString();
                    student.ClinicalSite     = rdr["HospitalName"].ToString();
                    student.StartDate        = rdr["CourseDateStart"].ToString();
                    student.EndDate          = rdr["CourseDateEnd"].ToString();


                    envelopeSumm = RequestStudentSignatureFromTemplate(student);

                    //CALL TO INSERT FORMSENT & ENVELOPE_HISTORY RECORDs
                    InsertFormAndEnvelopeInfo(student, envelopeSumm, batchRunID);
                } //END WHILE LOOP
            }     //END Try
            finally
            {
                // close reader
                rdr?.Close();

                // close connection
                conn?.Close();
            }
        }
        /// <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);
        }
Пример #9
0
        public EnvelopeSummary createEnvelopeFromTemplate(string accountId)
        {
            EnvelopeDefinition envDef = new EnvelopeDefinition();

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

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            TemplateRole tRole = new TemplateRole();

            tRole.Email    = "{USER_EMAIL}";
            tRole.Name     = "{USER_NAME}";
            tRole.RoleName = "{ROLE}";

            List <TemplateRole> rolesList = new List <TemplateRole>()
            {
                tRole
            };

            // add the role to the envelope and assign valid templateId from your account
            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = "{TEMPLATE_ID}";

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

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Trace.WriteLine("Envelope has been sent to " + tRole.Email);
            return(envelopeSummary);
        }
Пример #10
0
        //////////////////////////////////////////////////////////
        // Main()
        //////////////////////////////////////////////////////////
        static void Main(string[] args)
        {
            CoreRecipes recipes = new CoreRecipes();

            //*** TEST 1 - Request Signature (on local document)
            EnvelopeSummary envSummary = recipes.requestSignatureOnDocumentTest();

            //*** TEST 2 - Request Signature (from Template)
            //EnvelopeSummary envSummary = recipes.requestSignatureFromTemplateTest();

            //*** TEST 3 - Get Envelope Information
            //Envelope env = recipes.getEnvelopeInformationTest();

            //*** TEST 4 - Get Recipient Information
            //Recipients recips = recipes.listRecipientsTest();

            //*** TEST 5 - List Envelopes
            //EnvelopesInformation envelopes = recipes.listEnvelopesTest();

            //*** TEST 6 - Download Envelope Documents
            //recipes.listDocumentsAndDownloadTest();

            //*** TEST 7 - Embedded Sending
            //ViewUrl senderView = recipes.createEmbeddedSendingViewTest();

            //*** TEST 8 - Embedded Signing
            //ViewUrl recipientView = recipes.createEmbeddedSigningViewTest();

            //*** TEST 9 - Embedded DocuSign Console
            //ViewUrl consoleView = recipes.createEmbeddedConsoleViewTest();

            Console.Read();
        }
Пример #11
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));
        }
        public void GetFormData_CorrectInputParameters_ReturnEnvelopeFormData()
        {
            var envDef = new EnvelopeDefinition
            {
                EmailSubject = "[DocuSign C# SDK] - Please sign this doc"
            };

            var tRole = new TemplateRole
            {
                Email    = _testConfig.RecipientEmail,
                Name     = _testConfig.RecipientName,
                RoleName = "Manager"
            };

            var rolesList = new List <TemplateRole>()
            {
                tRole
            };

            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = _testConfig.TemplateId;

            envDef.Status = "sent";

            EnvelopeSummary envelopeSummary = _envelopesApi.CreateEnvelope(_testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary?.EnvelopeId);

            EnvelopeFormData envFormData = _envelopesApi.GetFormData(_testConfig.AccountId, envelopeSummary.EnvelopeId);

            Assert.IsNotNull(envFormData?.FormData);
            Assert.IsNotNull(envFormData?.EnvelopeId);
        }
        /// <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);
        }
Пример #14
0
        public void CreateEnvelopeTest()
        {
            try
            {
                // get the logininformation and accountId
                if (!TestConfig.Authenticated)
                {
                    AuthenticationApiTests loginTests = new AuthenticationApiTests();
                    loginTests.LoginTest();
                }

                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                // send the envelope (otherwise it will be "created" in the Draft folder
                envDef.EmailSubject = "CreateEnvelopeTest";
                envDef.Status       = TestConfig.EnvelopeStatusOnCreate;

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

                // store for use in other tests.
                TestConfig.EnvelopeId = envelopeSummary.EnvelopeId;
            }
            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);
            }
        }
        // ***DS.snippet.0.start
        private string DoWork(string signerEmail, string signerName, string ccEmail,
                              string ccName, string accessToken, string basePath, string accountId)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // accessToken
            // basePath
            // accountId
            var apiClient = new ApiClient(basePath);

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

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

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

            return(results.EnvelopeId);
        }
        /// <summary>
        /// Creates an envelope that would include payment processing to collect payment from recipient
        /// </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="envStatus">Status to set the envelope to</param>
        /// <param name="paymentDetails">Object containing all the necassary information to process payments</param>
        /// <returns>EnvelopeId for the new envelope</returns>
        public static string CreateEnvelopeWithPayment(string signerEmail, string signerName, string ccEmail,
                                                       string ccName, string accessToken, string basePath, string accountId, string envStatus, PaymentDetails paymentDetails)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // accessToken
            // basePath
            // accountId
            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, envStatus, paymentDetails);

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

            return(results.EnvelopeId);
        }
Пример #17
0
        public void GetEnvelopeInformationTest()
        {
            try
            {
                // get the logininformation and accountId
                AuthenticationApiTests loginTests = new AuthenticationApiTests();
                loginTests.LoginTest();

                EnvelopeDefinition envDef = Utils.CreateDraftEnvelopeDefinition();
                // send the envelope (otherwise it will be "created" in the Draft folder
                envDef.EmailSubject = "GetEnvelopeInformationTest";
                envDef.Status       = "sent";

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

                // Get the status of the envelope
                Envelope envelope = envelopesApi.GetEnvelope(TestConfig.AccountId, envelopeSummary.EnvelopeId, null);
                Assert.IsNotNull(envelope);
                Assert.IsNotNull(envelope.Status);
                Assert.IsNotNull(envelope.EnvelopeId);
                Trace.WriteLine("Envelope: " + envelope.ToJson());
            }
            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>
        /// 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);
        }
        private void LegacyRequestSignatureOnDocumentTest(string status = "sent")
        {
            // the document (file) we want signed
            const string SignTest1File = @"../../docs/SignTest1.pdf";

            // 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.Email        = testConfig.RecipientEmail;
            signer.Name         = testConfig.RecipientName;
            signer.RecipientId  = "1";
            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   = "100";
            signHere.ScaleValue  = ".5";
            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 = status;

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

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
Пример #20
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());
        }
Пример #21
0
        private Response FormatEnvelopeResponse(EnvelopeSummary envelopeSummary)
        {
            Response response = new Response();

            response.Meta.Add("status", envelopeSummary.Status);
            response.Data.Add("id", envelopeSummary.EnvelopeId);               // Service's   Id == EnvelopeId
            return(response);
        }
Пример #22
0
        //////////////////////////////////////////////////////////
        // Main()
        //////////////////////////////////////////////////////////
        static void Main(string[] args)
        {
            CoreRecipes recipes = new CoreRecipes();

            //*** TEST 1 - Request Signature (on local document)
            EnvelopeSummary envSummary = recipes.requestSignatureOnDocumentTest();

            Console.Read();
        }
Пример #23
0
        } // end requestSignatureTest()

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public EnvelopeSummary requestSignatureFromTemplateTest()
        {
            // Enter recipient (signer) name and email address
            string recipientName  = "[RECIPIENT_NAME]";
            string recipientEmail = "[RECIPIENT_EMAIL]";

            // the document (file) we want signed
            string templateId       = "[TEMPLATE_ID]";
            string templateRoleName = "[TEMPLATE_ROLE_NAME]";

            // 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: Signature Request from Template
            //===========================================================

            EnvelopeDefinition envDef = new EnvelopeDefinition();

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

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            TemplateRole tRole = new TemplateRole();

            tRole.Email    = recipientEmail;
            tRole.Name     = recipientName;
            tRole.RoleName = templateRoleName;

            List <TemplateRole> rolesList = new List <TemplateRole>()
            {
                tRole
            };

            // add the role to the envelope and assign valid templateId from your account
            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = templateId;

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

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

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

            return(envelopeSummary);
        } // end requestSignatureFromTemplateTest()
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal EnvelopeSummary Send()
        {
            CheckToken();

            EnvelopeDefinition envelope    = this.CreateEvelope();
            EnvelopesApi       envelopeApi = new EnvelopesApi(ApiClient.Configuration);
            EnvelopeSummary    results     = envelopeApi.CreateEnvelope(AccountID, envelope);

            return(results);
        }
Пример #25
0
        public EnvelopeSummary createEnvelopeWithEmbeddedRecipient(string accountId)
        {
            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes("test.pdf");

            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.Email        = "{USER_EMAIL}";
            signer.Name         = "{USER_NAME}";
            signer.RecipientId  = "1";
            signer.ClientUserId = "1001";

            // 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";

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

            // print the JSON response
            Trace.WriteLine("EnvelopeSummary:\n" + JsonConvert.SerializeObject(envelopeSummary));
            Trace.WriteLine("Envelope with embedded recipient created and sent.");
            return(envelopeSummary);
        }
Пример #26
0
        /// <summary>
        /// Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
        /// </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="envStatus">Status to set the envelope to</param>
        /// <returns>EnvelopeId for the new envelope</returns>
        public static string SendEnvelopeViaEmail(string signerEmail, string signerName, string ccEmail, string ccName, string accessToken, string basePath, string accountId, string docDocx, string docPdf, string envStatus)
        {
            EnvelopeDefinition env = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, docDocx, docPdf, envStatus);
            var apiClient          = new ApiClient(basePath);

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

            return(results.EnvelopeId);
        }
Пример #27
0
        /// <summary>
        /// Creates a new envelope from an existing template and send it out
        /// </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="templateId">The templateId for the tempalte to use to create an envelope</param>
        /// <returns>EnvelopeId for the new envelope</returns>
        public static string SendEnvelopeFromTemplate(string signerEmail, string signerName, string ccEmail, string ccName, string accessToken, string basePath, string accountId, string templateId)
        {
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi       envelopesApi = new EnvelopesApi(config);
            EnvelopeDefinition envelope     = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId);
            EnvelopeSummary    result       = envelopesApi.CreateEnvelope(accountId, envelope);

            return(result.EnvelopeId);
        }
Пример #28
0
        public void RequestSignatureViaTemplateTest()
        {
            try
            {
                // upload template if one doesn't exist
                // FAILED - CANT UPLOAD A TEMPLATE - API-3002 submitted
                // use predefined template
                AuthenticationApiTests authTests = new AuthenticationApiTests();
                authTests.LoginTest();

                // get pre-existing template with Signer1 role
                // since I can't upload a template right now
                TemplatesApi            templatesApi    = new TemplatesApi();
                EnvelopeTemplateResults templateResults = templatesApi.ListTemplates(TestConfig.AccountId);
                Assert.IsNotNull(templateResults);
                Assert.IsNotNull(templateResults.EnvelopeTemplates);
                string templateId = null;
                foreach (EnvelopeTemplateResult et in templateResults.EnvelopeTemplates)
                {
                    if (et.Name == "Test Template")
                    {
                        templateId = et.TemplateId;
                        break;
                    }
                }
                Assert.IsNotNull(templateId);

                EnvelopeDefinition envDef = new EnvelopeDefinition();
                envDef.TemplateId = templateId;

                envDef.TemplateRoles = new List <TemplateRole>();
                TemplateRole templateRole = new TemplateRole();
                templateRole.Email    = TestConfig.DefaultEmail;
                templateRole.Name     = TestConfig.DefaultName;
                templateRole.RoleName = "Signer1";
                envDef.TemplateRoles.Add(templateRole);
                envDef.Status = "sent"; // trigger the envelope to be sent (vs. Draft/Created)


                // send envelope using template roles
                EnvelopesApi    envelopesApi = new EnvelopesApi();
                EnvelopeSummary es           = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(es);
                Assert.IsNotNull(es.EnvelopeId);
                Trace.WriteLine("Envelope: " + es.ToJson());
            }
            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);
            }
        }
Пример #29
0
        /// <summary>
        /// Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
        /// </summary>
        /// <param name="signerEmail">Email address for the signer</param>
        /// <param name="signerName">Full name of 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>
        /// <returns>EnvelopeId for the new envelope</returns>
        public static string SendEnvelopeWithDelayedRouting(string signer1Email, string signer1Name, string signer2Email, string signer2Name, string accessToken, string basePath, string accountId, string docPdf, int delay)
        {
            EnvelopeDefinition env = MakeEnvelope(signer1Email, signer1Name, signer2Email, signer2Name, docPdf, delay);
            var apiClient          = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            // Step 3 start
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, env);

            // Step 3 end
            return(results.EnvelopeId);
        }
Пример #30
0
        /// <summary>
        /// Creates an envelope that would include two documents and add a signer and cc recipients to be notified via email
        /// </summary>
        /// <param name="signerEmail">Email address for the signer</param>
        /// <param name="signerName">Full name of 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>
        /// <returns>EnvelopeId for the new envelope</returns>
        public static string ScheduleEnvelope(string signerEmail, string signerName, string accessToken, string basePath, string accountId, string docPdf, DateTime resumeDate)
        {
            EnvelopeDefinition env = MakeEnvelope(signerEmail, signerName, docPdf, resumeDate);
            var apiClient          = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            // Step 3 start
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, env);

            // Step 3 end
            return(results.EnvelopeId);
        }