2. Check Package Status and Download Documents

Following up on the creating and sending a document package quick start guide, this guide will cover some things you can do after sending the package, such as: checking the package/signing status, downloading the e-signed documents, and downloading the evidence summary.

This guide will follow up on the Creating and Sending a Package with the .NET SDK guide. It covered looking in your OneSpan Sign inbox to see that your document package (transaction in the new UI) was created and sent properly after executing the C# class built in the guide.



Initial Setup

Create a new project and .cs file for this guide. For example, “CheckStatusAndDownload.cs”. If you need help with this setup, head over the Create and Send a Package with the .NET SDK guide for further instructions.

Locating the Package ID of your Existing Project

Since the package you are working with was created previously, we need to find the package ID for use in this project. If you select the project from the UI inbox, as seen above, the URL will have the package ID, like this:


In the C# class you created in the previous guide, you will see you had access to this package ID when you created the package and used it to send the package. If you were creating a more complex application, you would likely store this package ID for use within other parts of your application, versus looking it up in your OneSpan Sign URLs.

If you want to see this package ID coming from the C# class made in the previous guide, you could add the line:

Debug.WriteLine(“PackageId: “ + packageId);

After the line:

PackageId packageId = eslClient.createPackage( superDuperPackage);

If you run that class again, you will now see the package ID printed to the output window in Visual Studio.


The Code

This segment will breakdown the code section by section. You can get the full sample code from the Developer Community Code Share, here.

Access the Package

The first few lines define your connection information for OneSpan Sign.

private static String apiUrl = "https://sandbox.esignlive.com/api";
// USE https://apps.esignlive.com/api FOR PRODUCTION
private static String apiKey = "YOUR_API_KEY";

Be sure to put your API_KEY in place of the placeholder.

The first step is to connect to OneSpan Sign using your connection info, from above.

EslClient eslClient = new EslClient(apiKey, apiUrl);

Next, a PackageId object is created using the Package ID you got from your URL (or package creation C# class), above. Then, you will use that PackageId object to grab your previously sent package from the OneSpan Sign client.

PackageId packageId = new PackageId("YOUR_PACKAGE_ID");
DocumentPackage sentPackage = eslClient.GetPackage(packageId);

Check the Status

Now that you have access to the document package, you can check your package to see what the package status is. The possible values are ARCHIVED, COMPLETED, DECLINED, DRAFT, EXPIRED, OPTED_OUT, and SENT. Print the status to the Debug output window.

DocumentPackageStatus packageStatus = sentPackage.Status;
Debug.WriteLine("Package Status: " + packageStatus);

Next, check the signing status of the package. The possible values for this one are ARCHIVED, CANCELED, COMPLETE, DECLINED, EXPIRED, INACTIVE, OPTED_OUT, COMPLETED, and SIGNING_PENDING. Write this to the Debug output window, as well.

SigningStatus signingStatus = eslClient.GetSigningStatus(packageId,null,null);
Debug.WriteLine("Signing Status: " + signingStatus);

Download the Files

For the last part, you will check to see if the package is complete. If it is, the zip file of all documents will be downloaded, as well as the evidence summary. After each step, write to the Debug output so that you know the event happened when you test the class in the next step.

if (signingStatus.ToString() == "SIGNING_PENDING")
   Debug.WriteLine("Cannot Download: Signing not complete");
   byte[] zipContent = eslClient.DownloadZippedDocuments(packageId);
                   	+ "/package-documents.zip", zipContent);
   Debug.WriteLine("Document Zip File Downloaded");
   byte[] evidenceContent = eslClient.DownloadEvidenceSummary(packageId);
                   	+ "/evidence-summary.pdf", evidenceContent);
   Debug.WriteLine("Evidence Summary Downloaded");

Running the Code

Execute your C# class by clicking the Start button from the toolbar.

If you have not yet signed your package, your Output should look like the following:


After signing your package, you will get the following in your Output window:


If you now browse to the location where you saved your files (if you used the code above and are in Debug mode, they’ll be in the Debug folder inside your project, in your file system), you will see that your files were successfully downloaded.


Get the Code