public void EmbeddedSigningViewTest() { // create a new envelope with 2 recipients var envelope = new Envelope { Login = _account }; byte[] doc1 = { 36, 45, 34, 67, 121, 87, 99, 32, 32, 32, 54, 54, 55, 56, 32 }; var signers = new List<Signer>(); // note we need to specify clientUserId signers.Add(new Signer { email = "*****@*****.**", name = "test1", recipientId = "1", routingOrder = "1", clientUserId = "1" }); signers.Add(new Signer { email = "*****@*****.**", name = "test2", recipientId = "2", routingOrder = "2", clientUserId = "2" }); envelope.Recipients = new Recipients { signers = signers.ToArray() }; Assert.IsTrue(envelope.Create(doc1, "test-self-signed.doc")); Assert.IsNull(envelope.RestError); // send it envelope.Status = "sent"; Assert.IsTrue(envelope.UpdateStatus()); Assert.IsNull(envelope.RestError); // get embedded signing views for 2 recipients string urlForfirstSigner = envelope.GetEmbeddedSignerView("www.docusign.com", signers.First()); Assert.IsNull(envelope.RestError); Assert.IsFalse(string.IsNullOrEmpty(urlForfirstSigner)); string urlForSecondSigner = envelope.GetEmbeddedSignerView("www.docusign.com", signers.Last()); // now, this one won't work until first one signed (which cannot happen in this test) // this is because second recpieint was set to sign only after the first one finished (routing order) Assert.IsTrue(string.IsNullOrEmpty(urlForSecondSigner)); }
public DocumentForSign GetEmbeddedDocument(Envelope envelope, TemplateInfo templateInfo, string returnUrl) { try { if (envelope == null) throw new ArgumentNullException("envelope"); if (templateInfo == null) throw new ArgumentNullException("templateInfo"); envelope.GetRecipients(); var signer = envelope.Recipients.signers[0]; if (signer != null) { var documents = envelope.GetDocuments(); var envelopeDocument = documents.FirstOrDefault(x => x.name.Contains(templateInfo.Name)); if (envelopeDocument != null) { var tabs = new CustomTabs(int.Parse(envelopeDocument.documentId), signer.recipientId, signer.name); envelope.AddTabs(new TabCollection { companyTabs = tabs.CompanyTabs, dateSignedTabs = tabs.dateSignedTabs, signHereTabs = tabs.SignHereTabs, textTabs = tabs.TextTabs }); var doc = new DocumentForSign { Document = Template.GetTemplatePreview(templateInfo.Id), DocumentName = templateInfo.Name, EmbeddedUrl = envelope.GetEmbeddedSignerView(returnUrl, signer) }; if (!string.IsNullOrEmpty(doc.EmbeddedUrl)) { _context.Documents.Add(new DocuSignDocument() { EnvelopeId = envelope.EnvelopeId, EmbeddedUrl = doc.EmbeddedUrl, Status = "sent", UserId = signer.clientUserId }); _context.SaveChanges(); } return doc; } } } catch (Exception ex) { throw ex; } return null; }