Setting custom field from FastSpring on subscription renewal

Hi

I need to use LimeLM together with FastSpring for a subscription based software package. Generation of licenses and custom fields is working fine using the info as per https://wyday.com/limelm/help/automate-license-generation-with-fastspring/

I need to add a fulfilment that applies to rebills in FastSpring, where the LimeLM API is called from FastSpring to update the custom field containing the license expiry date. This seems to be possible according to the following forum post:https://wyday.com/forum/t/2418/fastspring-limelm-yearly-subscription/#post-12267which refers to using limelm.pkey.setDetails (see https://wyday.com/limelm/help/api/limelm.pkey.setDetails/)

What I need to know is how to tell FastSpring to include the pkey_id for the subscription item (and/or how to get FastSpring to store it when a new subscription & product key is created).

Some more info:

The below script is working, with the pkey_id entered manually. I just need to know how to get FastSpring to know the pkey_id.

<?php//TODO: set your API key found in http://wyday.com/limelm/settings/$api_key = 'xxxxxxxxxxxxxxxxxxxxxxx';

//TODO: set the version id to generate & find keys for// the version id is found in the url. For example http://wyday.com/limelm/version/100/// the version id is 100.$version_id = 'xxxxxxxxx';

//Manual Product Key ID. Need to insert this automatically$pkey_id = 'xxxxxxxx';

//TODO: Use any feature values here$feature_names = array('ExpireDate');$feature_values = array(date('Y-m-d'));

$post_data = array( 'method' => 'limelm.pkey.setDetails', 'api_key' => $api_key, 'pkey_id' => $pkey_id, 'nojsoncallback' => 1, 'format' => 'json');

if ($feature_names !== null){ $post_data['feature_name'] = $feature_names; $post_data['feature_value'] = $feature_values;}

// urlencode $post_data$post_string = '';foreach ($post_data as $key => $value){ if (is_array($value)) { foreach ($value as $sub_value) { $post_string .= $key.'[]='.urlencode($sub_value).'&'; } } else $post_string .= $key.'='.urlencode($value).'&';}$post_string = rtrim($post_string, '& ');

$request = curl_init('https://wyday.com/limelm/api/rest/');curl_setopt($request, CURLOPT_HEADER, 0);curl_setopt($request, CURLOPT_ENCODING, "");curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);curl_setopt($request, CURLOPT_POSTFIELDS, $post_string);curl_setopt($request, CURLOPT_SSL_VERIFYPEER, TRUE);

try{ $jObj = json_decode(curl_exec($request));

if ($jObj->stat == 'ok') { foreach ($jObj->pkeys->pkey as $pkey) { echo $pkey->key."\r\n"; } } else { // 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();}?>

Hey Ivan,

This is actually more of a question to be directed at FastSpring so see if there's a way to associate data (like a product key) to subscriptions.

If not, then you can certainly do the reverse. Namely, use the FastSpring API (IPN) to get notifications of renewals and cancellations: https://github.com/FastSpring/fastspring-api

So, when you create the subscription you should associate with the product key the subscription id from FastSpring. You can store that information using custom license fields: https://wyday.com/limelm/help/license-features/