Saas licensing

HiI am trying to find an example for simply leasing our software for say 1 year. Does anyone have a php script I can use on my server (php is foreign to me) i just need to set the expiry date to now + 1 year when a user activates.

I also need to check if a custom license field ExpiryDate is valid somehow. Seems simple but why are there no examples?

I would ideally like to capture the users email and add that to the license details as well.

Hope someone can help.

regardsMark

If PHP is foreign to you then you'll need to hire a developer to handle this for you, to debug it, and to work out all the kinks.

>> "I also need to check if a custom license field ExpiryDate is valid somehow. Seems simple but why are there no examples?"

We have numerous examples. In a language like C# it's literally 2 lines of code:

string expires = GetFeatureValue("subscription_expires", null);bool notExpired = expires == null ? false : IsDateValid(expires, TA_DateCheckFlags.TA_HAS_NOT_EXPIRED);

This is covered in the custom license fields article: http://wyday.com/limelm/help/license-features/

That code, in a slightly different form, is in the article. See: Example #2: SaaS or time limited restrictions

>> "I would ideally like to capture the users email and add that to the license details as well."

Do that when the customer buys your software: http://wyday.com/limelm/help/how-to-generate-product-keys-after-order/

Hi SamThe c# or delphi code is not such an issue. If we use the api credentials directly in the software it is insecure etc so we were told to use a serverside php script to handle the process of setting the expire date.

Our purchase process is completely separate. The purchase process simply delivers an activation code to the user so he can activate the software. When he activates the software we then want to set the expiry date for his license to 1year out.

This is the most basic use of the LimeLM software and there are no examples (in php).

This example Example #2: SaaS or time limited restrictions, has nothing to do with setting the license expiry date. Which is odd considering the title of the article. It only shows an example for limiting updates. Which is more complicated I am sure than settings a license expiry.

I already hire a programmer to write the software I dont really want to hire another one for a php script.

I would of thought this would be one of the simplest examples you could give out to users of LimeLM.

So if this cannot be resolved I will be looking around for other solutions.

regardsMark

Hey Mark,

>> "So if this cannot be resolved I will be looking around for other solutions."

We try to answer questions with as much specificity as the question asks. You're asking generically how to do a thing (set dates: user the web API & custom license fields, read date: use GetFeatureValue() ). If you want more specificity you need to ask us what doesn't make sense.

Unfortunately we don't have the resources to respond with a novel to every question just so we can cover every possible misunderstanding. You need to tell us what you do and don't understand.

>> "I would of thought this would be one of the simplest examples you could give out to users of LimeLM."

Right, and we do. Download the web API for multiple examples of using the web API. Read the articles to see other smaller examples. And for 1-liners (like changing a custom license field, we just mention the function you need to use and presume that's enough information).

Set values: use the web API. Which API function? Well, it depends on your needs. Do you want to set the expiration date when you generate the product key?

Web API function: http://wyday.com/limelm/help/api/limelm.pkey.generate/PHP function in LimeLM.php that calls that web API function: LimeLM::GeneratePKeys()

How do you set the custom license field? Well, it's a 1-liner (which I've exploded into multiple lines below), hence no "example" (see PaymentSetting.php, specifically the SendPKeys() function to see how the function is called, and the response is parsed).

$one_year_from_now = date('Y-m-d H:i:s', strtotime('+1 year'));

$num_keys = 1;$num_acts = 1;$email = 'your@example.com';$field_names = array('subscription_expires');$field_vals = array($one_year_from_now);$xml_response = LimeLM::GeneratePKeys('your version id', $num_keys, $num_acts, $email, $field_names, $field_vals);

And then, of course, you would need to parse the "$xml_reponse" to see if it actually succeeded and to see what the product keys are. How would you do that? See PaymentSettings.php for an exact example of how to do that.

How would you know how to generate a date 1-year from now (like shown above) without an example? It depends on the language you're using -- use Google, or Bing and you'll find thousands upon thousands of examples in your language of preference.

OK, so let's say you want to set the custom license field later. After you've already generated product keys. How do you do it? Well, again, the web API: http://wyday.com/limelm/help/api/

Which function in particular: http://wyday.com/limelm/help/api/limelm.pkey.setDetails/

How do I know that? http://wyday.com/limelm/help/license-features/#saas

I know you keep saying that article is unhelpful, but it's literally saying everything I'm saying here. You really need to tell me what is confusing you. Here's how you would use that function in PHP:

$pkey_id = '123'; // Note: NOT a product key, but the product key ID. How do you get the product key ID from the product key? Well, there's a function for that: http://wyday.com/limelm/help/api/limelm.pkey.getID/

// We're not changing the number of activations// or emails$num_acts = null;$email = null;

$one_year_from_now = date('Y-m-d H:i:s', strtotime('+1 year'));$field_names = array('subscription_expires');$field_vals = array($one_year_from_now);

$xml_response = LimeLM::SetPKeyDetails($pkey_id, $num_acts, $email, $field_names, $field_vals);

Again, you'll have to parse the response. Again, see PaymentSettings.php for an example of parsing the XML. Again, this is a 1-liner that I've exploded to multiple lines.

So how do you set the date when the customer activates? You don't. You can't. Why? Because there's no way to "cleanly" do that (I can get into this in-depth if you want: it's complicated).

So what do you do? You have some other event that set the date. Like what? Like the customer purchasing your software. What else? A customer renewing their subscription. What functions do I call? See above.

If you have questions or if any of this is not making sense then you need to tell me exactly what is confusing you. I tried to write a novel to answer all of your questions, but honestly, I have no idea what makes sense and what doesn't make sense unless you tell me.

HiThanks for your reply.

What we do now is the following:

1) Customer downloads software and trials for x days. He likes software so purchases via website and he gets an activation key delivered. He activates software for lifetime use.

What we would like to do is.

2) Customer downloads software and trials for x days. He likes software so purchases via website and he gets an activation key delivered. Now it is only a yearly license. He activates software for 1 year use.

The purchase process is pretty much fixed and we cannot control generating product keys. Which is why we bulk export them from the dashboard and deliver them on purchase. We use a third party shopping cart/payment processor.

We thought we could set the 1 year date when activating but you say we cannot now. We cannot do it when generating via purchase either so what can we do?

We can generate webhooks from the shopping platform, could that work?

regardsMark

The third party shopping cart we use is Shopify which has an api. Are there any examples of using shopify to generate keys on the fly after purchase which might be another route?

Yes, using webhooks is the route to take.

See this article to learn how to create the webhooks: https://help.shopify.com/manual/sell-online/notifications/webhooks

See this article about the actual code you'll need to use to verify the webhook is coming from Shopify: https://help.shopify.com/api/tutorials/webhooks

Hi WyattWhat about the LimeLM side of things? What info do i need to send to LimeLM in the webhook to generate a new key, add an email address and set an expiry date?

The point of the webhook is that Shopify contacts a script on your website after an action has happened (for example, a customer buys your software). The script is where you verify the webhook is valid (see shopify's exmaples in the link I gave you).

And then you also generate the product key in that script as well. How do you do it? Well, again see my previous post, and our extensive documentation and examples.

Oh a script again.

Can you answer this one?We thought we could set the 1 year date when activating but you say we cannot now. Why is this?

How is the activation code displayed to the customer in Shopify?

Currently the method for delivering keys is working well so we would not ideally want to change this unless it was for a more reliable method.

You can always set the "default value" for the custom license field to be "the date the key was created" plus/minus X "days/weeks/months/years".

Of course you still need to create the keys on order. And you do that in Shopify using webhooks. We don't currently have a pre-written example for Shopify. If you don't want to write it yourself (based on the links and examples I've given you) then I would recommend switching to FastSpring. Have a pre-written example: http://wyday.com/limelm/help/automate-license-generation-with-fastspring/