public void PutRecipients_CorrectAccountIdEnvelopeIdAndRecipients_ReturnRecipientsUpdateSummary()
        {
            CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(
                ref _testConfig);

            var signHere = new SignHere()
            {
                Name        = "SignHereTab",
                XPosition   = "75",
                YPosition   = "572",
                TabLabel    = "SignHereTab",
                PageNumber  = "1",
                DocumentId  = "1",
                RecipientId = "1"
            };

            var signHereTabs = new List <SignHere> {
                signHere
            };

            var signerTabs = new Tabs()
            {
                SignHereTabs = signHereTabs
            };

            var newSigner = new Signer()
            {
                Name                     = "Test name",
                Email                    = "*****@*****.**",
                RoutingOrder             = "1",
                Status                   = "created",
                DeliveryMethod           = "Email",
                RecipientId              = "1",
                Tabs                     = signerTabs,
                IdCheckConfigurationName = "ID Check"
            };

            var signers = new List <Signer> {
                newSigner
            };
            var recipients = new Recipients()
            {
                Signers = signers
            };

            RecipientsUpdateSummary recipientsUpdateSummary = _envelopesApi.UpdateRecipients(
                _testConfig.AccountId,
                _testConfig.EnvelopeId,
                recipients);

            Assert.IsNotNull(recipientsUpdateSummary?.RecipientUpdateResults);

            Recipients updatedListRecipients = _envelopesApi.ListRecipients(
                _testConfig.AccountId,
                _testConfig.EnvelopeId);

            Assert.IsTrue(updatedListRecipients.Signers.Exists(
                              x =>
                              x.Name == newSigner.Name && x.Email == newSigner.Email));
        }
示例#2
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());
        }
        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;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DocusignAuth docusignObj = new DocusignAuth();

            docusignObj.UserName      = ConfigurationManager.AppSettings["Username"].ToString();
            docusignObj.Password      = ConfigurationManager.AppSettings["Password"].ToString();
            docusignObj.IntegratorKey = ConfigurationManager.AppSettings["IntegratorKey"].ToString();
            docusignObj.TemplateId    = ConfigurationManager.AppSettings["TemplateId"].ToString();
            docusignObj.Url           = ConfigurationManager.AppSettings["Url"].ToString();

            DocusignMethods docusignMethods = new DocusignMethods(docusignObj);



            #region Document
            Document document = new Document();
            document.documentId = "1";
            document.name       = "test_document.pdf";

            DocDetail docDetail = new DocDetail();
            docDetail.document = document;
            #endregion

            #region RecipientCreation
            SignHere objSignHere = new SignHere();
            objSignHere.xPosition  = "100";
            objSignHere.yPosition  = "100";
            objSignHere.documentId = "1";
            objSignHere.pageNumber = "1";

            SignHereTab objSignHereTab = new SignHereTab();
            objSignHereTab.signHere = objSignHere;

            Tab objTab = new Tab();
            objTab.signHereTabs = objSignHereTab;

            signer objSigner = new signer();
            objSigner.recipientId = "1";
            objSigner.name        = "jay";
            objSigner.email       = "*****@*****.**";
            objSigner.tabs        = objTab;

            List <signer> signerList = new List <signer>();
            signerList.Add(objSigner);

            Recipients recip = new Recipients();
            recip.signers = signerList;

            #endregion

            envelopeDefinition data = new envelopeDefinition();
            data.emailSubject = "Hello";
            data.emailBlurb   = "Hello";
            data.status       = signatureStatus.sent;
            data.documents    = docDetail;
            data.recipients   = recip;

            string response = docusignMethods.RequestSignatureFromDocument(@"C:\Users\jay\Desktop\test_document.pdf", data);
        }
示例#5
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);
        }
示例#6
0
        internal static EnvelopeTemplate CreateDefaultTemplate(string templateName = null)
        {
            // Read a file from disk to use as a document.

            EnvelopeTemplate templateDef = new EnvelopeTemplate();

            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            templateDef.EmailSubject = "Template " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition = new EnvelopeTemplateDefinition();

            string tempName = templateName;

            if (tempName == null)
            {
                tempName = "Template Name " + DateTime.Now.ToString();
            }
            templateDef.EnvelopeTemplateDefinition.Name = tempName;

            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.RoleName    = "Signer1";
            signer.RecipientId = "1";



            // Create a SignHere tab somewhere on the document for the signer 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   = "200";
            signHere.YPosition   = "100";
            signHere.ScaleValue  = "0.5";
            signer.Tabs.SignHereTabs.Add(signHere);

            templateDef.Recipients         = new Recipients();
            templateDef.Recipients.Signers = new List <Signer>();
            templateDef.Recipients.Signers.Add(signer);
            return(templateDef);
        }
示例#7
0
        internal static EnvelopeDefinition CreateDraftEnvelopeDefinition()
        {
            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "Please Sign my C# SDK 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.UserName; // use name is same as my email
            signer.Name        = "Pat Developer";
            signer.RecipientId = "1";



            // Create a SignHere tab somewhere on the document for the signer 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  = "0.5";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients         = new Recipients();
            envDef.Recipients.Signers = new List <Signer>();
            envDef.Recipients.Signers.Add(signer);
            return(envDef);
        }
示例#8
0
        internal static EnvelopeTemplate CreateDefaultTemplate(string templateName = null)
        {
            // Read a file from disk to use as a document.

            EnvelopeTemplate templateDef = new EnvelopeTemplate();
            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            templateDef.EmailSubject = "Template " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition = new EnvelopeTemplateDefinition();

            string tempName = templateName;
            if (tempName == null) tempName = "Template Name " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition.Name = tempName;

            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.RoleName = "Signer1";
            signer.RecipientId = "1";

            // Create a SignHere tab somewhere on the document for the signer 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 = "200";
            signHere.YPosition = "100";
            signer.Tabs.SignHereTabs.Add(signHere);

            templateDef.Recipients = new Recipients();
            templateDef.Recipients.Signers = new List<Signer>();
            templateDef.Recipients.Signers.Add(signer);
            return templateDef;
        }
示例#9
0
        public string SendforESign(SendDocumentInfo docDetails, List <FileDetail> fileDetails, string CUName, string CUEmail)
        {
            try
            {
                if (!_canExecuteRequest)
                {
                    throw new Exception("Failed to retrieve Credentials from Credential store");
                }

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Request Send document");
                }

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

                string accountId = (!string.IsNullOrEmpty(Utility.DocuSignAccountID)) ? Utility.DocuSignAccountID : GetAccountID();

                EnvelopeDefinition envDef = new EnvelopeDefinition();
                envDef.EmailSubject = ConfigurationManager.AppSettings["DocuSignEmailSubject"];
                envDef.EmailBlurb   = ConfigurationManager.AppSettings["DocuSignEmailBody"];
                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Creating document object");
                }

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

                for (int i = 0; i < fileDetails.Count(); i++)
                {
                    Document doc = new Document();
                    doc.DocumentBase64 = fileDetails.ElementAt(i).base64WordDoc;
                    doc.Name           = fileDetails.ElementAt(i).name;
                    doc.DocumentId     = fileDetails.ElementAt(i).id;
                    doc.FileExtension  = "docx";
                    envDef.Documents.Add(doc);
                }

                envDef.Recipients                 = new Recipients();
                envDef.Recipients.Signers         = new List <Signer>();
                envDef.Recipients.InPersonSigners = new List <InPersonSigner>();

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Creating recipient and sign tabs");
                }

                foreach (var reci in docDetails.SignerDetails)
                {
                    if (docDetails.SignerDetails.ElementAt(0).IsInPerson.ToLower() == "true")
                    {
                        InPersonSigner signer = new InPersonSigner();
                        signer.Tabs = new Tabs();
                        signer.Tabs.SignHereTabs   = new List <SignHere>();
                        signer.Tabs.DateSignedTabs = new List <DateSigned>();
                        signer.Tabs.TextTabs       = new List <Text>();
                        signer.Tabs.DateTabs       = new List <Date>();
                        signer.Tabs.CheckboxTabs   = new List <Checkbox>();

                        //signer.Name = reci.ReciName;
                        //signer.Email = reci.ReciEmail;
                        //signer.RecipientId = reci.ReciId;
                        //signer.RoutingOrder = reci.ReciId;

                        signer.RecipientId         = reci.ReciId;
                        signer.RoutingOrder        = reci.ReciId;
                        signer.InPersonSigningType = "inPersonSigner";
                        signer.SignerName          = reci.ReciName;
                        signer.HostName            = CUName;
                        signer.HostEmail           = CUEmail;
                        //signer.AutoNavigation = "true";
                        //signer.DefaultRecipient = "true";

                        SignHere signHere = new SignHere();
                        signHere.DocumentId               = "1";
                        signHere.RecipientId              = reci.ReciId;
                        signHere.AnchorString             = "member$ign";
                        signHere.AnchorXOffset            = "0";
                        signHere.AnchorYOffset            = "0";
                        signHere.AnchorUnits              = "inches";
                        signHere.AnchorIgnoreIfNotPresent = "false";

                        signer.Tabs.SignHereTabs.Add(signHere);

                        DateSigned signed = new DateSigned();
                        signed.DocumentId               = "1";
                        signed.RecipientId              = reci.ReciId;
                        signed.AnchorString             = "member$date";
                        signed.AnchorXOffset            = "0";
                        signed.AnchorYOffset            = "0";
                        signed.AnchorUnits              = "inches";
                        signed.AnchorIgnoreIfNotPresent = "true";

                        signer.Tabs.DateSignedTabs.Add(signed);

                        for (int j = 1; j <= 16; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = "1";
                            textTab.AnchorString             = "member1$1nput" + j;
                            textTab.TabLabel                 = "OptionalBeneficiaryInfo" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            signer.Tabs.TextTabs.Add(textTab);
                        }


                        for (int k = 1; k <= 8; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = "1";
                            dateTab.AnchorString             = "OBI$D01B$" + k;
                            dateTab.TabLabel                 = "OBIDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            signer.Tabs.DateTabs.Add(dateTab);
                        }

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = "1";
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            signer.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.InPersonSigners.Add(signer);
                    }
                    else
                    {
                        Signer signer = new Signer();
                        signer.Tabs = new Tabs();
                        signer.Tabs.SignHereTabs   = new List <SignHere>();
                        signer.Tabs.DateSignedTabs = new List <DateSigned>();
                        signer.Tabs.TextTabs       = new List <Text>();
                        signer.Tabs.DateTabs       = new List <Date>();
                        signer.Tabs.CheckboxTabs   = new List <Checkbox>();

                        signer.Name         = reci.ReciName;
                        signer.Email        = reci.ReciEmail;
                        signer.RecipientId  = reci.ReciId;
                        signer.RoutingOrder = reci.ReciId;

                        SignHere signHere = new SignHere();
                        signHere.DocumentId               = "1";
                        signHere.RecipientId              = reci.ReciId;
                        signHere.AnchorString             = "member$ign";
                        signHere.AnchorXOffset            = "0";
                        signHere.AnchorYOffset            = "0";
                        signHere.AnchorUnits              = "inches";
                        signHere.AnchorIgnoreIfNotPresent = "false";

                        signer.Tabs.SignHereTabs.Add(signHere);

                        DateSigned signed = new DateSigned();
                        signed.DocumentId               = "1";
                        signed.RecipientId              = reci.ReciId;
                        signed.AnchorString             = "member$date";
                        signed.AnchorXOffset            = "0";
                        signed.AnchorYOffset            = "0";
                        signed.AnchorUnits              = "inches";
                        signed.AnchorIgnoreIfNotPresent = "true";

                        signer.Tabs.DateSignedTabs.Add(signed);

                        for (int j = 1; j <= 16; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = "1";
                            textTab.AnchorString             = "member1$1nput" + j;
                            textTab.TabLabel                 = "OptionalBeneficiaryInfo" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            signer.Tabs.TextTabs.Add(textTab);
                        }


                        for (int k = 1; k <= 8; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = "1";
                            dateTab.AnchorString             = "OBI$D01B$" + k;
                            dateTab.TabLabel                 = "OBIDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            signer.Tabs.DateTabs.Add(dateTab);
                        }

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = "1";
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            signer.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.Signers.Add(signer);
                    }
                }

                if (docDetails.JointSignerDetails != null && docDetails.JointSignerDetails.Count > 0)
                {
                    for (int i = 0; i < docDetails.JointSignerDetails.Count; i++)
                    {
                        if (docDetails.JointSignerDetails.ElementAt(i).IsInPerson.ToLower() == "true")
                        {
                            InPersonSigner jointSigner = new InPersonSigner();
                            jointSigner.Tabs = new Tabs();
                            jointSigner.Tabs.SignHereTabs   = new List <SignHere>();
                            jointSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                            jointSigner.Tabs.TextTabs       = new List <Text>();
                            jointSigner.Tabs.DateTabs       = new List <Date>();
                            jointSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                            //jointSigner.Name = docDetails.JointSignerDetails[i].ReciName;
                            //jointSigner.Email = docDetails.JointSignerDetails[i].ReciEmail;
                            //jointSigner.RecipientId = docDetails.JointSignerDetails[i].ReciId;
                            //jointSigner.RoutingOrder = docDetails.JointSignerDetails[i].ReciId;

                            jointSigner.RecipientId         = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.RoutingOrder        = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.InPersonSigningType = "inPersonSigner";
                            jointSigner.SignerName          = docDetails.JointSignerDetails[i].ReciName;
                            jointSigner.HostName            = CUName;
                            jointSigner.HostEmail           = CUEmail;

                            SignHere jointSignerTab = new SignHere();
                            jointSignerTab.DocumentId               = "1";
                            jointSignerTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSignerTab.AnchorString             = "Joint0w$ign" + (i + 1);
                            jointSignerTab.AnchorXOffset            = "0";
                            jointSignerTab.AnchorYOffset            = "0";
                            jointSignerTab.AnchorUnits              = "inches";
                            jointSignerTab.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.SignHereTabs.Add(jointSignerTab);

                            DateSigned jointSigned = new DateSigned();
                            jointSigned.DocumentId               = "1";
                            jointSigned.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSigned.AnchorString             = "Joint0w$date" + (i + 1);
                            jointSigned.AnchorXOffset            = "0";
                            jointSigned.AnchorYOffset            = "0";
                            jointSigned.AnchorUnits              = "inches";
                            jointSigned.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.DateSignedTabs.Add(jointSigned);

                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            textTab.AnchorString             = "joint1$1nput";
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            jointSigner.Tabs.TextTabs.Add(textTab);

                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "joint$D01B$";
                            dateTab.TabLabel                 = "date1";
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            jointSigner.Tabs.DateTabs.Add(dateTab);

                            for (int c = 1; c <= 5; c++)
                            {
                                Checkbox checkBox = new Checkbox();
                                checkBox.DocumentId               = "1";
                                checkBox.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                                checkBox.AnchorString             = "cu0$chk" + c;
                                checkBox.TabLabel                 = "MSRCheckBox" + c;
                                checkBox.AnchorXOffset            = "0";
                                checkBox.AnchorYOffset            = "0";
                                checkBox.AnchorUnits              = "inches";
                                checkBox.AnchorIgnoreIfNotPresent = "true";

                                jointSigner.Tabs.CheckboxTabs.Add(checkBox);
                            }

                            envDef.Recipients.InPersonSigners.Add(jointSigner);
                        }
                        else
                        {
                            Signer jointSigner = new Signer();
                            jointSigner.Tabs = new Tabs();
                            jointSigner.Tabs.SignHereTabs   = new List <SignHere>();
                            jointSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                            jointSigner.Tabs.TextTabs       = new List <Text>();
                            jointSigner.Tabs.DateTabs       = new List <Date>();
                            jointSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                            jointSigner.Name         = docDetails.JointSignerDetails[i].ReciName;
                            jointSigner.Email        = docDetails.JointSignerDetails[i].ReciEmail;
                            jointSigner.RecipientId  = docDetails.JointSignerDetails[i].ReciId;
                            jointSigner.RoutingOrder = docDetails.JointSignerDetails[i].ReciId;


                            SignHere jointSignerTab = new SignHere();
                            jointSignerTab.DocumentId               = "1";
                            jointSignerTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSignerTab.AnchorString             = "Joint0w$ign" + (i + 1);
                            jointSignerTab.AnchorXOffset            = "0";
                            jointSignerTab.AnchorYOffset            = "0";
                            jointSignerTab.AnchorUnits              = "inches";
                            jointSignerTab.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.SignHereTabs.Add(jointSignerTab);

                            DateSigned jointSigned = new DateSigned();
                            jointSigned.DocumentId               = "1";
                            jointSigned.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            jointSigned.AnchorString             = "Joint0w$date" + (i + 1);
                            jointSigned.AnchorXOffset            = "0";
                            jointSigned.AnchorYOffset            = "0";
                            jointSigned.AnchorUnits              = "inches";
                            jointSigned.AnchorIgnoreIfNotPresent = "true";

                            jointSigner.Tabs.DateSignedTabs.Add(jointSigned);

                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            textTab.AnchorString             = "joint1$1nput";
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            jointSigner.Tabs.TextTabs.Add(textTab);

                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "joint$D01B$";
                            dateTab.TabLabel                 = "date1";
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            jointSigner.Tabs.DateTabs.Add(dateTab);

                            for (int c = 1; c <= 5; c++)
                            {
                                Checkbox checkBox = new Checkbox();
                                checkBox.DocumentId               = "1";
                                checkBox.RecipientId              = docDetails.JointSignerDetails[i].ReciId;
                                checkBox.AnchorString             = "cu0$chk" + c;
                                checkBox.TabLabel                 = "MSRCheckBox" + c;
                                checkBox.AnchorXOffset            = "0";
                                checkBox.AnchorYOffset            = "0";
                                checkBox.AnchorUnits              = "inches";
                                checkBox.AnchorIgnoreIfNotPresent = "true";

                                jointSigner.Tabs.CheckboxTabs.Add(checkBox);
                            }

                            envDef.Recipients.Signers.Add(jointSigner);
                        }
                    }
                }


                if (docDetails.CUSignerDetails != null && docDetails.CUSignerDetails.Count > 0)
                {
                    for (int i = 0; i < docDetails.CUSignerDetails.Count; i++)
                    {
                        Signer cuSigner = new Signer();
                        cuSigner.Tabs = new Tabs();
                        cuSigner.Tabs.SignHereTabs   = new List <SignHere>();
                        cuSigner.Tabs.DateSignedTabs = new List <DateSigned>();
                        cuSigner.Tabs.TextTabs       = new List <Text>();
                        cuSigner.Tabs.DateTabs       = new List <Date>();
                        cuSigner.Tabs.CheckboxTabs   = new List <Checkbox>();

                        cuSigner.Name         = docDetails.CUSignerDetails[i].ReciName;
                        cuSigner.Email        = docDetails.CUSignerDetails[i].ReciEmail;
                        cuSigner.RecipientId  = docDetails.CUSignerDetails[i].ReciId;
                        cuSigner.RoutingOrder = docDetails.CUSignerDetails[i].ReciId;


                        SignHere cuSignerTab = new SignHere();
                        cuSignerTab.DocumentId               = "1";
                        cuSignerTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        cuSignerTab.AnchorString             = "Cu0w$ign";
                        cuSignerTab.AnchorXOffset            = "0";
                        cuSignerTab.AnchorYOffset            = "0";
                        cuSignerTab.AnchorUnits              = "inches";
                        cuSignerTab.AnchorIgnoreIfNotPresent = "true";

                        cuSigner.Tabs.SignHereTabs.Add(cuSignerTab);

                        DateSigned cuSigned = new DateSigned();
                        cuSigned.DocumentId               = "1";
                        cuSigned.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        cuSigned.AnchorString             = "Cu0w$date";
                        cuSigned.AnchorXOffset            = "0";
                        cuSigned.AnchorYOffset            = "0";
                        cuSigned.AnchorUnits              = "inches";
                        cuSigned.AnchorIgnoreIfNotPresent = "true";

                        cuSigner.Tabs.DateSignedTabs.Add(cuSigned);
                        for (int j = 1; j <= 6; j++)
                        {
                            Text textTab = new Text();
                            textTab.DocumentId               = "1";
                            textTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            textTab.AnchorString             = "cu1$1nput" + j;
                            textTab.TabLabel                 = "cuOfficialSec" + j;
                            textTab.AnchorXOffset            = "0";
                            textTab.AnchorYOffset            = "-3";
                            textTab.AnchorUnits              = "pixels";
                            textTab.AnchorIgnoreIfNotPresent = "true";
                            textTab.AnchorMatchWholeWord     = "true";
                            textTab.Required                 = "false";
                            textTab.Width    = "75";
                            textTab.Height   = "15";
                            textTab.FontSize = "Size10";
                            textTab.Font     = "TimesNewRoman";
                            cuSigner.Tabs.TextTabs.Add(textTab);
                        }

                        for (int k = 1; k <= 3; k++)
                        {
                            Date dateTab = new Date();
                            dateTab.DocumentId               = "1";
                            dateTab.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            dateTab.AnchorString             = "cu$D01B$" + k;
                            dateTab.TabLabel                 = "cuDate" + k;
                            dateTab.AnchorXOffset            = "0";
                            dateTab.AnchorYOffset            = "-3";
                            dateTab.AnchorUnits              = "pixels";
                            dateTab.AnchorIgnoreIfNotPresent = "true";
                            dateTab.AnchorMatchWholeWord     = "true";
                            dateTab.Required                 = "false";
                            dateTab.Width    = "50";
                            dateTab.Height   = "15";
                            dateTab.FontSize = "Size9";
                            dateTab.Font     = "Arial";
                            cuSigner.Tabs.DateTabs.Add(dateTab);
                        }

                        Text textTab1 = new Text();
                        textTab1.DocumentId               = "1";
                        textTab1.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab1.AnchorString             = "benComment$1nput";
                        textTab1.TabLabel                 = "BenComment";
                        textTab1.AnchorXOffset            = "0";
                        textTab1.AnchorYOffset            = "-3";
                        textTab1.AnchorUnits              = "pixels";
                        textTab1.AnchorIgnoreIfNotPresent = "true";
                        textTab1.AnchorMatchWholeWord     = "true";
                        textTab1.Required                 = "false";
                        textTab1.Width    = "75";
                        textTab1.Height   = "15";
                        textTab1.FontSize = "Size10";
                        textTab1.Font     = "TimesNewRoman";
                        cuSigner.Tabs.TextTabs.Add(textTab1);

                        Text textTab2 = new Text();
                        textTab2.DocumentId               = "1";
                        textTab2.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab2.AnchorString             = "RetailComment$1nput";
                        textTab2.TabLabel                 = "RetailComment";
                        textTab2.AnchorXOffset            = "0";
                        textTab2.AnchorYOffset            = "-3";
                        textTab2.AnchorUnits              = "pixels";
                        textTab2.AnchorIgnoreIfNotPresent = "true";
                        textTab2.AnchorMatchWholeWord     = "true";
                        textTab2.Required                 = "false";
                        textTab2.Width    = "75";
                        textTab2.Height   = "15";
                        textTab2.FontSize = "Size10";
                        textTab2.Font     = "TimesNewRoman";

                        cuSigner.Tabs.TextTabs.Add(textTab2);

                        Text textTab3 = new Text();
                        textTab3.DocumentId               = "1";
                        textTab3.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                        textTab3.AnchorString             = "Retailemployeeinfo$1nput";
                        textTab3.TabLabel                 = "Retailemployeeinfo";
                        textTab3.AnchorXOffset            = "0";
                        textTab3.AnchorYOffset            = "-3";
                        textTab3.AnchorUnits              = "pixels";
                        textTab3.AnchorIgnoreIfNotPresent = "true";
                        textTab3.AnchorMatchWholeWord     = "true";
                        textTab3.Required                 = "false";
                        textTab3.Width    = "75";
                        textTab3.Height   = "15";
                        textTab3.FontSize = "Size10";
                        textTab3.Font     = "TimesNewRoman";

                        cuSigner.Tabs.TextTabs.Add(textTab3);

                        for (int c = 1; c <= 5; c++)
                        {
                            Checkbox checkBox = new Checkbox();
                            checkBox.DocumentId               = "1";
                            checkBox.RecipientId              = docDetails.CUSignerDetails[i].ReciId;
                            checkBox.AnchorString             = "cu0$chk" + c;
                            checkBox.TabLabel                 = "MSRCheckBox" + c;
                            checkBox.AnchorXOffset            = "0";
                            checkBox.AnchorYOffset            = "0";
                            checkBox.AnchorUnits              = "inches";
                            checkBox.AnchorIgnoreIfNotPresent = "true";

                            cuSigner.Tabs.CheckboxTabs.Add(checkBox);
                        }

                        envDef.Recipients.Signers.Add(cuSigner);
                    }
                }

                envDef.Status = "sent";
                envDef.EnforceSignerVisibility = "true";

                if (Utility.IsEventLogged)
                {
                    Utility.LogAction("Sending Create and send envelope request");
                }

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

                return(envelopeSummary.EnvelopeId);
            }
            catch (Exception ex)
            {
                Utility.LogAction("sending document to DocuSign failed with exception: " + ex.Message);
                throw;
            }
        }
示例#10
0
        private DocumentModel SendDocumentAndGetUrl(DocumentSignModel model, Case caseModel, LoginAccount loginInfo, string serverPath)
        {
            var amountString = (caseModel.Transaction.Amount / 100d).ToString("C");

            var email = Guid.NewGuid() + "@twilio.com";

            string generatedPdfFilePath = pdfGenerator.GenerateDocument(caseModel.Customer.FirstName + " " + caseModel.Customer.LastName, caseModel.Transaction.Description, amountString, serverPath);

            byte[]             fileBytes = File.ReadAllBytes(generatedPdfFilePath);
            EnvelopeDefinition envDef    = new EnvelopeDefinition {
                EmailSubject = "Owl Finance: Transaction"
            };

            var documentModel = new DocumentModel();

            var documentId = model.CaseID.ToString();

            documentModel.DocumentID = documentId;
            var clientId = caseModel.Customer.ID.ToString();

            // Add a document to the envelope
            Document doc = new Document
            {
                DocumentBase64 = Convert.ToBase64String(fileBytes),
                Name           = "Case" + model.CaseID + ".pdf",
                DocumentId     = documentId
            };

            envDef.Documents = new List <Document> {
                doc
            };

            // Add a recipient to sign the documeent
            Signer signer = new Signer
            {
                Name         = model.SendTo,
                Email        = email,
                RecipientId  = "1",
                ClientUserId = clientId,
                Tabs         = new Tabs {
                    SignHereTabs = new List <SignHere>()
                }
            };

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            SignHere signHere = new SignHere
            {
                DocumentId  = documentId,
                PageNumber  = "1",
                RecipientId = "1",
                XPosition   = "40",
                YPosition   = "175"
            };

            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients {
                Signers = new List <Signer> {
                    signer
                }
            };
            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

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

            RecipientViewRequest viewOptions = new RecipientViewRequest()
            {
                ReturnUrl = "https://owlfinance.azurewebsites.net/#/docusign",
                //ReturnUrl = "https://www.docusign.com/devcenter",
                ClientUserId         = clientId,
                AuthenticationMethod = "email",
                UserName             = model.SendTo,
                Email = email
            };
            // create the recipient view (aka signing URL)
            ViewUrl recipientView = envelopesApi.CreateRecipientView(loginInfo.AccountId, envelopeSummary.EnvelopeId,
                                                                     viewOptions);

            documentModel.SignUrl    = recipientView.Url;
            documentModel.EnvelopeID = envelopeSummary.EnvelopeId;
            documentModel.DocumentID = documentId;

            return(documentModel);
        }
        static void Main(string[] args)
        {
            // Enter your DocuSign credentials
            string Username = "******";
            string Password = "******";
            string IntegratorKey = "[INTEGRATOR_KEY]";

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
        private static EnvelopeTemplate MakeTemplate(string resultsTemplateName)
        {
            // Data for this method
            // resultsTemplateName


            // document 1 (pdf) has tag /sn1/
            //
            // The template has two recipient roles.
            // recipient 1 - signer
            // recipient 2 - cc
            // The template will be sent first to the signer.
            // After it is signed, a copy is sent to the cc person.
            // read file from a local directory
            // The reads could raise an exception if the file is not available!
            // add the documents
            Document doc    = new Document();
            string   docB64 = Convert.ToBase64String(System.IO.File.ReadAllBytes("World_Wide_Corp_fields.pdf"));

            doc.DocumentBase64 = docB64;
            doc.Name           = "Lorem Ipsum"; // can be different from actual file name
            doc.FileExtension  = "pdf";
            doc.DocumentId     = "1";

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer();

            signer1.RoleName     = "signer";
            signer1.RecipientId  = "1";
            signer1.RoutingOrder = "1";
            // routingOrder (lower means earlier) determines the order of deliveries
            // to the recipients. Parallel routing order is supported by using the
            // same integer as the order for two or more recipients.

            // create a cc recipient to receive a copy of the documents, identified by name and email
            // We're setting the parameters via setters
            CarbonCopy cc1 = new CarbonCopy();

            cc1.RoleName     = "cc";
            cc1.RoutingOrder = "2";
            cc1.RecipientId  = "2";
            // Create fields using absolute positioning:
            SignHere signHere = new SignHere();

            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.XPosition  = "191";
            signHere.YPosition  = "148";

            Checkbox check1 = new Checkbox();

            check1.DocumentId = "1";
            check1.PageNumber = "1";
            check1.XPosition  = "75";
            check1.YPosition  = "417";
            check1.TabLabel   = "ckAuthorization";

            Checkbox check2 = new Checkbox();

            check2.DocumentId = "1";
            check2.PageNumber = "1";
            check2.XPosition  = "75";
            check2.YPosition  = "447";
            check2.TabLabel   = "ckAuthentication";

            Checkbox check3 = new Checkbox();

            check3.DocumentId = "1";
            check3.PageNumber = "1";
            check3.XPosition  = "75";
            check3.YPosition  = "478";
            check3.TabLabel   = "ckAgreement";

            Checkbox check4 = new Checkbox();

            check4.DocumentId = "1";
            check4.PageNumber = "1";
            check4.XPosition  = "75";
            check4.YPosition  = "508";
            check4.TabLabel   = "ckAcknowledgement";

            List list1 = new List();

            list1.DocumentId = "1";
            list1.PageNumber = "1";
            list1.XPosition  = "142";
            list1.YPosition  = "291";
            list1.Font       = "helvetica";
            list1.FontSize   = "size14";
            list1.TabLabel   = "list";
            list1.Required   = "false";
            list1.ListItems  = new List <ListItem>
            {
                new ListItem {
                    Text = "Red", Value = "Red"
                },
                new ListItem {
                    Text = "Orange", Value = "Orange"
                },
                new ListItem {
                    Text = "Yellow", Value = "Yellow"
                },
                new ListItem {
                    Text = "Green", Value = "Green"
                },
                new ListItem {
                    Text = "Blue", Value = "Blue"
                },
                new ListItem {
                    Text = "Indigo", Value = "Indigo"
                },
                new ListItem {
                    Text = "Violet", Value = "Violet"
                },
            };
            // The SDK can't create a number tab at this time. Bug DCM-2732
            // Until it is fixed, use a text tab instead.
            //   , number = docusign.Number.constructFromObject({
            //         documentId: "1", pageNumber: "1", xPosition: "163", yPosition: "260",
            //         font: "helvetica", fontSize: "size14", tabLabel: "numbersOnly",
            //         height: "23", width: "84", required: "false"})
            Text textInsteadOfNumber = new Text();

            textInsteadOfNumber.DocumentId = "1";
            textInsteadOfNumber.PageNumber = "1";
            textInsteadOfNumber.XPosition  = "153";
            textInsteadOfNumber.YPosition  = "260";
            textInsteadOfNumber.Font       = "helvetica";
            textInsteadOfNumber.FontSize   = "size14";
            textInsteadOfNumber.TabLabel   = "numbersOnly";
            textInsteadOfNumber.Height     = "23";
            textInsteadOfNumber.Width      = "84";
            textInsteadOfNumber.Required   = "false";

            RadioGroup radioGroup = new RadioGroup();

            radioGroup.DocumentId = "1";
            radioGroup.GroupName  = "radio1";

            radioGroup.Radios = new List <Radio>
            {
                new Radio {
                    PageNumber = "1", Value = "white", XPosition = "142", YPosition = "384", Required = "false"
                },
                new Radio {
                    PageNumber = "1", Value = "red", XPosition = "74", YPosition = "384", Required = "false"
                },
                new Radio {
                    PageNumber = "1", Value = "blue", XPosition = "220", YPosition = "384", Required = "false"
                }
            };

            Text text = new Text();

            text.DocumentId = "1";
            text.PageNumber = "1";
            text.XPosition  = "153";
            text.YPosition  = "230";
            text.Font       = "helvetica";
            text.FontSize   = "size14";
            text.TabLabel   = "text";
            text.Height     = "23";
            text.Width      = "84";
            text.Required   = "false";

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs();

            signer1Tabs.CheckboxTabs = new List <Checkbox>
            {
                check1, check2, check3, check4
            };

            signer1Tabs.ListTabs = new List <List> {
                list1
            };
            // numberTabs: [number],
            signer1Tabs.RadioGroupTabs = new List <RadioGroup> {
                radioGroup
            };
            signer1Tabs.SignHereTabs = new List <SignHere> {
                signHere
            };
            signer1Tabs.TextTabs = new List <Text> {
                text, textInsteadOfNumber
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the env object
            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer> {
                signer1
            };
            recipients.CarbonCopies = new List <CarbonCopy> {
                cc1
            };


            // create the overall template definition
            EnvelopeTemplate template = new EnvelopeTemplate();

            // The order in the docs array determines the order in the env
            template.Description = "Example template created via the API";
            template.Name        = resultsTemplateName;
            template.Documents   = new List <Document> {
                doc
            };
            template.EmailSubject = "Please sign this document";
            template.Recipients   = recipients;
            template.Status       = "created";


            return(template);
        }
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string ccEmail, string ccName)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // Config.docDocx
            // Config.docPdf
            // RequestItemsService.Status -- the envelope status ('created' or 'sent')


            // document 1 (html) has tag **signature_1**
            // document 2 (docx) has tag /sn1/
            // document 3 (pdf) has tag /sn1/
            //
            // The envelope has two recipients.
            // recipient 1 - signer
            // recipient 2 - cc
            // The envelope will be sent first to the signer.
            // After it is signed, a copy is sent to the cc person.
            // read files from a local directory
            // The reads could raise an exception if the file is not available!
            string doc2DocxBytes = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.docDocx));
            string doc3PdfBytes  = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.docPdf));
            // create the envelope definition
            EnvelopeDefinition env = new EnvelopeDefinition();

            env.EmailSubject = "Please sign this document set";

            // Create document objects, one per document
            Document doc1 = new Document();
            string   b64  = Convert.ToBase64String(document1(signerEmail, signerName, ccEmail, ccName));

            doc1.DocumentBase64 = b64;
            doc1.Name           = "Order acknowledgement"; // can be different from actual file name
            doc1.FileExtension  = "html";                  // Source data format. Signed docs are always pdf.
            doc1.DocumentId     = "1";                     // a label used to reference the doc
            Document doc2 = new Document {
                DocumentBase64 = doc2DocxBytes,
                Name           = "Battle Plan", // can be different from actual file name
                FileExtension  = "docx",
                DocumentId     = "2"
            };
            Document doc3 = new Document
            {
                DocumentBase64 = doc3PdfBytes,
                Name           = "Lorem Ipsum", // can be different from actual file name
                FileExtension  = "pdf",
                DocumentId     = "3"
            };

            // The order in the docs array determines the order in the envelope
            env.Documents = new List <Document> {
                doc1, doc2, doc3
            };

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1"
            };

            // routingOrder (lower means earlier) determines the order of deliveries
            // to the recipients. Parallel routing order is supported by using the
            // same integer as the order for two or more recipients.

            // create a cc recipient to receive a copy of the documents, identified by name and email
            // We're setting the parameters via setters
            CarbonCopy cc1 = new CarbonCopy
            {
                Email        = ccEmail,
                Name         = ccName,
                RecipientId  = "2",
                RoutingOrder = "2"
            };

            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            //
            // The DocuSign platform searches throughout your envelope's
            // documents for matching anchor strings. So the
            // signHere2 tab will be used in both document 2 and 3 since they
            // use the same anchor string for their "signer 1" tabs.
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "**signature_1**",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            SignHere signHere2 = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs {
                SignHereTabs = new List <SignHere> {
                    signHere1, signHere2
                }
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                },
                CarbonCopies = new List <CarbonCopy> {
                    cc1
                }
            };

            env.Recipients = recipients;
            // Request that the envelope be sent by setting |status| to "sent".
            // To request that the envelope be created as a draft, set to "created"
            env.Status = RequestItemsService.Status;

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

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

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

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

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

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

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

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

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

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

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

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

            // 5. Redirect the user's browser to the URL
            return(Redirect(viewUrl.Url));
        }
示例#15
0
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string brandId)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // Config.docDocx
            // Config.docPdf
            // RequestItemsService.Status -- the envelope status ('created' or 'sent')


            // The envelope has two recipients.
            // recipient 1 - signer
            // The envelope will be sent first to the signer.
            // After it is signed, a copy is sent to the cc person.
            // read files from a local directory
            // The reads could raise an exception if the file is not available!
            string docPdfBytes = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.docPdf));
            // create the envelope definition
            EnvelopeDefinition env = new EnvelopeDefinition();

            env.EmailSubject = "Please sign this document set";

            // Create document objects, one per document
            Document doc = new Document
            {
                DocumentBase64 = docPdfBytes,
                Name           = "Lorem Ipsum", // can be different from actual file name
                FileExtension  = "pdf",
                DocumentId     = "1"
            };

            // The order in the docs array determines the order in the envelope
            env.Documents = new List <Document> {
                doc
            };

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1"
            };


            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            //
            // The DocuSign platform searches throughout your envelope's
            // documents for matching anchor strings. So the
            // signHere2 tab will be used in both document 2 and 3 since they
            // use the same anchor string for their "signer 1" tabs.
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "**signature_1**",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            SignHere signHere2 = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere1, signHere2
                }
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                }
            };

            env.Recipients = recipients;
            // Request that the envelope be sent by setting |status| to "sent".
            // To request that the envelope be created as a draft, set to "created"
            env.Status = RequestItemsService.Status;

            //Set the brand id.
            env.BrandId = brandId;

            return(env);
        }
示例#16
0
        public async Task <DocuSign.eSign.Model.ViewUrl> sendenvelope(string signerName, string signerEmail)
        {
            //public async Task<DocuSign.eSign.Model.ViewUrl> sendenvelope(string signerName, string signerEmail)
            //var signerName =obj.name;
            ///var signerEmail = obj.email;
            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Lorem Ipsum",
                FileExtension  = "pdf",
                DocumentId     = "1"
            };

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



            accessToken = GetAccessToken();

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

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

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

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

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

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results      = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);
            //ViewData["results"] = $"Envelope status: {results.Status}. Envelope ID: {results.EnvelopeId}";

            string envelopeId = results.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl,
                ClientUserId         = signerClientId,
                AuthenticationMethod = "none",
                UserName             = signerName,
                Email = signerEmail
            };

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

            return(viewUrl);
        }
示例#17
0
        public static void CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(ref TestConfig testConfig, string status = "sent")
        {
            var signTest1File = @"../../docs/SignTest1.pdf";

            byte[] fileBytes = File.ReadAllBytes(signTest1File);

            var envDef = new EnvelopeDefinition
            {
                EmailSubject = "[DocuSign C# SDK] - Please sign this doc"
            };

            var doc = new Document
            {
                DocumentBase64 = Convert.ToBase64String(fileBytes),
                Name           = "TestFile.pdf",
                DocumentId     = "1"
            };

            envDef.Documents = new List <Document> {
                doc
            };

            var signer = new Signer
            {
                Email        = testConfig.RecipientEmail,
                Name         = testConfig.RecipientName,
                RecipientId  = "1",
                ClientUserId = "1234",
                Tabs         = new Tabs
                {
                    SignHereTabs = new List <SignHere>()
                }
            };

            var signHere = new SignHere
            {
                DocumentId  = "1",
                PageNumber  = "1",
                RecipientId = "1",
                XPosition   = "100",
                YPosition   = "100",
                ScaleValue  = ".5"
            };

            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer
                }
            };

            envDef.Status = status;

            var             envelopesApi    = new EnvelopesApi(testConfig.ApiClient);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary?.EnvelopeId);

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
        }
示例#18
0
        public async Task <ViewUrl> digiSign(IList <TimesheetVm> tempTimesheetVm, User user, User clientUser)
        {
            // Embedded Signing Ceremony
            // 1. Create envelope request obj
            // 2. Use the SDK to create and send the envelope
            // 3. Create Envelope Recipient View request obj
            // 4. Use the SDK to obtain a Recipient View URL
            // 5. Redirect the user's browser to the URL

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object


            DocuSign.eSign.Model.Document document = new DocuSign.eSign.Model.Document
            {
                DocumentBase64 = Convert.ToBase64String(WriteBytes(tempTimesheetVm, user, clientUser)),
                Name           = user.FirstName + "_" + user.LastName + " Timesheet",
                FileExtension  = "pdf",
                DocumentId     = "1"
            };
            DocuSign.eSign.Model.Document[] documents = new DocuSign.eSign.Model.Document[] { document };

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

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

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

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

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

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + DocuSignConstants.ACCESS_TOKEN);
            EnvelopesApi    envelopesApi = new EnvelopesApi(apiClient.Configuration);
            EnvelopeSummary results      = await envelopesApi.CreateEnvelopeAsync(DocuSignConstants.ACCOUNT_ID, envelopeDefinition);

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

            // 4. Use the SDK to obtain a Recipient View URL
            ViewUrl viewUrl = await envelopesApi.CreateRecipientViewAsync(DocuSignConstants.ACCOUNT_ID, envelopeId, viewOptions);

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

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object
            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Lorem Ipsum",
                FileExtension  = "pdf",
                DocumentId     = "1"
            };

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

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

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

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

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

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

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

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

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

            // 5. Redirect the user's browser to the URL
            return(Redirect(viewUrl.Url));
        }
示例#20
0
        internal static EnvelopeDefinition CreateDraftEnvelopeDefinition()
        {
            // Read a file from disk to use as a document.
            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "Please Sign my C# SDK 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.UserName;  // use name is same as my email
            signer.Name = "Pat Developer";
            signer.RecipientId = "1";

            // Create a SignHere tab somewhere on the document for the signer 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";
            signer.Tabs.SignHereTabs.Add(signHere);

            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);
            return envDef;
        }
        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 = EnvelopeInfo.Name;

            string signerEmail = EnvelopeInfo.Email;

            // Send envelope. Signer's request to sign is sent by email.
            // 1. Create envelope request obj
            // 2. Use the SDK to create and send the envelope

            // 1. Create envelope request object
            //    Start with the different components of the request
            //    Create the document object
            Document document = new Document
            {
                DocumentBase64 = Convert.ToBase64String(ReadContent(docName)),
                Name           = "Lorem Ipsum",
                FileExtension  = "pdf",
                DocumentId     = "1",
            };

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

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

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

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

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs {
                SignHereTabs = new List <SignHere>(signHereTabs)
            };

            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };

            // Create recipients object
            Recipients recipients = new Recipients {
                Signers = new List <Signer>(signers)
            };

            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = EnvelopeInfo.AssuntoEmail,
                Documents    = new List <Document>(documents),
                Recipients   = recipients,
                Status       = "sent"
            };

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

            apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + 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());
        }
示例#22
0
        public IActionResult Create(string signerEmail, string signerName)
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

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

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

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

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

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);

            // Step 3: Create Tabs and CustomFields
            SignHere signHere = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            Text textLegal = new Text
            {
                AnchorString  = "/legal/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Value         = signerName,
                Locked        = "false",
                TabId         = "legal_name",
                TabLabel      = "Legal name",
            };

            Text textFamiliar = new Text
            {
                AnchorString  = "/familiar/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Value         = signerName,
                Locked        = "false",
                TabId         = "familiar_name",
                TabLabel      = "Familiar name"
            };

            // The salary is set both as a readable number in the /salary/ text field,
            // and as a pure number in a custom field ('salary') in the envelope
            int salary = 123000;

            Text textSalary = new Text
            {
                AnchorString  = "/salary/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "-9",
                AnchorXOffset = "5",
                Font          = "helvetica",
                FontSize      = "size11",
                Bold          = "true",
                Locked        = "true",
                // Convert number to String: 'C2' sets the string
                // to currency format with two decimal places
                Value    = salary.ToString("C2"),
                TabId    = "salary",
                TabLabel = "Salary"
            };

            TextCustomField salaryCustomField = new TextCustomField
            {
                Name     = "salary",
                Required = "false",
                Show     = "true", // Yes, include in the CoC
                Value    = salary.ToString()
            };

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

            // Create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1",
                ClientUserId = signerClientId
            };

            // Add the tabs model (including the SignHere tab) to the signer.
            // The Tabs object wants arrays of the different field/tab types
            // Tabs are set per recipient/signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere
                },
                TextTabs = new List <Text> {
                    textLegal, textFamiliar, textSalary
                }
            };

            signer1.Tabs = signer1Tabs;
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                }
            };

            string doc1b64 = Convert.ToBase64String(System.IO.File.ReadAllBytes(Config.tabsDocx));

            // Create document objects, one per document
            Document doc1 = new Document
            {
                DocumentBase64 = doc1b64,
                Name           = "Lorem Ipsum", // Can be different from actual file name
                FileExtension  = "docx",
                DocumentId     = "1"
            };

            // Step 4: Create the envelope definition
            EnvelopeDefinition envelopeAttributes = new EnvelopeDefinition()
            {
                EnvelopeIdStamping = "true",
                EmailSubject       = "Please Sign",
                EmailBlurb         = "Sample text for email body",
                Status             = "Sent",
                Recipients         = recipients,
                CustomFields       = cf,
                Documents          = new List <Document> {
                    doc1
                }
            };

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

            RequestItemsService.EnvelopeId = results.EnvelopeId;

            // Step 6: Create the View Request
            RecipientViewRequest viewRequest = new RecipientViewRequest();

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

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

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

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

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

            return(Redirect(redirectUrl));
        }
示例#23
0
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string ccEmail,
                                                string ccName, string item, string quantity)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName
            // item
            // quantity
            // signerClientId -- class global


            // The envelope request object uses Composite Template to
            // include in the envelope:
            // 1. A template stored on the DocuSign service
            // 2. An additional document which is a custom HTML source document

            // Create Recipients for server template. Note that Recipients object
            // is used, not TemplateRole
            //
            // Create a signer recipient for the signer role of the server template
            Signer signer1 = new Signer
            {
                Email       = signerEmail,
                Name        = signerName,
                RoleName    = "signer",
                RecipientId = "1",
                // Adding clientUserId transforms the template recipient
                // into an embedded recipient:
                ClientUserId = signerClientId
            };
            // Create the cc recipient
            CarbonCopy cc1 = new CarbonCopy
            {
                Email       = ccEmail,
                Name        = ccName,
                RoleName    = "cc",
                RecipientId = "2"
            };
            // Recipients object:
            Recipients recipientsServerTemplate = new Recipients
            {
                CarbonCopies = new List <CarbonCopy> {
                    cc1
                },
                Signers = new List <Signer> {
                    signer1
                }
            };

            // create a composite template for the Server Template
            CompositeTemplate compTemplate1 = new CompositeTemplate
            {
                CompositeTemplateId = "1"
            };
            ServerTemplate serverTemplates = new ServerTemplate
            {
                Sequence   = "1",
                TemplateId = RequestItemsService.TemplateId
            };

            compTemplate1.ServerTemplates = new List <ServerTemplate> {
                serverTemplates
            };
            // Add the roles via an inlineTemplate
            InlineTemplate inlineTemplate = new InlineTemplate
            {
                Sequence   = "1",
                Recipients = recipientsServerTemplate
            };

            compTemplate1.InlineTemplates = new List <InlineTemplate> {
                inlineTemplate
            };
            // The signer recipient for the added document with
            // a tab definition:
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "**signature_1**",
                AnchorYOffset = "10",
                AnchorUnits   = "pixels",
                AnchorXOffset = "20"
            };

            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere1
                }
            };
            // Signer definition for the added document
            Signer signer1AddedDoc = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = signerClientId,
                RoleName     = "signer",
                RecipientId  = "1",
                Tabs         = signer1Tabs
            };
            // Recipients object for the added document:
            Recipients recipientsAddedDoc = new Recipients
            {
                CarbonCopies = new List <CarbonCopy> {
                    cc1
                },
                Signers = new List <Signer> {
                    signer1AddedDoc
                }
            };

            // create the HTML document
            Document doc1 = new Document();

            String doc1b64 = Convert.ToBase64String(document1(signerEmail, signerName, ccEmail, ccName, item, quantity));

            doc1.DocumentBase64 = doc1b64;
            doc1.Name           = "Appendix 1--Sales order"; // can be different from actual file name
            doc1.FileExtension  = "html";
            doc1.DocumentId     = "1";
            // create a composite template for the added document
            CompositeTemplate compTemplate2 = new CompositeTemplate
            {
                CompositeTemplateId = "2"
            };
            // Add the recipients via an inlineTemplate
            InlineTemplate inlineTemplate2 = new InlineTemplate
            {
                Sequence   = "2",
                Recipients = recipientsAddedDoc
            };

            compTemplate2.InlineTemplates = new List <InlineTemplate> {
                inlineTemplate2
            };
            compTemplate2.Document = doc1;

            EnvelopeDefinition env = new EnvelopeDefinition
            {
                Status             = "sent",
                CompositeTemplates = new List <CompositeTemplate> {
                    compTemplate1, compTemplate2
                }
            };

            return(env);
        }
示例#24
0
        static void Main(string[] args)
        {
            // Enter your DocuSign credentials
            string Username      = "******";
            string Password      = "******";
            string IntegratorKey = "[INTEGRATOR_KEY]";

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

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

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

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

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

            string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";

            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

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

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

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

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

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

            EnvelopeDefinition envDef = new EnvelopeDefinition();

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

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.Name        = recipientName;
            signer.Email       = recipientEmail;
            signer.RecipientId = "1";

            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List <SignHere>();
            SignHere signHere = new SignHere();

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

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

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

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

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
        public static void Execute()
        {
            // Enter your DocuSign credentials
            var credentials = new DocusignQuickStart.DocusignCredentials
            {
                Username = "******",
                Password = "******",
                IntegratorKey = "81f3bae3-f472-4a51-8d5f-e966f74cb0ab"
            };

            // specify the document (file) we want signed
            string SignTest1File = @"C:\Users\callu_000\Documents\UD Group\Docusign\CNG\CNG Contract.pdf";

            // Enter recipient (signer) name and email address
            string recipientName = "Callum Rigby";
            string recipientEmail = "*****@*****.**";

            string recipientName2 = "John Smith";
            string recipientEmail2 = "*****@*****.**";

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

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

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

            string authHeader = JsonConvert.SerializeObject(credentials);
            //DocusignCredentials cred = JsonConvert.DeserializeObject<DocusignCredentials>(authHeader);
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);

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

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

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

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

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

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

            // Add a document to the envelope
            var doc = new Document();
            doc.DocumentBase64 = 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
            var signer = new Signer();
            signer.Name = recipientName;
            signer.Email = recipientEmail;
            signer.RecipientId = "1";
            signer.RoutingOrder = "1";

            var signer2 = new Signer();
            signer2.Name = recipientName2;
            signer2.Email = recipientEmail2;
            signer2.RecipientId = "2";
            signer.RoutingOrder = "2";

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

            signer2.Tabs = new Tabs();
            signer2.Tabs.SignHereTabs = new List<SignHere>();
            var signHere2 = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "2";
            signHere.XPosition = "100";
            signHere.YPosition = "200";
            signer2.Tabs.SignHereTabs.Add(signHere);

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

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

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

            // print the JSON response
            Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary));
            Console.Read();
        }
示例#26
0
        private static EnvelopeDefinition CreateEnvelope(string signerEmail, string signerName, string brandId, string status, string docPdf)
        {
            string docPdfBytes = Convert.ToBase64String(System.IO.File.ReadAllBytes(docPdf));
            // create the envelope definition
            EnvelopeDefinition env = new EnvelopeDefinition();

            env.EmailSubject = "Please sign this document set";

            // Create document objects, one per document
            Document doc = new Document
            {
                DocumentBase64 = docPdfBytes,
                Name           = "Lorem Ipsum", // can be different from actual file name
                FileExtension  = "pdf",
                DocumentId     = "1"
            };

            // The order in the docs array determines the order in the envelope
            env.Documents = new List <Document> {
                doc
            };

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1"
            };


            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            //
            // The DocuSign platform searches throughout your envelope's
            // documents for matching anchor strings. So the
            // signHere2 tab will be used in both document 2 and 3 since they
            // use the same anchor string for their "signer 1" tabs.
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "**signature_1**",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            SignHere signHere2 = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorYOffset = "10",
                AnchorXOffset = "20"
            };

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere1, signHere2
                }
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                }
            };

            env.Recipients = recipients;
            env.Status     = status;

            //Set the brand id.
            env.BrandId = brandId;

            return(env);
        }
示例#27
0
        public ActionResult SendSignatureRequest()
        {
            string ds_signer1_name  = WebhookLibrary.GetFakeName();
            string ds_signer1_email = WebhookLibrary.GetFakeEmail(ds_signer1_name);
            string ds_cc1_name      = WebhookLibrary.GetFakeName();
            string ds_cc1_email     = WebhookLibrary.GetFakeEmail(ds_cc1_name);
            string webhook_url      = Request.Url.GetLeftPart(UriPartial.Authority) + "/api/Webhook";

            if (WebhookLibrary.AccountId == null)
            {
                return(Content("[\"ok\" => false, \"html\" => \"<h3>Problem</h3><p>Couldn't login to DocuSign: \"]"));
            }

            // The envelope request includes a signer-recipient and their tabs object,
            // and an eventNotification object which sets the parameters for
            // webhook notifications to us from the DocuSign platform
            List <EnvelopeEvent> envelope_events = new List <EnvelopeEvent>();

            EnvelopeEvent envelope_event1 = new EnvelopeEvent();

            envelope_event1.EnvelopeEventStatusCode = "sent";
            envelope_events.Add(envelope_event1);
            EnvelopeEvent envelope_event3 = new EnvelopeEvent();

            envelope_event3.EnvelopeEventStatusCode = "completed";
            envelope_events.Add(envelope_event3);
            EnvelopeEvent envelope_event4 = new EnvelopeEvent();

            envelope_event4.EnvelopeEventStatusCode = "declined";
            envelope_events.Add(envelope_event4);
            EnvelopeEvent envelope_event5 = new EnvelopeEvent();

            envelope_event5.EnvelopeEventStatusCode = "voided";
            envelope_events.Add(envelope_event5);

            List <RecipientEvent> recipient_events = new List <RecipientEvent>();
            RecipientEvent        recipient_event2 = new RecipientEvent();

            recipient_event2.RecipientEventStatusCode = "Delivered";
            recipient_events.Add(recipient_event2);
            RecipientEvent recipient_event3 = new RecipientEvent();

            recipient_event3.RecipientEventStatusCode = "Completed";
            recipient_events.Add(recipient_event3);
            RecipientEvent recipient_event4 = new RecipientEvent();

            recipient_event4.RecipientEventStatusCode = "Declined";
            recipient_events.Add(recipient_event4);

            EventNotification event_notification = new EventNotification();

            event_notification.Url                               = webhook_url;
            event_notification.LoggingEnabled                    = "true";
            event_notification.RequireAcknowledgment             = "true";
            event_notification.UseSoapInterface                  = "false";
            event_notification.IncludeCertificateWithSoap        = "false";
            event_notification.SignMessageWithX509Cert           = "false";
            event_notification.IncludeDocuments                  = "true";
            event_notification.IncludeEnvelopeVoidReason         = "true";
            event_notification.IncludeTimeZone                   = "true";
            event_notification.IncludeSenderAccountAsCustomField = "false";
            event_notification.IncludeDocumentFields             = "true";
            event_notification.IncludeCertificateOfCompletion    = "false";
            event_notification.EnvelopeEvents                    = envelope_events;
            event_notification.RecipientEvents                   = recipient_events;

            Document document = new Document();

            document.DocumentId = "1";
            document.Name       = "NDA.pdf";

            //string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Documents\NDA.pdf");
            Byte[] bytes = System.IO.File.ReadAllBytes(Server.MapPath("~/Documents/NDA.pdf"));
            document.DocumentBase64 = Convert.ToBase64String(bytes);

            SignHere sign_here_tab = new SignHere();

            sign_here_tab.AnchorString  = "signer1sig";
            sign_here_tab.AnchorXOffset = "0";
            sign_here_tab.AnchorYOffset = "0";
            sign_here_tab.AnchorUnits   = "mms";
            sign_here_tab.RecipientId   = "1";
            sign_here_tab.Name          = "Please sign here";
            sign_here_tab.Optional      = "false";
            sign_here_tab.ScaleValue    = 1;
            sign_here_tab.TabLabel      = "signer1sig";

            FullName full_name_tab = new FullName();

            full_name_tab.AnchorString  = "signer1name";
            full_name_tab.AnchorYOffset = "-6";
            full_name_tab.FontSize      = "Size12";
            full_name_tab.RecipientId   = "1";
            full_name_tab.TabLabel      = "Full Name";
            full_name_tab.Name          = "Full Name";

            DocuSign.eSign.Model.Text text_tab = new DocuSign.eSign.Model.Text();
            text_tab.AnchorString  = "signer1company";
            text_tab.AnchorYOffset = "-8";
            text_tab.FontSize      = "Size12";
            text_tab.RecipientId   = "1";
            text_tab.TabLabel      = "Company";
            text_tab.Name          = "Company";
            text_tab.Required      = "false";

            DateSigned date_signed_tab = new DateSigned();

            date_signed_tab.AnchorString  = "signer1date";
            date_signed_tab.AnchorYOffset = "-6";
            date_signed_tab.FontSize      = "Size12";
            date_signed_tab.RecipientId   = "1";
            date_signed_tab.Name          = "Date Signed";
            date_signed_tab.TabLabel      = "Company";

            DocuSign.eSign.Model.Tabs tabs = new DocuSign.eSign.Model.Tabs();
            tabs.SignHereTabs = new List <SignHere>();
            tabs.SignHereTabs.Add(sign_here_tab);
            tabs.FullNameTabs = new List <FullName>();
            tabs.FullNameTabs.Add(full_name_tab);
            tabs.TextTabs = new List <Text>();
            tabs.TextTabs.Add(text_tab);
            tabs.DateSignedTabs = new List <DateSigned>();
            tabs.DateSignedTabs.Add(date_signed_tab);

            Signer signer = new Signer();

            signer.Email        = ds_signer1_email;
            signer.Name         = ds_signer1_name;
            signer.RecipientId  = "1";
            signer.RoutingOrder = "1";
            signer.Tabs         = tabs;

            Signer signer2 = new Signer();

            signer2.Email        = "*****@*****.**";
            signer2.Name         = "Mario Beko";
            signer2.RecipientId  = "3";
            signer2.RoutingOrder = "1";

            CarbonCopy carbon_copy = new CarbonCopy();

            carbon_copy.Email        = ds_cc1_email;
            carbon_copy.Name         = ds_cc1_name;
            carbon_copy.RecipientId  = "2";
            carbon_copy.RoutingOrder = "2";

            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer>();
            recipients.Signers.Add(signer);
            recipients.Signers.Add(signer2);
            recipients.CarbonCopies = new List <CarbonCopy>();
            recipients.CarbonCopies.Add(carbon_copy);

            EnvelopeDefinition envelope_definition = new EnvelopeDefinition();

            envelope_definition.EmailSubject = "Please sign the " + "NDA.pdf" + " document.URL:" + webhook_url;
            envelope_definition.Documents    = new List <Document>();
            envelope_definition.Documents.Add(document);
            envelope_definition.Recipients        = recipients;
            envelope_definition.EventNotification = event_notification;
            envelope_definition.Status            = "sent";

            EnvelopesApi envelopesApi = new EnvelopesApi(WebhookLibrary.Configuration);

            EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(WebhookLibrary.AccountId, envelope_definition, null);

            if (envelope_summary == null || envelope_summary.EnvelopeId == null)
            {
                return(Content("[\"ok\" => false, html => \"<h3>Problem</h3>\" \"<p>Error calling DocuSign</p>\"]"));
            }

            string envelope_id = envelope_summary.EnvelopeId;

            // Create instructions for reading the email
            string html = "<h2>Signature request sent!</h2>" +
                          "<p>Envelope ID: " + envelope_id + "</p>" +
                          "<h2>Next steps</h2>" +
                          "<h3>1. Open the Webhook Event Viewer</h3>" +
                          "<p><a href='" + Request.Url.GetLeftPart(UriPartial.Authority) + "/Webhook010/status?envelope_id=" + envelope_id + "'" +
                          "  class='btn btn-primary' role='button' target='_blank' style='margin-right:1.5em;'>" +
                          "View Events</a> (A new tab/window will be used.)</p>" +
                          "<h3>2. Respond to the Signature Request</h3>";

            string email_access = WebhookLibrary.GetFakeEmailAccess(ds_signer1_email);

            if (email_access != null)
            {
                // A temp account was used for the email
                html += "<p>Respond to the request via your mobile phone by using the QR code: </p>" +
                        "<p>" + WebhookLibrary.GetFakeEmailAccessQRCode(email_access) + "</p>" +
                        "<p> or via <a target='_blank' href='" + email_access + "'>your web browser.</a></p>";
            }
            else
            {
                // A regular email account was used
                html += "<p>Respond to the request via your mobile phone or other mail tool.</p>" +
                        "<p>The email was sent to " + ds_signer1_name + " &lt;" + ds_signer1_email + "&gt;</p>";
            }

            //return Content("['ok'  => true,'envelope_id' => "+envelope_id+",'html' => "+ html+",'js' => [['disable_button' => 'sendbtn']]]");  // js is an array of items
            return(Content(html));
        }
示例#28
0
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName)
        {
            // Data for this method
            // signerEmail
            // signerName
            // signerClientId -- class global
            // Config.docPdf


            byte[] buffer = System.IO.File.ReadAllBytes(Config.docPdf);

            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();

            envelopeDefinition.EmailSubject = "Please sign this document";
            Document doc1 = new Document();

            String doc1b64 = Convert.ToBase64String(buffer);

            doc1.DocumentBase64 = doc1b64;
            doc1.Name           = "Lorem Ipsum"; // can be different from actual file name
            doc1.FileExtension  = "pdf";
            doc1.DocumentId     = "3";

            // The order in the docs array determines the order in the envelope
            envelopeDefinition.Documents = new List <Document> {
                doc1
            };

            // Create a signer recipient to sign the document, identified by name and email
            // We set the clientUserId to enable embedded signing for the recipient
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = signerClientId,
                RecipientId  = "1"
            };

            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            //
            // The DocuSign platform seaches throughout your envelope's
            // documents for matching anchor strings.
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorUnits   = "pixels",
                AnchorXOffset = "10",
                AnchorYOffset = "20"
            };
            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere1
                }
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipient to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                }
            };

            envelopeDefinition.Recipients = recipients;

            // Request that the envelope be sent by setting |status| to "sent".
            // To request that the envelope be created as a draft, set to "created"
            envelopeDefinition.Status = "sent";

            return(envelopeDefinition);
        }
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string ccEmail, string ccName)
        {
            // Data for this method
            // signerEmail
            // signerName
            // ccEmail
            // ccName


            // document 1 (html) has multiple tags:
            // /l1q/ and /l2q/ -- quantities: drop down
            // /l1e/ and /l2e/ -- extended: payment lines
            // /l3t/ -- total -- formula
            //
            // The envelope has two recipients.
            // recipient 1 - signer
            // recipient 2 - cc
            // The envelope will be sent first to the signer.
            // After it is signed, a copy is sent to the cc person.

            ///////////////////////////////////////////////////////////////////
            //                                                               //
            // NOTA BENA: This method programmatically constructs the        //
            //            order form. For many use cases, it would be        //
            //            better to create the order form as a template      //
            //            using the DocuSign web tool as a WYSIWYG           //
            //            form designer.                                     //
            //                                                               //
            ///////////////////////////////////////////////////////////////////

            // Order form constants
            string l1Name             = "Harmonica";
            int    l1Price            = 5;
            string l1Description      = $"${l1Price} each"
            , l2Name                  = "Xylophone";
            int    l2Price            = 150;
            string l2Description      = $"${l2Price} each";
            int    currencyMultiplier = 100;

            // read file from a local directory
            // The read could raise an exception if the file is not available!
            string doc1HTML1 = System.IO.File.ReadAllText("order_form.html");
            // Substitute values into the HTML
            // Substitute for: {signerName}, {signerEmail}, {ccName}, {ccEmail}
            var doc1HTML2 = doc1HTML1.Replace("{signerName}", signerName)
                            .Replace("{signerEmail}", signerEmail)
                            .Replace("{ccName}", ccName)
                            .Replace("{ccEmail}", ccEmail);

            // create the envelope definition
            EnvelopeDefinition env = new EnvelopeDefinition
            {
                EmailSubject = "Please complete your order"
            };

            // add the documents
            string   doc1b64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(doc1HTML2));
            Document doc1    = new Document
            {
                DocumentBase64 = doc1b64,
                Name           = "Order form", // can be different from actual file name
                FileExtension  = "html",       // Source data format. Signed docs are always pdf.
                DocumentId     = "1"           // a label used to reference the doc
            };

            env.Documents = new List <Document> {
                doc1
            };

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                RecipientId  = "1",
                RoutingOrder = "1"
            };
            // routingOrder (lower means earlier) determines the order of deliveries
            // to the recipients. Parallel routing order is supported by using the
            // same integer as the order for two or more recipients.

            // create a cc recipient to receive a copy of the documents, identified by name and email
            // We're setting the parameters via setters
            CarbonCopy cc1 = new CarbonCopy
            {
                Email        = ccEmail,
                Name         = ccName,
                RoutingOrder = "2",
                RecipientId  = "2"
            };

            // Create signHere fields (also known as tabs) on the documents,
            // We're using anchor (autoPlace) positioning
            SignHere signHere1 = new SignHere
            {
                AnchorString  = "/sn1/",
                AnchorYOffset = "10",
                AnchorUnits   = "pixels",
                AnchorXOffset = "20"
            };
            ListItem listItem0 = new ListItem {
                Text = "none", Value = "0"
            }
            , listItem1 = new ListItem {
                Text = "1", Value = "1"
            }
            , listItem2 = new ListItem {
                Text = "2", Value = "2"
            }
            , listItem3 = new ListItem {
                Text = "3", Value = "3"
            }
            , listItem4 = new ListItem {
                Text = "4", Value = "4"
            }
            , listItem5 = new ListItem {
                Text = "5", Value = "5"
            }
            , listItem6 = new ListItem {
                Text = "6", Value = "6"
            }
            , listItem7 = new ListItem {
                Text = "7", Value = "7"
            }
            , listItem8 = new ListItem {
                Text = "8", Value = "8"
            }
            , listItem9 = new ListItem {
                Text = "9", Value = "9"
            }
            , listItem10 = new ListItem {
                Text = "10", Value = "10"
            }
            ;
            List listl1q = new List
            {
                Font          = "helvetica",
                FontSize      = "size11",
                AnchorString  = "/l1q/",
                AnchorYOffset = "-10",
                AnchorUnits   = "pixels",
                AnchorXOffset = "0",
                ListItems     = new List <ListItem> {
                    listItem0, listItem1, listItem2,
                    listItem3, listItem4, listItem5, listItem6,
                    listItem7, listItem8, listItem9, listItem10
                },
                Required = "true",
                TabLabel = "l1q"
            },
                 listl2q = new List
            {
                Font          = "helvetica",
                FontSize      = "size11",
                AnchorString  = "/l2q/",
                AnchorYOffset = "-10",
                AnchorUnits   = "pixels",
                AnchorXOffset = "0",
                ListItems     = new List <ListItem> {
                    listItem0, listItem1, listItem2,
                    listItem3, listItem4, listItem5, listItem6,
                    listItem7, listItem8, listItem9, listItem10
                },
                Required = "true",
                TabLabel = "l2q"
            };

            // create two formula tabs for the extended price on the line items
            FormulaTab formulal1e = new FormulaTab
            {
                Font               = "helvetica",
                FontSize           = "size11",
                AnchorString       = "/l1e/",
                AnchorYOffset      = "-8",
                AnchorUnits        = "pixels",
                AnchorXOffset      = "105",
                TabLabel           = "l1e",
                Formula            = $"[l1q] * {l1Price}",
                RoundDecimalPlaces = "0",
                Required           = "true",
                Locked             = "true",
                DisableAutoSize    = "false",
            },
                       formulal2e = new FormulaTab
            {
                Font               = "helvetica",
                FontSize           = "size11",
                AnchorString       = "/l2e/",
                AnchorYOffset      = "-8",
                AnchorUnits        = "pixels",
                AnchorXOffset      = "105",
                TabLabel           = "l2e",
                Formula            = $"[l2q] * {l2Price}",
                RoundDecimalPlaces = "0",
                Required           = "true",
                Locked             = "true",
                DisableAutoSize    = "false",
            },
            // Formula for the total
                       formulal3t = new FormulaTab
            {
                Font               = "helvetica",
                Bold               = "true",
                FontSize           = "size12",
                AnchorString       = "/l3t/",
                AnchorYOffset      = "-8",
                AnchorUnits        = "pixels",
                AnchorXOffset      = "50",
                TabLabel           = "l3t",
                Formula            = $"[l1e] + [l2e]",
                RoundDecimalPlaces = "0",
                Required           = "true",
                Locked             = "true",
                DisableAutoSize    = "false",
            };

            // Payment line items
            PaymentLineItem paymentLineIteml1 = new PaymentLineItem
            {
                Name            = l1Name,
                Description     = l1Description,
                AmountReference = "l1e"
            },
                            paymentLineIteml2 = new PaymentLineItem
            {
                Name            = l2Name,
                Description     = l2Description,
                AmountReference = "l2e"
            };
            PaymentDetails paymentDetails = new PaymentDetails
            {
                GatewayAccountId   = Config.GatewayAccountId,
                CurrencyCode       = "USD",
                GatewayName        = Config.GatewayName,
                GatewayDisplayName = Config.GatewayDisplayName,
                LineItems          = new List <PaymentLineItem> {
                    paymentLineIteml1, paymentLineIteml2
                }
            };

            // Hidden formula for the payment itself
            FormulaTab formulaPayment = new FormulaTab
            {
                TabLabel           = "payment",
                Formula            = $"([l1e] + [l2e]) * {currencyMultiplier}",
                RoundDecimalPlaces = "0",
                PaymentDetails     = paymentDetails,
                Hidden             = "true",
                Required           = "true",
                Locked             = "true",
                DocumentId         = "1",
                PageNumber         = "1",
                XPosition          = "0",
                YPosition          = "0"
            };

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere1
                },
                ListTabs = new List <List> {
                    listl1q, listl2q
                },
                FormulaTabs = new List <FormulaTab> {
                    formulal1e, formulal2e, formulal3t, formulaPayment
                }
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the envelope object
            Recipients recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer1
                },
                CarbonCopies = new List <CarbonCopy> {
                    cc1
                }
            };

            env.Recipients = recipients;

            // Request that the envelope be sent by setting |status| to "sent".
            // To request that the envelope be created as a draft, set to "created"
            env.Status = RequestItemsService.Status;

            return(env);
        }
示例#30
0
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string documentBase64)
        {
            var envelopeDefinition = new EnvelopeDefinition()
            {
                EmailSubject = "Please sign this document"
            };

            var doc = new Document()
            {
                DocumentBase64 = documentBase64,
                Name           = $"Contract_{signerName}",
                FileExtension  = "pdf",
                DocumentId     = "3"
            };

            envelopeDefinition.Documents = new List <Document> {
                doc
            };
            var signer = new Signer
            {
                Email        = signerEmail,
                Name         = signerName,
                ClientUserId = signerClientId,
                RecipientId  = "1",
            };

            var signHere = new SignHere
            {
                AnchorString = "/signature/",
                AnchorUnits  = "pixels"
            };

            var dateSigned = new DateSigned
            {
                AnchorString = "/datesigned/",
                AnchorUnits  = "pixels"
            };

            var placeSigned = new Text
            {
                AnchorString = "/placesigned/",
                AnchorUnits  = "pixels",
                Width        = "100"
            };

            var signerTabs = new Tabs
            {
                SignHereTabs = new List <SignHere> {
                    signHere
                },
                DateSignedTabs = new List <DateSigned> {
                    dateSigned
                },
                TextTabs = new List <Text> {
                    placeSigned
                }
            };

            signer.Tabs = signerTabs;

            var recipients = new Recipients
            {
                Signers = new List <Signer> {
                    signer
                }
            };

            var envelope_events = new List <EnvelopeEvent>()
            {
                new EnvelopeEvent
                {
                    EnvelopeEventStatusCode = "completed"
                }
            };

            var event_notification = new EventNotification
            {
                Url                               = "https://auditqualification.azurewebsite.com/Docusign/connectwebhook",
                LoggingEnabled                    = "true",
                RequireAcknowledgment             = "true",
                UseSoapInterface                  = "false",
                IncludeCertificateWithSoap        = "false",
                SignMessageWithX509Cert           = "false",
                IncludeDocuments                  = "true",
                IncludeEnvelopeVoidReason         = "true",
                IncludeTimeZone                   = "true",
                IncludeSenderAccountAsCustomField = "true",
                IncludeDocumentFields             = "true",
                IncludeCertificateOfCompletion    = "true",
                EnvelopeEvents                    = envelope_events
            };

            envelopeDefinition.EventNotification = event_notification;
            envelopeDefinition.Recipients        = recipients;

            envelopeDefinition.Status = "sent";

            return(envelopeDefinition);
        }
示例#31
0
        public async Task <Boolean> sendRequestSign(string signerName, string signerEmail, string accountId, string returnUrl, string authHeader, Dictionary <string, SymitarVars> symitarVars, string fileName)
        {
            List <EnvelopeEvent> envelope_events = new List <EnvelopeEvent>();

            EnvelopeEvent envelope_event1 = new EnvelopeEvent();

            envelope_event1.EnvelopeEventStatusCode = "sent";
            envelope_events.Add(envelope_event1);
            EnvelopeEvent envelope_event2 = new EnvelopeEvent();

            envelope_event2.EnvelopeEventStatusCode = "delivered";
            envelope_events.Add(envelope_event2);
            EnvelopeEvent envelope_event3 = new EnvelopeEvent();

            envelope_event3.EnvelopeEventStatusCode = "completed";

            List <RecipientEvent> recipient_events = new List <RecipientEvent>();
            RecipientEvent        recipient_event1 = new RecipientEvent();

            recipient_event1.RecipientEventStatusCode = "Sent";
            recipient_events.Add(recipient_event1);
            RecipientEvent recipient_event2 = new RecipientEvent();

            recipient_event2.RecipientEventStatusCode = "Delivered";
            recipient_events.Add(recipient_event2);
            RecipientEvent recipient_event3 = new RecipientEvent();

            recipient_event3.RecipientEventStatusCode = "Completed";

            EventNotification event_notification = new EventNotification();

            event_notification.Url                               = returnUrl;
            event_notification.LoggingEnabled                    = "true";
            event_notification.RequireAcknowledgment             = "true";
            event_notification.UseSoapInterface                  = "false";
            event_notification.IncludeCertificateWithSoap        = "false";
            event_notification.SignMessageWithX509Cert           = "false";
            event_notification.IncludeDocuments                  = "true";
            event_notification.IncludeEnvelopeVoidReason         = "true";
            event_notification.IncludeTimeZone                   = "true";
            event_notification.IncludeSenderAccountAsCustomField = "true";
            event_notification.IncludeDocumentFields             = "true";
            event_notification.IncludeCertificateOfCompletion    = "true";
            event_notification.EnvelopeEvents                    = envelope_events;
            event_notification.RecipientEvents                   = recipient_events;


            Tabs tabs = new Tabs();

            tabs.TextTabs       = new List <Text>();
            tabs.SignHereTabs   = new List <SignHere>();
            tabs.DateSignedTabs = new List <DateSigned>();
            int index = 1;

            foreach (KeyValuePair <string, SymitarVars> data in symitarVars)
            {
                System.Console.WriteLine(data.Value.FieldLabel);
                System.Console.WriteLine(data.Value.FieldValue);
                if (data.Value.FieldType.ToUpper() != "SETTING" && (data.Value.FieldType != "DocuSignField" || (data.Value.FieldType == "DocuSignField" && !String.IsNullOrWhiteSpace(data.Value.FieldValue))))
                {
                    switch (data.Value.FieldType)
                    {
                    case "DocuSignField":
                        Text text_tab = new Text();
                        text_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        text_tab.AnchorYOffset = "-8";
                        text_tab.AnchorXOffset = "0";
                        text_tab.RecipientId   = string.Concat("", index);
                        text_tab.TabLabel      = data.Value.FieldLabel;
                        text_tab.Name          = data.Value.FieldValue;
                        text_tab.Value         = data.Value.FieldValue;
                        // text_tab.Required = data.Value.Required;

                        tabs.TextTabs.Add(text_tab);
                        break;

                    case "SignatureField":
                        SignHere sign_here_tab = new SignHere();
                        sign_here_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        sign_here_tab.AnchorXOffset = "0";
                        sign_here_tab.AnchorYOffset = "0";
                        sign_here_tab.Name          = "";
                        sign_here_tab.Optional      = data.Value.Required;
                        sign_here_tab.ScaleValue    = "1";
                        sign_here_tab.TabLabel      = data.Value.FieldLabel;

                        tabs.SignHereTabs.Add(sign_here_tab);
                        break;

                    case "DateSigned":
                        DateSigned date_signed_tab = new DateSigned();
                        date_signed_tab.AnchorString  = "/*" + data.Value.FieldLabel + "*/";
                        date_signed_tab.AnchorYOffset = "-6";
                        date_signed_tab.RecipientId   = string.Concat("", index);
                        date_signed_tab.Name          = "";
                        date_signed_tab.TabLabel      = data.Value.FieldLabel;
                        // date_signed_tab.Required = data.Value.Required;

                        tabs.DateSignedTabs.Add(date_signed_tab);
                        break;

                    default:
                        break;
                        index++;
                    }
                }
            }

            Signer signer = new Signer();

            signer.Email        = signerEmail;
            signer.Name         = signerName;
            signer.RecipientId  = "1";
            signer.RoutingOrder = "1";
            signer.Tabs         = tabs;


            Task <Stream> getS3PDF = S3Data.ReadS3PDF("eSignature/PDFTemplate/" + fileName + ".pdf");
            Stream        newPdf   = await getS3PDF;
            var           bytes    = S3Data.ReadByteStream(newPdf);

            Document document = new Document();

            document.DocumentId = "1";
            document.Name       = fileName;

            // byte[] buffer = System.IO.File.ReadAllBytes("AUTOPYMT2.pdf");
            document.DocumentBase64 = Convert.ToBase64String(bytes);

            Recipients recipients = new Recipients();

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

            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();

            envelopeDefinition.EmailSubject = "Please sign the " + "AUTOPYMT.pdf" + " document";
            envelopeDefinition.Documents    = new List <Document>();
            envelopeDefinition.Documents.Add(document);
            envelopeDefinition.Recipients        = recipients;
            envelopeDefinition.EventNotification = event_notification;
            envelopeDefinition.Status            = "sent";

            ApiClient apiClient = new ApiClient(basePath);

            apiClient.Configuration.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);

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

            if (envelope_summary == null || envelope_summary.EnvelopeId == null)
            {
                return(false);
            }

            // apiClient.Configuration.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            // EnvelopesApi envelopesApi = new EnvelopesApi(WebhookLibrary.Configuration);
            // EnvelopeSummary envelope_summary = envelopesApi.CreateEnvelope(WebhookLibrary.AccountId, envelope_definition, null);

            // string envelope_id = envelope_summary.EnvelopeId;
            Console.WriteLine(envelope_summary);
            return(true);
        }
        public void GenerateDocument(string name, string email, int LastInsertID)
        {
            var docuSignClient = new ESignClient(this.ESignCredentials);
            var accountId      = docuSignClient.AccountId;

            // 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.
            var templateRoles = this.DocuSignTemplate.TemplateRoleNames.Select(m => new TemplateRole
            {
                Email    = email,
                Name     = name,
                RoleName = m
            }).ToList();

            // create a new envelope which we will use to send the signature request
            var envelope = new EnvelopeDefinition
            {
                EmailSubject  = this.EmailTemplate.Subject,
                EmailBlurb    = this.EmailTemplate.MessageBody,
                TemplateId    = this.DocuSignTemplate.TemplateId,
                TemplateRoles = templateRoles,
                Status        = "sent"
            };
            //Added by MK - START

            FileStream fs = new FileStream(@"C:/Users/ue/Desktop/LIC/MoneyPack -1.pdf", FileMode.Open, FileAccess.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, data.Length);
            //string base64 = Convert.ToBase64String(data);

            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = this.EmailTemplate.Subject;

            // Add a document to the envelope
            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(data);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

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

            // Add a recipient to sign the document
            Signer signer = new Signer();

            signer.Email       = email;
            signer.Name        = name;
            signer.RecipientId = "1";

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

            //Added by MK - END



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

            if (LastInsertID != 0)
            {
                string mycon;
                mycon = "server=localhost;port=3306;database=esignapp;user=root;password=sql123";
                con   = new MySql.Data.MySqlClient.MySqlConnection();
                con.ConnectionString = mycon;
                con.Open();
                string UpdateFil = "update tbl_envelope set EnvelopeId = '" + envelopeSummary.EnvelopeId + "', EnvelopeStatus = '" + envelopeSummary.Status + "' where id = '" + LastInsertID + "' ";
                MySql.Data.MySqlClient.MySqlCommand cmd2 = new MySql.Data.MySqlClient.MySqlCommand(UpdateFil, con);
                cmd2.ExecuteNonQuery();
            }
        }
        public void JwtBulkEnvelopesApiTest()
        {
            #region Envelope Creation - with BulkRecipient Flag
            // 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";
            // doc.FileExtension = System.IO.Path.GetExtension(SignTest1File);

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

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.RecipientId     = "1";
            signer.IsBulkRecipient = "true";

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


            TemplateTabs templateTabs = new TemplateTabs();
            templateTabs.DateTabs = new List <Date>();

            Tabs tabs = new Tabs();
            tabs.DateTabs = new List <Date>();

            SignerAttachment signerAttachment = new SignerAttachment();
            signerAttachment.ScaleValue = "";

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

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

            testConfig.EnvelopeId = envelopeSummary.EnvelopeId;
            #endregion
            var response = MockBulkRecipientsSummaryResponse();

            // update the status of the enve
            Envelope envelope = new Envelope();
            envelope.Status = "sent";

            envelopesApi.Update(testConfig.AccountId, testConfig.EnvelopeId, envelope);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.BulkRecipientsUri);
            Assert.IsNotNull(response.BulkRecipientsCount);
        }
示例#34
0
        public async Task <IActionResult> OnPostAsync([FromRoute] string accessCode, [FromRoute] Guid taxId)
        {
            var tax = await _taxBiz.Get(new BaseCoreModel { Id = taxId });

            var result = await _membershipServiceApi.SystemUserApiService.Get(
                new MembershipService.ApiClient.Models.BaseModel
            {
                Id = tax.Data.User.Id
            });

            var bytesAsync =
                await global::System.IO.File.ReadAllBytesAsync(
                    "/home/ubuntu/Workdir/AccnetEngagement.pdf");

            var documentBase64 = Convert.ToBase64String(bytesAsync);
            var accessToken    = await _docusignHttpClient.GetAccessToken(accessCode);

            var userInfo = await _docusignHttpClient.GetUserInfo(accessToken.Data);

            Document document = new Document
            {
                DocumentBase64 = documentBase64,
                Name           = "test", FileExtension = "pdf", DocumentId = "1"
            };

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

            // Create the signer recipient object
            Signer signer = new Signer
            {
                Email       = userInfo.Data.email, Name = userInfo.Data.name, ClientUserId = userInfo.Data.sub,
                RecipientId = "1", RoutingOrder = "1"
            };

            // Create the sign here tab (signing field on the document)


            var dateSigned = new DocuSign.eSign.Model.DateSigned()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Date Signed Tab", XPosition = "70", YPosition = "120",
                Value      = DateTime.Now.ToString("d")
            };

            var fullName1 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "69", YPosition = "130",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };

            var text = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "69", YPosition = "140", Value = result.Data.Address
            };

            var fullName4 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "100", YPosition = "155",
                Value      = result.Data.Gender + " " + result.Data.Firstname + " " + result.Data.Lastname
            };

            var text1 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "370", YPosition = "202", Value = tax.Data.Title
            };
            var text2 = new DocuSign.eSign.Model.Text()
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Text Tab", XPosition = "150", YPosition = "260", Value = tax.Data.Title
            };


            var fullName2 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "240", YPosition = "260",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };
            var fullName3 = new DocuSign.eSign.Model.Text
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Full Name Tab", XPosition = "430", YPosition = "260",
                Value      = result.Data.Firstname + " " + result.Data.Lastname
            };


            SignHere signHereTab = new SignHere
            {
                DocumentId = "1", PageNumber = "1", RecipientId = "1",
                TabLabel   = "Sign Here Tab", XPosition = "400", YPosition = "650"
            };

            SignHere[]   signHereTabs = new SignHere[] { signHereTab };
            DateSigned[] dateSigns    = new DateSigned[] { dateSigned };
            Text[]       texts        = new Text[] { text, text1, text2, fullName1, fullName2, fullName3, fullName4 };

            // Add the sign here tab array to the signer object.
            signer.Tabs = new Tabs
            {
                SignHereTabs   = new List <SignHere>(signHereTabs),
                DateSignedTabs = new List <DateSigned>(dateSigns), TextTabs = new List <Text>(texts)
            };
            // Create array of signer objects
            Signer[] signers = new Signer[] { signer };
            // Create recipients object
            Recipients recipients = new Recipients {
                Signers = new List <Signer>(signers)
            };
            // Bring the objects together in the EnvelopeDefinition
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition
            {
                EmailSubject = "Please sign the document",
                Documents    = new List <Document>(documents),
                Recipients   = recipients,
                Status       = "sent"
            };
            // 2. Use the SDK to create and send the envelope
            var apiClient = new DocuSign.eSign.Client.ApiClient(basePath);

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

            // 3. Create Envelope Recipient View request obj
            string envelopeId = results.EnvelopeId;
            RecipientViewRequest viewOptions = new RecipientViewRequest
            {
                ReturnUrl            = returnUrl, ClientUserId = userInfo.Data.sub,
                AuthenticationMethod = "none",
                UserName             = userInfo.Data.name, Email = userInfo.Data.email
            };

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

            return(Ok(Result <string> .Successful(viewUrl.Url)));
        }