Support forum
wyDay blog
wyDay Home

SaaS and time-limited licensing

In this article you'll learn how to use TurboActivate in tandem with the LimeLM web-api for Software as a Service (SaaS) licensing or permanent licenses with time-limited maintenance and servicing contracts.

We'll illustrate this by showing a real life example. You can get the complete "limit-updates" code in the (requires login, signup here).

And if you're using another language then use the web API reference to help you write the necessary code.

Defining the problem

Let's say you offer your customers a permanent license but you charge annually for software updates. The problem is such: how do you limit the updates?

Step 1: Add an "update_expires" field

As we described in the custom license fields article, the first step is to click the "Custom license fields" link on your dashboard or on the sidebar:

Version Sidebar

Then create a new field "update_expires" with the type "Date / Time". Also, make sure the "Required" and "Readable form your app" checkboxes are checked.

Adding a new custom license field

Step 2: Verify "update_expires" using the web API

In this example, all of the work to verify that the user has permission to download the updates will be done server-side. That is, you'll send the user's product key to your server and the server will query LimeLM to get the "update_expires" field value associated with the product key.

Client side

The first step is to send the product key to the server along with the request to download the update.

We're going to assume you're using wyBuild to build and deliver your updates, but the same concept can be applied no matter what updater program you use. Add 2 download sites to wyBuild: 1 for your server file and 1 for the updates file.

Notice that update site passes the %file% and %urlargs% variables to be parsed by the "index.php" file.

Limit updates in wyBuild

When you run wyUpdate.exe make sure you pass the product key to wyUpdate via the -urlargs commandline switch. You can get the current product key using the GetPKey() function in TurboActivate. Here's a simple example of what it should look like:

wyUpdate.exe -urlargs:"PRODUCT-KEY-GOES-HERE"

Or, if you're using the AutomaticUpdater control, use the wyUpdateCommandline property:

automaticUpdater1.wyUpdateCommandline = "-urlargs:\"" + TurboActivate.GetPKey() + "\"";

Then when wyUpdate checks for updates it will download the server file (*.wys file) unencumbered. And if there are updates available wyUpdate will try to download the file by passing the requested file along with the product key to the verification script on the server. The script then validates the details and either sends the file or rejects the user.

Server side

There are 4 steps to limiting updates server-side:

  1. Convert the product key to a product key ID using the limelm.pkey.getID API function.

  2. Get the field values of the product key using the limelm.pkey.getDetails API function.

  3. Verifying the "update_expires" field value is a date later than today.

  4. Deliver the update file requested OR throw an error (403 error code).

If you're using PHP or ASP.NET (C# or VB.NET) then you don't have to write this yourself. Just use the "\PHP\limit-updates\index.php" file or the "limit-updates.aspx" file for ASP.NET. Of course you'll need to set your API key and version ID in the code before you can use them on your site.