How’s it goin’ my dotnet fam?

I recently completed the development of an e-signature integration using the DocuSign API in my team’s Web Forms app. Taking a break from the budgeting app series, I wanted to write a little bit about how it was done, any disturbances in the force while working with the API in tandem with ASP.NET, and how you can get something working pretty fast in your own apps.

Some background on our app - it began as a .NET 3.5 Web Forms app that generates quotes for insurance policies (fuck yes, right?). A form is filled out which then fills a PDF and requires two signatures. The current business workflow was to email the PDFs around, letting the signers print them, sign them, fax them back in, and email them back. Perfect candidate for software automation!

We looked at a handful of third-party e-signature vendors and DocuSign won our vote. You may have used DocuSign yourself online. It’s seems to be the de facto e-signature service right now.

The DocuSign API has been a breeze to work with. It’s a mostly RESTful implementation and is open-sourced on github along with a handful of client libraries that make using the library as easy as a nicely named method call.

Okay, enough spat, let’s get to the steps:

  1. First, in order to use their .NET client library, you’ll need your app to be at .NET 4.5 or later. We upgraded ours from 3.5 before this which wasn’t too bad. I’ve mentioned it before but we essentially just followed this tutorial by Dave Paquette.

  2. Set up a developer sandbox account with DocuSign to get your integration key. This will allow you to develop and test the app for free until you eventually convert it to a live paid account.

  3. Using NuGet, and install the DocuSign .NET Client package to one of your projects. We created a DocuSignService class that implements an ESignatureService interface. In our app we expect we might offer alternatives to DocuSign so we were certain to ensure we only program to that interface. We borrowed a lot of the nomenclature from DocuSign though - envelopes, recipients, documents, etc. Hopefully other e-signature providers model their objects something like that.

  4. Okay, you’ve got the library, you’ve got your DocuSign API integration key, username, and password. Now you just need to login and make a request. Fortunately DocuSign provided a bunch of sample code to do these basic steps so that’s where we will head next. Head on over to the CoreRecipes.cs file on github and grab the requestSignatureOnDocumentTest method. You’ll also need to set your integrator key as is done at the very top of the Examples.cs file in the main method.

  5. Call the method! At this point you would edit the sample code so it has real values, and a real path to a document (we used the version of the envelope.Create() method that takes a byte array since our PDFs are stored in a database.) As I mentioned before, we modeled envelopes and recipients in our own database, so our UI let’s a user fill in the needed data and we map our own models to DocuSign’s models in the client library before making requests. This way, if we implement a different e-signature service, we can just make a new mapping. Keep all the DocuSign specific code in it’s own area.

  6. That’s it! Your recipient will receive an email with a link to e-sign inside DocuSign. Now of course that’s just the happy path of e-signatures. You may want to do a number of other things like checking the signature status (use DocuSign Connect), pulling the signed document back in, or having your users sign directly in your app. Fortunately, all can be done using a very similar approach to the the signing request call and the documentation is very thorough.

Disturbances In The Force

Most of the development has been smooth sailing, the only unpleasantry I had was using an UpdatePanel for asynchronous calls. I put the e-signature form in it’s own UpdatePanel and all the requests had this nifty animation along with an Amazon-tracking-esque progress bar that animated to the current status. Because of our apps requirements and the amount of different technologies used on the page, I had to pull out the UpdatePanel.

I think UpdatePanel gets a lot of slack, but it’s a handy abstraction for async if your Web Forms app is simple…(is it ever?)

So, have you used the DocuSign API in your apps? What was your main frustration? What about HelloSign or any of the competitors?

Next week I’ll get back on schedule with the budgeting asp.net core app. I’m finishing up the early parts of the Web API and by reader request will take a stab at using React for the front end. If you haven’t already, sign up for the newsletter to be notified when it’s posted.

Share the URL if you like this :) It would be much appreciated.