---
updatedAt: 2026-01-21T17:26:15.000Z
agentTools:
  projectIndex: https://developer.fastspring.com/llms.txt
---

# License Keys

Provide a license key to customers after a successful purchase. This can appear on the completion page, email receipt, or account management portal following a successful purchase.

# Generate a License

1. Navigate to the product’s details page. In the Fulfillments section, click **Edit**.
2. Click **+ Add Fulfillment** > **Generate a License**.
3. Click **Choose a Generator…** to select the type of license generator.
4. Click **Next**.

The following steps will vary depending on what type of license generator you selected.

# Pre-Defined List

If you have an existing list of license keys, paste them in the Pre-Defined List field, and control the number of license keys per quantity purchased. Follow the instructions below to further customize the format and behavior of the pre-defined list. 

1. Below **License Format**, select whether you want to limit each Licence Key to a single line. If a single key can contain carriage returns, select **Multi-Line License**.

2. Below **License Quantity Behavior**, select whether FastSpring issues a separate license key for each quantity purchased, or a single license key per purchase, regardless of the quantity.

![](https://fastspring.com/wp-content/uploads/2022/02/image-44-1024x720.png)

3. Below **Step 2: Enter Licenses**, enter a list of License Keys that follow the criteria you configured above.
4. Click **Create**. The License Configuration dialog displays the number of licenses available based on what you entered in the editor.

## Advanced Configuration

In the License List configuration page of each type of License Key, you can apply advanced configurations to customize your License Key.

![](https://fastspring.com/wp-content/uploads/2022/02/image-45-1024x417.png)

1. **License Generator Name:** Enter an internal-facing name for your license generator.
2. **Ordered List:** Select this checkbox to ensure FastSpring issues the License Keys in the order in which you pasted them. If you do not select this checkbox, FastSpring may issue license keys from your list in any sequence.
3. **Custom Template Key:** Enter an identifier to assign more than one license generator to the product. This enables you to separately identify them in a template, and use the identifier to control where the License Key is placed.

# Script

You can supply a custom PHP script or JavaScript snippet for FastSpring to use when generating license keys. As you are applying changes, use the **Test** button at the top, right corner of the page to test your changes.

![](https://fastspring.com/wp-content/uploads/2022/02/image-46-1024x453.png)

This is not a full implementation of PHP. Some features might be unavailable.

1. In the **Output Format** drop-down, select the type of license key format that the script generates.
   * **Single-Line License (Quantity Based):** One license key per quantity purchased. Separate license keys by a line feed character (or a carriage return + line feed character).
   * **Multi-Line License (Quantity Based):** One license key per quantity purchased. Separate additional license keys with an empty line or a return + line feed carrier.
   * **Single License Only:** One license key regardless of the quantity purchased by the customer. The license key may contain any type of character and may span multiple lines.
   * **Single File Based License - MIME 1.0:** Binary data as a multipart, mixed MIME 1.0 file. Customers can download the file via a URL provided to them by FastSpring.
2. In the **License Name** field, click the drop-down selector and select which data point from the order details the script factors into license key generation.
   * **Not Name Based:** The license key generation does not take any name into consideration.
   * **Email Address:** The script bases the license keys on the customer’s email address as entered during the purchase process.
   * **Person Name:** The script bases the license keys on the customer’s full name as entered during the purchase process.
3. In the **Script Type** drop-down, specify whether you are supplying a PHP script or a JavaScript snippet.
4. Click **Create**. The General settings for your fulfillment are saved. You can edit the Output Format or License Name on the General page.
5. In the **Script Source Code**, enter the custom License Key Generation Code.
6. **Save** your changes.

The new fulfillment appears in the product details page. 

## PHP Script Parameters

* **$name**: The customer’s full name, company name, or email address, depending on License Name and the customer’s choice.
* **$name\_unicode**: Array of Unicode codepoints (integers) representing name.
* **$company:** Customer’s company, if entered.
* **$company\_unicode:** Array of Unicode codepoints (integers) representing a company.
* **$email:** Customer’s email address.
* **$quantity:** It is the responsibility of the script to determine how quantity is handled. If you return multiple licenses, all licenses will be assigned to the order.
* **$product:** The product name.
* **$reference:** The order reference.
* **$subscription**: The subscription ID.
* **$tags**: Map of tag names to tag quantities. Tag names are defined at the product level and allow license generation to be based on other products in an order. Tag values are always 1 or greater.
* **$referrer**: A custom value passed into the order process via the URL

## JavaScript Parameters

The following lists the order parameters available for use in your JavaScript code.

* **name:** This may be the customer’s full name, company name, or email address, depending on License Name and the customer’s choice.
* **company:** Customer’s company, if entered.
* **email:** Customer’s email address.
* **quantity:** It is the responsibility of the script to determine how quantity is handled. If you return multiple licenses, all licenses will be assigned to the order.
* **product**: The product name.
* **reference**: The order’s reference or ID.
* **subscription:** The subscription reference or ID.
* **tags**: Map of tag names to tag quantities. Tag names are defined at the product level and allow license generation to be based on other products in an order. Tag values are always 1 or greater.
* **referrer:** A custom value passed into the order process via the URL.

## Special JavaScript Functions

The following helper functions are available for use in your JavaScript license generation scripts.

* **sha1HexDigest(arg1):** Returns the SHA-1 hex digest of the input string.
* **md5HexDigest(arg1):** Returns the MD5 hex digest of the input string.
* **aes(arg1, arg2):** Encrypts the string (`arg2`) using a 128-bit AES key (`arg1`) in Base64. Returns a Base64 string.
* **aesDecrypt(arg1, arg2):** Decrypts the string (`arg2`) using a 128-bit AES key (`arg1`) in Base64. Returns a plain string.
* **dsaSign(arg1, arg2):** Signs the input string (`arg2`) using a 512- or 1024-byte DSA key (`arg1`) in PEM format. Returns a Base64 string.
* **base64(arg1):** Converts the input string to Base64. Returns a Base64 string.
* **base64Decode(arg1):** Decodes a Base64-encoded string. Returns a plain string.
* **rsaSha512Sign(arg1, arg2):** Signs data (`arg2`) using a private key (`arg1`) in PEM format with SHA-512 and RSA. Returns a Base64 string.
* **httpGet(url, \[params]):** Executes an HTTP GET request. Example:
  ```js
  var response = httpGet("http://www.example.com", { "ipAddress": ipAddress });
  response.statusCode;
  response.body;
  ```
* **httpPost(url, \[params]):** Executes an HTTP POST request. Example:
  ```js
  var response = httpPost("http://www.example.com", { "ipAddress": ipAddress });
  response.statusCode;
  response.body;
  ```
* **http(options):** Executes a customizable HTTP request. Example:
  ```js
  var response = http({
   type: "POST",
   url: "http://www.example.com",
   username: "tom",
   password: "secret",
   params: { "ipAddress": ipAddress }
  });
  response.statusCode;
  response.body;
  ```

# Remote Server Request

Remote server request fulfillments contact a remote server to create a new, custom license key while FastSpring processes the order. After receiving the license key, FastSpring provides the customer with the license key and saves it as part of the order record. 

![](https://fastspring.com/wp-content/uploads/2022/02/image-47-1024x548.png)

1. In the **URL** field, enter the URL or endpoint of your external server. FastSpring will access the URL during order processing to generate a license key.
   * The URL must begin with `http://` or `https://`.
2. In the Method drop-down, select the **POST** or **GET** method for the HTTP request to your external server. We recommend using POST.
3. If you selected **POST**, select the type of character encoding for the post body in the Post Encoding field below.
   * This step does not apply for the GET method, as the URL includes the transaction data as URL parameters instead of transmitting the information as an HTTP message body.
4. In the **Output Format** drop-down, select the type of license format that FastSpring should expect from the remote server.
   * **Single-Line License (Quantity Based):** The script generates one license key per quantity purchased. License keys generated by the script may be separated by a line feed character (or a carriage return + line feed character).
   * **Multi-Line License (Quantity Based):** The script generates one license key per quantity purchased. However, license keys may be separated by an empty line. The empty line separator should only contain a line feed character (or a carriage return + line feed character).
   * **Single License Only:** The script generates one license key regardless of the quantity purchased by the customer. The license key may contain any type of character and may span multiple lines.
   * **Single File Based License / MIME 1.0:** This advanced option supports binary data as a multipart/mixed MIME 1.0 file. Customers can download the file via a URL provided to them by FastSpring. See [MIME 1.0 Output Format](https://developer.fastspring.com/docs/mime-1-0-license-output-format) for more information.
5. Click **Create**.

Access the Security, Parameters, and Advanced subpages to further customize the remote server request.

![](https://fastspring.com/wp-content/uploads/2022/02/image-48-1024x543.png)

## Security

Secure the License Key generation process and prevent fraudulent requests from being accepted by your server. Use the unique, 32-character private key to verify the authenticity of requests originating from your FastSpring Store.

![](https://fastspring.com/wp-content/uploads/2022/02/image-49-1024x361.png)\
In the **Authentication** section, enter a username and password. FastSpring passes the credentials specified here to the remote server with each license key generation request. You can configure the script to ignore requests that do not include a valid login.

## Parameters

The Parameters subpage provides a list of order parameters that you can include in the URL. FastSpring passes these data points (such as transaction details or customer data) to the remote server for use in license key generation. You can customize up to 10 custom parameters on this page.

## Advanced

Apply advanced configurations listed below to customize your license key.

* **License Generator Name:** Enter an internal-facing name for your license generator.
* **Ordered List:** Select this checkbox to ensure FastSpring issues the license keys in the order in which you entered them.
* **Custom Template Key:** Enter an identifier to assign more than one license generator to the product. This enables you to separately identify them in a template, and use the identifier to control where the license key is placed.

# CocoaFob

Specify a DSA Private Key to generate license keys through CocoaFob. CocoaFob is an advanced option that may be beneficial for Mac or other Objective-C applications.

1. In the **Product Name** field, enter the name of the product. This becomes part of the registration source string.

2. In the **DSA Private Key** field, enter the private key used to generate licenses. The value you enter should begin with —–BEGIN DSA PRIVATE KEY—– and should end with —–END DSA PRIVATE KEY—–.

3. Click **Create**.

![](https://fastspring.com/wp-content/uploads/2022/02/image-50-1024x397.png)

4. In the **License Source Template** field, specify the license source template that your application will use to verify licenses.
5. On the **Advanced** page, in the **License Name** field, click the drop-down and select which data point from the order details to factor into license key generation.

![](https://fastspring.com/wp-content/uploads/2022/02/image-51-1024x431.png)

* **Not Name Based:** The license key generation does not take any name into consideration.
* **Email Address:** The implementation bases the license keys on the email address entered at checkout.
* **Person Name:** The implementation bases the license keys on the full name entered at checkout.

6. Optionally, select the **Generate Multiple Licenses** checkbox for FastSpring to generate a separate license key for each quantity purchased in the order. If you do not select this checkbox, FastSpring generates one license key per product, regardless of the quantity purchased.

7. In the **Custom Template Key** field, enter an identifier to assign more than one license generator to the product. This enables you to separately identify them in a template, and use the identifier to control where the License Key is placed.

8. **Save** your changes.

# Aquatic Prime

Using AquaticPrime instructs FastSpring to generate a license file that is compatible with the third-party AquaticPrime algorithm.

For more information, see <https://github.com/bdrister/AquaticPrime>.

1. In the **Product Name** field, enter the name of the associated product. FastSpring will use this as the “product” key value in the license file.
2. In the **Full License Filename** field, enter the name of the license you would like to provide to customers. Include the file extension.
3. In the **Public Key** field, enter the public key for use in the license key generation.
4. In the **Private Key** field, enter the private key for use in validating license files generated with the public key.
5. Click **Create**. The Third Party Generator page appears.\
   ![](https://fastspring.com/wp-content/uploads/2022/02/image-52-1024x951.png)
6. In the License Name field, select which data point the from the order to use in the `#{name}` variable when generating a license.
   * **Not Name Based:** The `#{name}` variable is null.
   * **Email Address:** The `#{name}` variable contains the customer’s email address.
   * **Person Name:** The `#{name}` variable contains the customer’s full name, as entered at checkout.
7. Optionally, use the **MIME Type** field to override the default AquaticPrime file MIME type.
8. In the **Content** section, enter additional key/value pairs to include in the license output. Enter the key name in the **Name** column. In the **Value** column, enter the corresponding parameter to include in the license.
9. **Save** your fulfillment.

## Advanced Settings

![](https://fastspring.com/wp-content/uploads/2022/02/image-53-1024x356.png)

* **License Generator Name:** Enter an internal-facing name for your license generator.
* **Ordered List:** Select this checkbox to ensure FastSpring issues the License Keys in the order in which you pasted them. If you do not select this checkbox, FastSpring may issue license keys from your list in any sequence.
* **Custom Template Key:** Enter an identifier to assign more than one license generator to the product. This enables you to separately identify them in a template, and use the identifier to control where the License Key is placed.

# Software Passport

![](https://fastspring.com/wp-content/uploads/2022/02/image-54-1024x459.png)\
If you are already using Software Passport to protect your application, you can enter your Software Passport project settings in order for FastSpring to generate License Keys compatible with your project. Contact Support for more information.

1. In the **Encryption Template** field, enter the encryption template from your Software Passport project for the current product.
2. In the **Signature Level** field, click the drop-down and select the signature level used in your Software Passport project for the current product.
3. In the **Key Type / Version** field, click the drop-down and select the key type and version used by your Software Passport project for the current product.
4. Click **Create**. The General settings are saved, and an Advanced page becomes available.

## Advanced

![](https://fastspring.com/wp-content/uploads/2022/02/image-55-1024x516.png)

1. In the **License Name** field, select which data point should be factored into license key generation via the name variable:
   * **Not Name Based:** The license key generation does not take any name into consideration.
   * **Email Address:** The implementation bases the license keys on the email address entered at checkout.
   * **Person Name:** The implementation bases the license keys on the full name entered at checkout.
2. In the **License Name Modification** field, indicate whether or not to modify the customer’s license name, based on your selection above.
3. In the **License Quantity Behavior** field, select whether FastSpring issues a separate license key for each quantity purchased or a single license key per purchase, regardless of the quantity.
4. Optionally, use the **Custom Template Key** field to enter an identifier to assign more than one license generator to the product. This enables you to separately identify them in a template, and use the identifier to control where the License Key is placed.
5. **Save** your changes. The fulfillment appears in the Fulfillment section of the page.