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);
        }
Exemple #2
0
        private 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);
        }
Exemple #3
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_event2 = new EnvelopeEvent();

            envelope_event2.EnvelopeEventStatusCode = "delivered";
            envelope_events.Add(envelope_event2);
            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_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";
            recipient_events.Add(recipient_event3);
            RecipientEvent recipient_event4 = new RecipientEvent();

            recipient_event4.RecipientEventStatusCode = "Declined";
            recipient_events.Add(recipient_event4);
            RecipientEvent recipient_event5 = new RecipientEvent();

            recipient_event5.RecipientEventStatusCode = "AuthenticationFailed";
            recipient_events.Add(recipient_event5);
            RecipientEvent recipient_event6 = new RecipientEvent();

            recipient_event6.RecipientEventStatusCode = "AutoResponded";
            recipient_events.Add(recipient_event6);

            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 = "true";
            event_notification.IncludeDocumentFields             = "true";
            event_notification.IncludeCertificateOfCompletion    = "true";
            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;

            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.CarbonCopies = new List <CarbonCopy>();
            recipients.CarbonCopies.Add(carbon_copy);

            EnvelopeDefinition envelope_definition = new EnvelopeDefinition();

            envelope_definition.EmailSubject = "Please sign the " + "NDA.pdf" + " document";
            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));
        }
        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, string signerCountryCode, string signerPhoneNumber, string ccEmail, string ccName, string ccCountryCode, string ccPhoneNumber)
        {
            // Data for this method
            // signerEmail
            // signerName
            // signerCountryCode
            // signerPhoneNumber
            // ccEmail
            // ccName
            // ccCountryCode
            // ccPhoneNumber
            // 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",
                AdditionalNotifications = new List <RecipientAdditionalNotification>
                {
                    new RecipientAdditionalNotification
                    {
                        PhoneNumber = new RecipientPhoneNumber
                        {
                            CountryCode = signerCountryCode,
                            Number      = signerPhoneNumber
                        },
                        SecondaryDeliveryMethod = "SMS"
                    }
                }
            };

            // 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",
                AdditionalNotifications = new List <RecipientAdditionalNotification>
                {
                    new RecipientAdditionalNotification
                    {
                        PhoneNumber = new RecipientPhoneNumber
                        {
                            CountryCode = ccCountryCode,
                            Number      = ccPhoneNumber
                        },
                        SecondaryDeliveryMethod = "SMS"
                    }
                }
            };

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