ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application

Introduction
 
In this article, I will explain how to integrate and validate a DocuSign connection with an ASP.NET MVC5 web application. Let's move forward.
 
Prerequisites 
  • Visual Studio
  • Basic Knowledge of ASP.NET MVC
  • Basic Knowledge of C#
Article Flow
  • Introduction about DocuSign
  • Create an account on DocuSign portal
  • Activate DocuSign account
  • Generate Integrator Key
  • Create ASP.NET MVC Empty project
  • Create a Controller and View
  • Install Docusign Integrations client from NuGet and enable it in our application
  • Validate the DocuSign Connection
Introduction to DocuSign
 
DocuSign is a top eSignature brand that provides electronic signature technology and digital transaction management services for facilitating electronic exchanges of contracts and signed documents. The features of DocuSign include authentication services, user identity management, and workflow automation. Nowadays, no one is ready to make an in-person meeting, or contract, or bonding. Even a lot of software companies ask us to sign on a device to accept their offer letter, right? Okay, now we will move to the first step of creating an account on DocuSign. We can use the trial account until it goes to production.
 
Create an account on the DocuSign portal
 
To create an account, click here. It's a Sandbox account and it will take you to the screen mentioned below. Fill in the required fields and get started into the DocuSign portal.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
Activate DocuSign account
 
After registration, you will get a mail from the DocuSign team to activate your account. There, you need to reset your password and then you can redirect to your dashboard.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
Generate Integrator Key
 
The Integrator key serves as the client id for the OAuth token. I'd first make sure that you're connecting the correct integrator key to the correct account. You can generate multiple integrator keys in the demo environment but when your API gets certified, only one integrator key can be promoted to production. Make sure that you are pointing to the demo environment with a valid integrator key. With the help of the integrator key only, we can integrate this DocuSign account to our application and this integrator key will act as a token for the user.
 
Given below is your dashboard and opt for the "Go to Admin" option to generate the integrator key.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application
 
By default, our account will be without integrator key, so we have to create that. To create an integrator key, click "Add integrator key".
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
While creating the API integrator key, give a proper name because, in the trial account, we can have multiple keys. Now, we will create an application. 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
In the below image, you can see that we got the integrator key. Now, we have got enough things to connect with our application.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
Create ASP.NET MVC Empty project 
  • To create an ASP.NET MVC empty project, follow the below steps one by one. Here, I have used Visual Studio 2017.
  • Select New Project -> Visual C# -> Web -> ASP.NET Web Application and enter your application name. Here, I named it "DocusignDemo".
  • Now, click OK.
  • Then, select Empty ASP.NET MVC template and click OK to create the project.
  • Once you click OK, the project will be created with the basic architecture of MVC. If you are not aware of how to create an Empty ASP.NET Web Application, please visit Step 1 and Step 2 to learn
Once you complete these steps, you will get the screen as below.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
Create a Controller and View
 
Now, create an empty Controller and View. Here, I created a Controller with the name of "DocusignController". Whenever we create an empty Controller, it is created with an empty Index action method. And create an empty View of this action method "Index".
 
Install Docusign Integrations client from NuGet and enable it in our application,
 
Select Package Manager Console 
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
and Install-Package DocuSign.Integration.Client.dll -Version 1.7.2.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
After installation, it will be integrated into our application as below.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
Now, write the logic in your controller to validate this integration and account credentials.
  1. RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net";  
  2. RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2";  
  3. RestSettings.Instance.IntegratorKey = "******************************"//Mention your created Integrator key  
  4. DocuSign.Integrations.Client.Account account = new DocuSign.Integrations.Client.Account();  
  5. account.Email = credential.UserName; //Mention your Account Username  
  6. account.Password = credential.Password; //Mention your Account Password  
  7. bool result = account.Login();  
  8. if (result) {  
  9.     Console.WriteLine("Docusign Integration Success");  
  10. else {  
  11.     Console.WriteLine("Docusign Integration Failed");  
  12. }  
The above code is straightforward. Just run your application.
 
ASP.NET MVC 5 - Integrate And Validate DocuSign Connection With Web Application 
 
We successfully integrated the DocuSign with our application. In my next article, we will see how to send the documents for signature and how to track whether the documents are signed or viewed by the recipient. 
 
Complete Controller 
  1. using DocuSign.Integrations.Client;  
  2. using System;  
  3. using System.Collections.Generic;  
  4. using System.Linq;  
  5. using System.Web;  
  6. using System.Web.Mvc;  
  7. namespace DocusignDemo.Controllers {  
  8.     public class DocusignController: Controller {  
  9.         MyCredential credential = new MyCredential();  
  10.         // GET: Docusign  
  11.         public ActionResult Index() {  
  12.             RestSettings.Instance.DocuSignAddress = "https://demo.docusign.net";  
  13.             RestSettings.Instance.WebServiceUrl = RestSettings.Instance.DocuSignAddress + "/restapi/v2";  
  14.             RestSettings.Instance.IntegratorKey = "PasteYour Integrator key"//Mention your created Integrator key  
  15.             DocuSign.Integrations.Client.Account account = new DocuSign.Integrations.Client.Account();  
  16.             account.Email = credential.UserName; //Mention your Account Username  
  17.             account.Password = credential.Password; //Mention your Account Password  
  18.             bool result = account.Login();  
  19.             if (result) {  
  20.                 Console.WriteLine("Docusign Integration Success");  
  21.             } else {  
  22.                 Console.WriteLine("Docusign Integration Failed");  
  23.             }  
  24.             return View();  
  25.         }  
  26.     }  
  27.     public class MyCredential {  
  28.         public string UserName {  
  29.             get;  
  30.             set;  
  31.         } = "Enter Your Username";  
  32.         public string Password {  
  33.             get;  
  34.             set;  
  35.         } = "Enter Your Password";  
  36.     }  
  37. }  
Summary
 
In this article, we have seen how to Integrate DocuSign and Validate with our ASP.NET MVC5 Web application
 
I hope you enjoyed this article. Your valuable feedback and comments about this article are always welcome.


Similar Articles