This post was most recently updated on August 2nd, 2024
DocuSign sends email invitations to the Recipients, and the Recipients click on a link in the email to go to the DocuSign site and sign the documents. DocuSign takes care of everything – sending emails to the Recipients, handling all of the possible actions that they can take during signing, providing access to the signed documents after the signing ceremony is complete.
Let’s say that you have a web application that collects some information from your customer, and prepares an envelope with the documents that the customer needs to sign. You send the envelope, and then inform your customer that they will receive an email from DocuSign, and that they will need to click on the link in the email to start the signing process. Then, once the signing is complete, your application can be notified via a status callback from DocuSign, and you can then take additional steps as necessary.
The general use for the DocuSign service is sending documents for signature and the basic steps are described in below Fig:
Steps to Use DocuSign:
- First you have to Register with DocuSign Sandbox(https://secure.docusign.com/signup/develop)
- After Login you have to Create IntegratorKey inside DocuSign Sandbox. (To Create IntegratorKey go to Admin —> select API and Keys—->select Add IntegratorKey )
- Use this Uername,Password,IntegratorKey in your Web application to Login in Docusign Sandbox.
1234567891011121314151617181920212223public ActionResult DocuSinLOogin(){// Enter your DocuSign credentialsstring docuSignUser = "Username"string docuSignPassword = "Password"string docuSignIntegratorKey = "your IntegratorKey"// Enter recipient (signer) name and email address// 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 clientApiClient apiClient = new ApiClient(basePath);// set client in global config so we don't need to pass it to each API objectConfiguration.Default.ApiClient = apiClient;string authHeader = "{\"Username\":\"" + docuSignUser + "\", \"Password\":\"" + docuSignPassword + "\", \"IntegratorKey\":\"" + docuSignIntegratorKey + "\"}";Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);// we will retrieve this from the login() resultsstring accountId = null;// the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration objectAuthenticationApi authApi = new AuthenticationApi();LoginInformation loginInfo = authApi.Login();}
4. Now you have to create Envelope in which you have to Add Recipients and Documents on which you require Electronic Signature from Recipients.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
public ActionResult DocuSignEnvelopeSummary(IEnumerable<HttpPostedFileBase> file, string Reciepientemail, string name) { DocuSignModel objDocuSignModel = new DocuSignModel(); string path = Server.MapPath("~/Uploads/"); foreach (var fileupload in file) { if (fileupload != null && fileupload.ContentLength > 0) { fileupload.SaveAs(path + Path.GetFileName(fileupload.FileName)); objDocuSignModel.FileName = fileupload.FileName; objDocuSignModel.FilePath = Path.GetFullPath(path + fileupload.FileName); ; } } // Enter your DocuSign credentials string docuSignUser = WebConfigurationManager.AppSettings["DocuSignUser"].ToString(); string docuSignPassword = WebConfigurationManager.AppSettings["DocuSignPassword"].ToString(); string docuSignIntegratorKey = WebConfigurationManager.AppSettings["DocuSignIntegratorKey"].ToString(); // Enter recipient (signer) name and email address char[] delimiterChars = { ' ', ',', ';' }; string[] Names = name.Split(delimiterChars); string[] Emails = Reciepientemail.Split(delimiterChars); for (int s = 0; s < Names.Count(); s++) { objDocuSignModel.RecipientName = Names[s]; } for (int e = 0; e < Emails.Count(); e++) { objDocuSignModel.RecipientEmailId = Emails[e]; } // 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\":\"" + docuSignUser + "\", \"Password\":\"" + docuSignPassword + "\", \"IntegratorKey\":\"" + docuSignIntegratorKey + "\"}"; Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication"); 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()); List<string> SignTest1File = new List<string>(); EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.EmailSubject = "Please sign this Electronic mail doc"; envDef.Documents = new List<Document>(); // Add a document to the envelope int p = 0; foreach (HttpPostedFileBase SignTestFile in file) { SignTest1File.Add(SignTestFile.FileName); Document document = new Document(); document.DocumentId = "1"; for (; p < SignTest1File.Count();) { byte[] fileBytes = System.IO.File.ReadAllBytes(path + SignTest1File[p]); document.DocumentBase64 = System.Convert.ToBase64String(fileBytes); document.Name = Path.GetFileName(path + SignTest1File[p]); p++; break; } document.FileExtension = "txt"; envDef.Documents.Add(document); } envDef.Recipients = new Recipients(); envDef.Recipients.Signers = new List<Signer>(); // Add a recipient to sign the documeent Signer signer = new Signer(); signer.Tabs = new Tabs(); signer.Tabs.SignHereTabs = new List<SignHere>(); int j = 0; for (int i = 0; i < Names.Length;) { for (; j < Emails.Length;) { Signer recipient = new Signer(); recipient.Name = Names[i]; recipient.Email = Emails[j]; recipient.RecipientId = Convert.ToString(++i); SignHere signHere = new SignHere(); signHere.DocumentId = Convert.ToString(i); signHere.PageNumber = Convert.ToString(i); signHere.RecipientId = Convert.ToString(i); signHere.XPosition = "100"; signHere.YPosition = "150"; signer.Tabs.SignHereTabs.Add(signHere); envDef.Recipients.Signers.Add(recipient); j++; break; } } // 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); return View(); } |
5. From Envelope Summary you will get Staus of your mail whether it is Sent,Delivered,Completed,Deleted etc..
References:
1.https://github.com/docusign/docusign-soap-sdk/wiki/Code-Walkthrough-_-Embedded-Signing
2.https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#Introduction+Changes/Process Flow.htm
3.https://github.com/docusign/docusign-rest-recipes/blob/master/core_recipes/CoreRecipes.cs