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); }
private void JwtRequestSignatureOnDocumentTest(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); 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 = 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; }
public static object CreateEnvelope_SailboatLoan(object[] reqArray, string accountId) { try { //list to store all objects that will be returned to Node.js List <object> rtn = new List <object>(); object nodeReqBody = reqArray[0]; //extract req.body from array passed in object nodeReqSession = reqArray[1]; //extract req.session from array passed in string nodeCurrentPath = reqArray[2].ToString(); //extract current path from array passed in string gmapBase64Doc = reqArray[3].ToString(); //extract gmapBase64Doc from array passed in //create dictionary from Node object and extract object values from request body var bodyDictionary = (IDictionary <string, object>)nodeReqBody; var body = new Body() { inputEmail = (string)bodyDictionary["inputEmail"], inputFirstName = (string)bodyDictionary["inputFirstName"], inputLastName = (string)bodyDictionary["inputLastName"], inputAppraiserEmail = (string)bodyDictionary["inputAppraiserEmail"], inputAppraiserFirstName = (string)bodyDictionary["inputAppraiserFirstName"], inputAppraiserLastName = (string)bodyDictionary["inputAppraiserLastName"], inputSigningLocation = (string)bodyDictionary["inputSigningLocation"], inputSigningLocationAppraiser = (string)bodyDictionary["inputSigningLocationAppraiser"], //the fields below may not exist (depending on the UI options selected, so test to see if they are in the dictionary first inputAccessCode = bodyDictionary.ContainsKey("inputAccessCode") ? (string)bodyDictionary["inputAccessCode"] : "", inputAccessCodeAppraiser = bodyDictionary.ContainsKey("inputAccessCodeAppraiser") ? (string)bodyDictionary["inputAccessCodeAppraiser"] : "", inputAuthentication = bodyDictionary.ContainsKey("inputAuthentication") ? (string)bodyDictionary["inputAuthentication"] : "", inputAuthenticationAppraiser = bodyDictionary.ContainsKey("inputAuthenticationAppraiser") ? (string)bodyDictionary["inputAuthenticationAppraiser"] : "", inputPhone = bodyDictionary.ContainsKey("inputPhone") ? (string)bodyDictionary["inputPhone"] : "", inputAppraiserPhone = bodyDictionary.ContainsKey("inputAppraiserPhone") ? (string)bodyDictionary["inputAppraiserPhone"] : "" }; var file1Base64 = Helper.getLocalDocument(nodeCurrentPath + "/pdfs/LoanSailboat.docx"); var file2Base64 = Helper.getLocalDocument(nodeCurrentPath + "/pdfs/LoanSailboatAppraiser.docx"); // create an envelope that will store the document(s), field(s), and recipient(s) EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.EmailSubject = "Sailboat Loan Application"; envDef.EmailBlurb = "Please sign the Loan application to start the application process."; // add documents to the envelope Document doc1 = new Document(); doc1.DocumentBase64 = file1Base64; doc1.Name = "Application"; // can be different from actual file name doc1.FileExtension = "docx"; doc1.DocumentId = "1"; // hardcode so we can easily refer to this document later Document doc2 = new Document(); // MessageBox.Show(gmapBase64Doc); if (gmapBase64Doc != "") { doc2.DocumentBase64 = gmapBase64Doc; doc2.Name = "Map"; // can be different from actual file name doc2.FileExtension = "png"; doc2.DocumentId = "2"; // hardcode so we can easily refer to this document later } Document doc3 = new Document(); doc3.DocumentBase64 = file2Base64; doc3.Name = "Appraiser"; // can be different from actual file name doc3.FileExtension = "docx"; doc3.DocumentId = "3"; // hardcode so we can easily refer to this document later envDef.Documents = new List <Document>(); envDef.Documents.Add(doc1); if (gmapBase64Doc != "") { envDef.Documents.Add(doc2); } envDef.Documents.Add(doc3); envDef.EnforceSignerVisibility = "true"; // Recipients Signer signer = new Signer(); signer.RoutingOrder = "1"; signer.Email = body.inputEmail; signer.Name = body.inputFirstName + " " + body.inputLastName; signer.RecipientId = "1"; signer.ExcludedDocuments = new List <String>(); signer.ExcludedDocuments.Add("3"); if (body.inputSigningLocation == "embedded") { signer.ClientUserId = "1001"; } if (body.inputAccessCode != "" && body.inputAccessCode.Length > 0) { signer.AccessCode = body.inputAccessCode; } if (body.inputAuthentication == "phone") { Helper.addPhoneAuthToRecipient(signer, body.inputPhone); } Signer appraiserSigner = new Signer(); appraiserSigner.RoutingOrder = "2"; appraiserSigner.Email = body.inputAppraiserEmail; appraiserSigner.Name = body.inputAppraiserFirstName + " " + body.inputAppraiserLastName; appraiserSigner.RecipientId = "2"; if (body.inputSigningLocationAppraiser == "embedded") { appraiserSigner.ClientUserId = "2002"; } if (body.inputAccessCodeAppraiser != "" && body.inputAccessCodeAppraiser.Length > 0) { appraiserSigner.AccessCode = body.inputAccessCodeAppraiser; } if (body.inputAuthenticationAppraiser == "phone") { Helper.addPhoneAuthToRecipient(appraiserSigner, body.inputAppraiserPhone); } // Signer Tabs signer.Tabs = new Tabs(); signer.Tabs.TextTabs = new List <Text>(); signer.Tabs.NumberTabs = new List <Number>(); signer.Tabs.FormulaTabs = new List <FormulaTab>(); signer.Tabs.EmailTabs = new List <Email>(); signer.Tabs.FullNameTabs = new List <FullName>(); signer.Tabs.SignerAttachmentTabs = new List <SignerAttachment>(); signer.Tabs.SignHereTabs = new List <SignHere>(); signer.Tabs.InitialHereTabs = new List <InitialHere>(); signer.Tabs.DateSignedTabs = new List <DateSigned>(); // Note: using anchorStrings (in tabs below) makes documentId and pageNumber irrelevant (they affect all documents and pages) // Email Email signerEmail = new Email(); signerEmail.RecipientId = "1"; signerEmail.AnchorString = "Applicant Email"; signerEmail.AnchorXOffset = "0"; signerEmail.AnchorYOffset = "0"; signerEmail.Value = body.inputEmail; signer.Tabs.EmailTabs.Add(signerEmail); // FullName FullName signerFullName = new FullName(); signerFullName.RecipientId = "1"; signerFullName.AnchorString = "Applicant Full Name"; signerFullName.AnchorXOffset = "0"; signerFullName.AnchorYOffset = "0"; signer.Tabs.FullNameTabs.Add(signerFullName); // Attachment SignerAttachment signerAttachment = new SignerAttachment(); signerAttachment.RecipientId = "1"; signerAttachment.AnchorString = "Please attach"; signerAttachment.AnchorXOffset = "0"; signerAttachment.AnchorYOffset = "40"; signerAttachment.Optional = "true"; signer.Tabs.SignerAttachmentTabs.Add(signerAttachment); // SignHere SignHere signerSignHere = new SignHere(); signerSignHere.RecipientId = "1"; signerSignHere.AnchorString = "Applicant Signature"; signerSignHere.AnchorXOffset = "0"; signerSignHere.AnchorYOffset = "4"; signer.Tabs.SignHereTabs.Add(signerSignHere); // InitialHere InitialHere signerInitialHere = new InitialHere(); signerInitialHere.RecipientId = "1"; signerInitialHere.AnchorString = "Applicant Initial"; signerInitialHere.AnchorXOffset = "0"; signerInitialHere.AnchorYOffset = "0"; signer.Tabs.InitialHereTabs.Add(signerInitialHere); // Appraiser Tabs appraiserSigner.Tabs = new Tabs(); appraiserSigner.Tabs.TextTabs = new List <Text>(); appraiserSigner.Tabs.EmailTabs = new List <Email>(); appraiserSigner.Tabs.FullNameTabs = new List <FullName>(); appraiserSigner.Tabs.SignHereTabs = new List <SignHere>(); appraiserSigner.Tabs.InitialHereTabs = new List <InitialHere>(); appraiserSigner.Tabs.DateSignedTabs = new List <DateSigned>(); appraiserSigner.Tabs.FormulaTabs = new List <FormulaTab>(); appraiserSigner.Tabs.SignerAttachmentTabs = new List <SignerAttachment>(); appraiserSigner.Tabs.NumberTabs = new List <Number>(); // Email Email appraiserSignerEmail = new Email(); appraiserSignerEmail.RecipientId = "2"; appraiserSignerEmail.AnchorString = "Appraiser Email"; appraiserSignerEmail.AnchorXOffset = "0"; appraiserSignerEmail.AnchorYOffset = "0"; appraiserSignerEmail.Value = body.inputAppraiserEmail; appraiserSigner.Tabs.EmailTabs.Add(appraiserSignerEmail); // FullName FullName appraiserSignerFullName = new FullName(); appraiserSignerFullName.RecipientId = "2"; appraiserSignerFullName.AnchorString = "Appraiser Full Name"; appraiserSignerFullName.AnchorXOffset = "0"; appraiserSignerFullName.AnchorYOffset = "0"; appraiserSigner.Tabs.FullNameTabs.Add(appraiserSignerFullName); // Appraisal amount Number appraiserSignerAmount = new Number(); appraiserSignerAmount.RecipientId = "2"; appraiserSignerAmount.AnchorString = "Appraiser Estimate"; appraiserSignerAmount.AnchorXOffset = "0"; appraiserSignerAmount.AnchorYOffset = "0"; appraiserSignerAmount.Locked = "false"; appraiserSigner.Tabs.NumberTabs.Add(appraiserSignerAmount); // SignHere SignHere appraisalSignerSignHere = new SignHere(); appraisalSignerSignHere.RecipientId = "2"; appraisalSignerSignHere.AnchorString = "Appraiser Signature"; appraisalSignerSignHere.AnchorXOffset = "0"; appraisalSignerSignHere.AnchorYOffset = "4"; appraiserSigner.Tabs.SignHereTabs.Add(appraisalSignerSignHere); // BLANK TEXT (on first document, to make it visible to our Appraiser) Text appraisalSignerText = new Text(); appraisalSignerText.RecipientId = "2"; appraisalSignerText.DocumentId = "1"; appraisalSignerText.PageNumber = "1"; appraisalSignerText.XPosition = "0"; appraisalSignerText.YPosition = "0"; appraisalSignerText.Value = ""; appraisalSignerText.Locked = "true"; appraiserSigner.Tabs.TextTabs.Add(appraisalSignerText); // add recipients envDef.Recipients = new Recipients(); envDef.Recipients.Signers = new List <Signer>(); envDef.Recipients.Signers.Add(signer); envDef.Recipients.Signers.Add(appraiserSigner); // send the envelope by setting |status| to "sent". To save as a draft set to "created" // - note that the envelope will only be 'sent' when it reaches the DocuSign server with the 'sent' status (not in the following call) envDef.Status = "sent"; //Get Config settings from App.config DocuSignConfig configSettings = new DocuSignConfig(); if (configSettings.BRAND_ID != "" && configSettings.BRAND_ID.Length > 0) { envDef.BrandId = configSettings.BRAND_ID; } // instantiate a new EnvelopesApi object EnvelopesApi envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef); rtn.Add(envelopeSummary); //Index 0: add envelopeSummary to the return object // Create and save envelope locally (temporary) //app.helpers.createAndSaveLocal(req, envelopeSummary.envelopeId) //.then(function(){ List <object> remainingSigners = new List <object>(); if (body.inputSigningLocationAppraiser == "embedded") { remainingSigners.Add(appraiserSigner); } else { remainingSigners.Add("remote-signer"); } remainingSigners.Add("remote-signer"); // last signer is remote (employee) if (body.inputSigningLocation == "embedded") { ViewUrl viewUrl = Helper.getRecipientUrl(envelopesApi, accountId, envDef, envelopeSummary.EnvelopeId.ToString(), signer); rtn.Add(viewUrl); //Index 1: add viewURL to the return object } rtn.Add(signer); //Index 2: add signer to the return object rtn.Add(appraiserSigner); //Index 3: add appraiserSigner to the return object return(rtn); } catch (Exception ex) { MessageBox.Show(ex.Message); throw ex; } }