Support forum
Wyatt Says...
wyDay Home

Automate license generation with FastSpring

FastSpringThis article will tell you how to sign up and configure FastSpring to automatically generate product keys and email them to your customers after they purchase your software.

Step 1. Signup for LimeLM, download the Web API pack

If you haven't already signed up for LimeLM then sign up now. All plans have a 30-day free trial. Or, if you're just putting your toes in the water, there's even a free plan that has no time limit and doesn't require a credit card.

After you've created your account download the LimeLM Web API pack. This zip file contains (among other things) the PHP script you'll be pasting into your FastSpring account.

Step 2: Create a product within LimeLM & add TurboActivate to your app

After you've signed up with LimeLM you'll need to create a product and add TurboActivate to your app. Read the "Getting started with LimeLM" article to learn how to do this.

Step 3. Getting your API key

Now that you've added a product within LimeLM and added TurboActivate to your app you're ready to setup your FastSpring payment form to automatically generate and send product keys to your new customers. This payment form will be using to the LimeLM API to generate product keys so you'll need to copy your LimeLM API key from your settings page.

Step 4. Getting the Version ID

You can get the version ID by examining the URL in your browser. For instance, from the URL you can see the version ID is 100. (Note: The Version ID is not the Version GUID).

Step 5. Signup for FastSpring

If you haven't already signed up for FastSpring you can do it now.

Step 6. Configuring FastSpring

Now that you have both a LimeLM account and a FastSpring account you can set configure FastSpring to generate product keys after a customer has ordered your software.

a. Create a new product (or select an existing one)

After logging into FastSpring, click "Products and Pages" in your FastSpring dashboard:

FastSpring dashboard

Click the product you want to generate product keys for (or create a new product). On your product's page click the "Add" link next to the "Fulfillment Actions" text:

Add fulfillment action

b. License fulfillment

Click the "Licenses" tab at the top of the screen, select the "Script (PHP or JavaScript)" option, then click "Next":

Add fulfillment action

Choose the output format as "Plain Text, Single-Line License", Set the "License Name Type" to "Email Address", and set the "Script Type" to "PHP" then click the "Create" button:

New license fulfillment action

After clicking "Create" you'll be brought to a page that asks you for the PHP code to generate licenses. You can find this code after you've extracted the LimeLM Web API pack you downloaded in "Step 1" of this tutorial. Open the file "FastSpring-PHP-Code.txt" found in the "PHP\FastSpring" folder. Copy the code and paste it into the textbox on FastSpring:

Paste the "FastSpring-PHP-Code.txt" code

In the code you just pasted change the $api_key and $version_id variables with the values of the API key (see Step 3) and the version id you'll be creating product keys for (see Step 4).

If you're setting custom license field values for the product key then you can uncomment the $feature_names and $feature_values variables add values to the arrays. For example:

//TODO: Use any custom license field values here
$feature_names = array('update_expires', 'another field name');
$feature_values = array('2012-06-25', 'another value');

Now you're ready to test to see if everything works. Click the "Run Test" link on the page.

Click Run Test

After a few seconds FastSpring will show you the result of the test. If the license generation was successful you'll see a product key in the "Output" and "Licenses Captured" boxes:

Test results

Also, in your LimeLM dashboard you'll see the same license:

Test results

Now that the product key generates successfully click the "Close" link in the "Actions" box on the test page. This will bring you back to the script configuration page. Click "Save" in this page to save your changes. Your next step is "c. Email fulfillment".

Not seeing the product key?

If there's no license key and you are instead seeing a blank line or an error then something went wrong. To debug the problem click the "Close" link in the "Actions" box (on the right hand side of the test page). This will bring you back to the script configuration page.

Scroll down to the bottom of the source code text box and you'll notice 2 lines that say "// Uncomment the next line [...]". Uncomment the 2 "error output" lines like this:

        // Uncomment the next line to see the error LimeLM is giving you.
        echo $jObj->message;
catch (Exception $e)
    // Uncomment the next line to see the exception.
    echo 'Failure: '.$e->getMessage();

After uncommenting those 2 lines click the "Run Test" link again. Now, instead of a product key you'll see a description of the error. Fix whatever it says is wrong, comment those "error output" lines again, and run the test once more. Now the product key should appear.

Click the "Save" link to go back to your product's main configuration page.

c. Email fulfillment

After clicking "Save" on your script configuration page you'll be brought back to your product configuration page. Now we'll be adding an "Email fulfillment" by first clicking the "Add" link again next to the "Fulfillment Actions" text:

Add fulfillment action

Select the "Email / Web Notification" and click the "Next" button:

Add email fulfillment action

In the "Email Subject" textbox paste the following line:

Your #{orderItem.display} product key

In the "Email Text Contents" textbox paste the following block of text:


    Thank you for your order. Your product key is:


This product key is licensed for #{orderItem.quantity} <choose><when test="#{orderItem.quantity eq 1}">user</when><otherwise>users</otherwise></choose> of #{orderItem.display}.

Then click the "Create" button.

Step 7. Test the FastSpring order process

Now that you have both license & email fulfillment actions the product keys will be sent to your new customers the instant they place an order. When a new user orders your software the email they get will look something like this:

John Smith,

    Thank you for your order. Your product key is:


This product key is licensed for 2 users of AwesomeApp.