Announcement:Materials and articles for ProductCart 5 can be found at our brand new support center.

Create an account to edit articles | See Formatting Syntax for Wiki syntax | We look forward to your contribution!

Generating a License for a Downloadable Product

Overview

This document describes how you can successfully build a license generator that interfaces with ProductCart’s Downloadable Products module. With the word “module” we are not referring to a separate set of files within ProductCart, but rather to all the features (and therefore the ASP source code, database table and fields, etc.) that refer to creating, managing, and selling digital goods with ProductCart. These features are included in all versions of ProductCart.

Skill Requirements

This topic is for Web developers. Non-technical users of ProductCart are encouraged to outsource this portion of the store setup to a third party that may help them custom program a license generation file that at the same times meets their licensing requirements, and correctly interfaces with ProductCart (Certified ProductCart Developers)

Why a License Generator

The Downloadable Product Module was built under the assumption that Downloadable Products may require a license to be delivered to the customer to unlock/install/use the product after it has been downloaded. The system also assumes that each Downloadable Product available for purchase on the store may need a different type of license (e.g. a software product may need a Serial Number to be delivered with the purchase; an eBook may need a User Name and a Password; etc.).

When you add or modify a Downloadable Product you can specify the name of the license file to be used to generate license information for that product.

Default License Generator

ProductCart includes a default License Generator that should be used as the starting point for creating custom license generating scripts. The following paragraph describes the ASP code that the file contains.

When hosted on the same Web server where the store is located, all license generators should be placed in a subdirectory of the pcadmin folder called licenses. On the Add/Modify Product pages, just enter the file name, not the path to the file. You can also host the license generator on a remote Web server. In that scenario, enter the full URL to the file (including the initial "http://").

The default license generator is the file myLicense.asp located in the folder “pcadmin/licenses”. The code is heavily commented to help you understand how a license is being generated. The section of the code designed to host your license generating script is the one included between the comments:

'BEGIN LICENSE GENERATOR CODE
...
'END OF LICENSE GENERATOR CODE

You should not need to edit the rest of the code.

If you open the file using Notepad or your favorite HTML editor you will notice that the top part of the code sets the license variables. Then, these variables are assigned values using the license generating scripts that you will create. The default License Generator contains some sample scripts that return random numeric or alphanumeric strings.

You don’t need to assign a value to every one of the 5 license key variables. One or more can be empty. For example, if you only need three pieces of information, you would leave the last two variables blank, using the code:

Tn4=""
Tn5=""

The bottom part of the code looks at the quantity ordered for the selected Downloadable Product and calls the license generating function as many times as needed. So if a customer ordered 3 units of a software application that requires a Serial Number to be delivered with the download link, ProductCart would generate 3 Serial Numbers and include all of them in the order details and order confirmation e-mail when the order is processed.

Testing a Custom License Generator

You can use ProductCart to test your custom License Generator. Right after you have added a Downloadable Product to the store, click on Modify this product again on the confirmation page, or select Details after locating the product through the search feature.

You will notice that compared to the Add New Product page, the form now contains a Test License Generator button located towards the bottom of the page. When you click on it, ProductCart will pass sample order information to the license generator, and return the results in a pop-up window.

For example, a test performed using the default license generator returned the following results in the Test License Generator pop-up window:

Demo Data:
Order ID: #5236
Order Date: 11/23/2003
Process Date: 11/23/2003
Customer ID: 125
Product ID: 406
Quantity: 1
Product SKU: EIBM1257A

Returns:
Order ID: #5236
Product ID: 406
Temporary User Name: 653753
Temporary Password: dn6t346w1j7z
License Key: JHsCEPsU9nt9F4t00i77f27v
Serial Number: A57YgM8BB3VU2HV8cPVa2nWd
Winning Lottery Numbers: cLwvIi4Y1240JO471m58j3Nz

When Licenses are Generated

Licenses are generated when the order status is updated to Processed (either manually or automatically, at the time the order placed or later, depending on the payment settings).

License information is delivered to customers in two ways:

  • Through the order confirmation e-mail (unless you instructed ProductCart not to send a confirmation e-mail upon processing the order).
  • Through the View Previous Orders section of the Customer Service area of the storefront.

QR Code
QR Code Generating a License for a Downloadable Product (generated for current page)