Developing Applications Using The SoftwareShield System > Creating Licensing Solutions > Available License Models > Pay-Per-Use (of a feature) License Model

Pay-Per-Use (of a feature) License Model


This model is an extension of the Pay-Per-Feature model and allows you to deliver software for which a user must individually pay for each use of a feature. Features can be as simple as the functionality behind a button click or the ability to dynamically load a binary module. In this model features are completely independent from one another and the uses for each of them can be individually purchased and activated.

Overview - How to Integrate the Pay-Per-Use (of a feature) License Model Into Your Application

In this model, you will use a General Use Authorization Definition for each of the pay-per-use protected features. You will interpret the stored parameter value in the definition as the number of (pre) paid uses remaining for that feature. The maximum number of features you can protect with the pay-per-use (of a feature) license model is 64. The maximum number of uses that a single feature can contain at any one time is 65,536.

  1. The first step is to design the license.  Ensure that your license has the necessary Authorization Definitions built into it. Create a number of General Use Authorization Definitions - one for each feature that is pay-per-use.  Be sure that the definition uses a parameter value, as this will serve as the storage location for the number of paid uses remaining.  You may wish to "pre-set" the license with a number of "complimentary uses" of your features to let the user understand the process and how great your features are.   

  2. Once you are satisfied with your license, compile a distributed copy of it. The distributed copy is encrypted and compressed and only contains absolutely necessary information for the enforcement of your license. Place a copy of this distributed license in your applications directory. If you have decided to use steganographic alias files, make sure that they are also in the application directory. Have a look at the programming notes file that the SoftwareShield License Manager creates for your specific license. This will make your programming a little easier by supplying you with the code you will need to invoke the start up event. Please see Deploying the License for Your Application for more detailed information about deploying your license.

  3. Next, in your programs startup event (main form load etc.) create an instance of the ClientProtector object and immediately call its StartUp function. You will have to pass specific parameters such as the license name, main license file password, and the finger print options code - but this code will have been already written for your convenience when you compiled your license - just look in the programming notes file created by the SoftwareShield License Manager. Have a look at the exact details of the StartUp function for more information on making this call.

  4. Now, once the ClientProtector StartUp call returns and the license state is as you expect it to be - determine which features (if any) are activated (have unused uses remaining):

    1. Call GetAuthorizationDetails or GetAuthorizationDetailsEx for the General Use Authorization Definition(s) you have defined to hold the state of your features.

    2. Interpret the stored parameter value of the definition to determine which features (if any) are have unused uses remaining.  The stored parameter value represents that number for the feature associated with the definition you are inspecting.

  5. When the user "uses" your protected feature, you must decrement the uses remaining count for that feature. To do this, call GetAuthorizationDetails or GetAuthorizationDetailsEx, decrement the count of the stored parameter and then call SetAuthorizationDetails or SetAuthorizationDetailsEx being sure to pass the new value.  If the value reaches zero - be sure to update your UI to reflect that there are no more uses remaining.

  6. To Activate the users license and add uses to your protected features you will have to construct a numeric parameter that represents the number of new uses they have purchased from you.  

  7. You must be careful not to destroy any remaining unused uses when the user activates a new Activation Code.  The successful activation of a General Use Authorization Definition always overwrites any existing stored parameter value with the parameter value embedded inside the Activation Code.  To be sure not to destroy any unused uses, before any call to input a new Activation Code do the following:

    1. Call GetAuthorizationDetails or GetAuthorizationDetailsEx to temporarily store the unused uses in memory for each protected feature.

    2. Call SetAuthorizationDetails or SetAuthorizationDetailsEx to set the Activated state of each definition to false.

    3. Allow the Activation Code input to proceed. If successful, check the Activated state of each definition, if any one is set now true, the definition was activated and the stored parameter value is the number of uses to "add".  In this case, add the new number in the definition to the number of unused uses you previously stored and re-set them into the definition using SetAuthorizationDetails or SetAuthorizationDetailsEx.

    4. You may (optionally) need to re-set the activated state in the definitions depending on how your program interprets these values elsewhere.
       

Related Topics