Esempio n. 1
0
        public async Task <ApiResponse <DocuSignResponseModel> > SendDocument(DocumentSignModel model, string serverPath)
        {
            var docusignManager = new DocuSignManager();
            var confirmationUrl = appSettings.Get("docusign:ConfirmationUrl");

            var authInformation = new DocuSignAuthHeader
            {
                Username      = settings.Docusign.UserName,
                Password      = settings.Docusign.Password,
                IntegratorKey = settings.Docusign.IntegratorKey
            };

            var caseModel = caseRepository.Query(c => c.ID == model.CaseID).FirstOrDefault();

            var responseModel = docusignManager.SendDocument(model, caseModel, authInformation, serverPath, confirmationUrl);

            var docusignLog = new DocuSignLog
            {
                CaseID      = model.CaseID,
                DocumentID  = responseModel.DocumentID,
                EnvelopeID  = responseModel.EnvelopeID,
                CreatedDate = DateTime.Now
            };

            repository.Add(docusignLog);
            await repository.SaveChanges();

            return(new ApiResponse <DocuSignResponseModel>(responseModel));
        }
        public async Task <HttpResponseMessage> SendDocument(DocumentSignModel model)
        {
            string serverPath = HttpContext.Current.Server.MapPath("~");

            var response = await service.SendDocument(model, serverPath);

            return(SendHttpResponse(response));
        }
Esempio n. 3
0
        public DocuSignResponseModel SendDocument(DocumentSignModel model, Case caseModel, DocuSignAuthHeader authInformation, string serverPath)
        {
            var docusignResponse = new DocuSignResponseModel();

            var loginInfo = GetLoginInfo(authInformation);

            var documentModel = SendDocumentAndGetUrl(model, caseModel, loginInfo, serverPath);

            docusignResponse.SignUrl    = documentModel.SignUrl;
            docusignResponse.CaseID     = model.CaseID.ToString();
            docusignResponse.DocumentID = documentModel.DocumentID;
            docusignResponse.EnvelopeID = documentModel.EnvelopeID;

            return(docusignResponse);
        }
Esempio n. 4
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);
        }