Product key Activation

Hai,

we already use LimeLM Product key option for last 2 years.Now we integrate payment option(money bookers) also. how to generate product key in our application itself.please help for below the option,In our application after payment is finished .How to generate the product key and also how to send the product key to client E-Mail in our applicationplease help with sample codes.

We show how to generate product keys after an order in the How to generate product keys after an order article.

What server language are you using (PHP, C#, etc.)?

Hai,

Am using server language is PHP. Already follow this How to generate product keys after an order article only.but payment only complete not generate the product key. what problem have please help me with sample code.

thanks.

In the PaymentSettings.php file you should set the "$debug" variable to true and set the "$debug_log" variable to a path that is writeable by PHP scripts. Then, run the order process again. After it fails, open the "payment_debug.log" file and read what the error was. Or paste it here and I'll help you from there.

Hai,

In the PaymentSettings.php file,

$debug=true;$debug_log = dirname(__FILE__).'/payment_debug.log';

payment_debug .log this files is not having the web api (php folder). run the payment.php file at time show the error is Debugging turned on--All actions will be logged to log file.how to solve this error and how to use payment_debug.log.please help me.

thanks,

hai

i will use that coding only for paymentsetting.php any change is need please update there...

paymentsetting.php

<?php//TODO: Set the following constants. All URLs must be publicly accessible.// See http://wyday.com/limelm/help/how-to-generate-product-keys-after-order/// to learn how to configure the payment form and set everything up.

//==== General Config ====

//TODO: disable debug & sandbox when you're using this on your live site.

// Enable debug logging$debug = true;$debug_log = dirname(__FILE__).'/payment_debug.log';

// Set any of the following 4 boolean values to either// true or false based on whether you're using that// particular payment method. "payment.php" automatically// shows or hides the payment method based on these boolean// values.

// If you set a payment setting to true then you'll also// have to configure the payment settings for that// particular payment method below.$UseAuthorizeNetCC = true;$UseAuthorizeNetBank = true;$UseMoneybookers = true;$UsePayPal = true;

// dollars, cents$AppPrice = array(1, 00);$Currency = 'USD';

// The currency symbol that the end-user will see.// If you're not using "$" then you should use// the HTML-entity equivalent of the symbol.// Your customers will see the symbol.

// = &euro;// = &pound;// = &yen;// etc.$CurrencySign = '$';

$CompanyName = 'VERTEX';$AppName = 'SPINSOFT';

// api key found in http://wyday.com/limelm/settings/$LimeLM_ApiKey = '<snip>';

// the version id is found in the url.// For example http://wyday.com/limelm/version/100/ the version id is '100'.$LimeLM_VersionID = '160';

// URL of the "paychecker.php" script.// This is where Moneybookers and PayPal orders are confirmed and processed.// If you're not using Moneybookers or PayPal then you don't have to set this.$CheckScript = 'http://example.com/buy/paychecker.php';

// Where the user can buy your products$BuyPage = 'http://example.com/buy/payment.php';

// Thank you page (once payment is made, user is sent to this page)$ThankYouPage = 'http://example.com/buy/pay-thankyou.php';

// The logo to display on the PayPal / Moneybookers checkout// this site must be HTTPS or it won't display.// Maximum size (PayPal): 150px (width) by 50px (height)// Maximum size (Moneybookers): 200px (width) by 50px (height)$YourLogo; // = 'https://example.com/buy/toplogo.png';

//==== Authorize.Net Config ====

// the API Login ID and Transaction Key must be replaced with valid values$AuthNetLogin = 'PASTE LOGIN HERE';$AuthNetTansKey = 'PASTE Transaction Key HERE';$AuthNetTest = false;

//==== PayPal Config ====

// Use PayPal Sandbox (set to false on your live server)$PayPalSandbox = false;

// Paypal Email$PayPalEmail = 'your@email.com';

//==== Moneybookers Config ====

// Your Moneybookers email$MBEmail = 'sudhavs86@gmail.com';

// Set the "Secret Word" in your Moneybookers account// on the "Merchant tools" page. Then set it here.$SecretWord = '<snip>';

function debug_log($message, $success, $end = false){ global $debug, $debug_log;

if (!$debug || !$debug_log) return;

// Timestamp $text = '['.date('m/d/Y g:i A').'] - '.(($success)?'SUCCESS :':'FAILURE :').$message. "\n";

if ($end) $text .= "\n------------------------------------------------------------------\n\n";

// Write to log $fp=fopen($debug_log, 'a'); fwrite($fp, $text); fclose($fp);}

function SendPKeys($quantity, $email, $first, $last){ //Note: we put LimeLM in this directory. Change it as needed. require('LimeLM.php');

global $LimeLM_VersionID, $LimeLM_ApiKey;

$errors = false;

// set your API key LimeLM::SetAPIKey($LimeLM_ApiKey);

try { // Generate the product key - set the number of activations using the quantity $xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email));

if ($xml['stat'] == 'ok') { foreach ($xml->pkeys->pkey as $pkey) { // add a newline if you're generating more than one key if ($product_keys) $product_keys .= "\r\n";

// set the product key $product_keys .= $pkey['key']."\r\n"; } } else //failure { // use the error code & message debug_log('Failed to generate product keys: ('.$xml->err['code'].') '.$xml->err['msg'],false); } } catch (Exception $e) { debug_log('Failed to generate product keys, caught exception: '.$e->getMessage(),false); }

if (empty($product_keys)) { // the product key didn't generate, don't send e-mail to the customer yet. $errors = true; }

// form the customer name $customerName = $first;

if (!empty($last)) // append the last name $customerName .= ' '.$last;

$emailBody = $customerName.',

Thank you for your order. Your product key is:

'.$product_keys.'

This product key is licensed for '.$quantity.( $quantity > 1 ? ' users' : ' user' ).' of '.$AppName.'.

Thank you,

'.$CompanyName;

if (!empty($product_keys)) { // Send Email to the buyer $emailSent = mail($email, 'Your '.$AppName.' product key', $emailBody,$headers); }

// generate an array you can insert into your database $new_order_info = array( 'quantity_licenses' => $quantity, 'pkey' => $product_keys, 'pkey_emailed' => $emailSent ? '1' : '0', // 0 = no, 1 = yes 'first_name' => $first, 'last_name' => $last, 'email' => $email );

//TODO: delete logging, or log to a safe location (not accessible to outside world) debug_log('TODO: Insert array into db: '."\r\n\r\n".print_r($new_order_info, true), true);

if (!$emailSent) { $errors = true; debug_log('Error sending product Email to '.$email.'.',false); }

LimeLM::CleanUp();}?>

thank you please help me...

You didn't set the $CheckScript, $BuyPage, or $ThankYouPage variables. These all must be set to your URLs. Also, if you're not using paypal or Authorize.NET then you should set $UsePayPal, $UseAuthorizeNetBank , and $UseAuthorizeNetCC all to false.

Hai

Now use for Paymentsetting.php coding is<?php//TODO: Set the following constants. All URLs must be publicly accessible.// See http://wyday.com/limelm/help/how-to-generate-product-keys-after-order/// to learn how to configure the payment form and set everything up.

//==== General Config ====

//TODO: disable debug & sandbox when you're using this on your live site.

// Enable debug logging$debug = true;$debug_log = dirname(__FILE__).'/payment_debug.log';

// Set any of the following 4 boolean values to either// true or false based on whether you're using that// particular payment method. "payment.php" automatically// shows or hides the payment method based on these boolean// values.

// If you set a payment setting to true then you'll also// have to configure the payment settings for that// particular payment method below.$UseAuthorizeNetCC = false;$UseAuthorizeNetBank = false;$UseMoneybookers = true;$UsePayPal = false;

// dollars, cents$AppPrice = array(1, 00);$Currency = 'USD';

$CurrencySign = '$';

$CompanyName = 'VERTEX';$AppName = 'SPINSOFT';

// api key found in http://wyday.com/limelm/settings/$LimeLM_ApiKey = 'ee9335e4ce0c33522d773.93125420';

.$LimeLM_VersionID = '160';

$CheckScript = 'http://aaraa.co.in/testing/payment/paychecker.php';

// Where the user can buy your products$BuyPage = 'http://aaraa.co.in/testing/payment/payment.php';

// Thank you page (once payment is made, user is sent to this page)$ThankYouPage = 'http://aaraa.co.in/testing/payment/pay-thankyou.php';

$YourLogo; // = 'https://example.com/buy/toplogo.png';

//==== Authorize.Net Config ====

// the API Login ID and Transaction Key must be replaced with valid values$AuthNetLogin = 'PASTE LOGIN HERE';$AuthNetTansKey = 'PASTE Transaction Key HERE';$AuthNetTest = false;

//==== PayPal Config ====

// Use PayPal Sandbox (set to false on your live server)$PayPalSandbox = false;

// Paypal Email$PayPalEmail = 'your@email.com';

//==== Moneybookers Config ====

// Your Moneybookers email$MBEmail = 'sudhavs86@gmail.com';

// Set the "Secret Word" in your Moneybookers account// on the "Merchant tools" page. Then set it here.$SecretWord = '3067108';

function debug_log($message, $success, $end = false){ global $debug, $debug_log;

if (!$debug || !$debug_log) return;

// Timestamp $text = '['.date('m/d/Y g:i A').'] - '.(($success)?'SUCCESS :':'FAILURE :').$message. "\n";

if ($end) $text .= "\n------------------------------------------------------------------\n\n";

// Write to log $fp=fopen($debug_log, 'a'); fwrite($fp, $text); fclose($fp);}

function SendPKeys($quantity, $email, $first, $last){ //Note: we put LimeLM in this directory. Change it as needed. require('LimeLM.php');

global $LimeLM_VersionID, $LimeLM_ApiKey;

$errors = false;

// set your API key LimeLM::SetAPIKey($LimeLM_ApiKey);

try { // Generate the product key - set the number of activations using the quantity $xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email));

if ($xml['stat'] == 'ok') { foreach ($xml->pkeys->pkey as $pkey) { // add a newline if you're generating more than one key if ($product_keys) $product_keys .= "\r\n";

// set the product key $product_keys .= $pkey['key']."\r\n"; } } else //failure { // use the error code & message debug_log('Failed to generate product keys: ('.$xml->err['code'].') '.$xml->err['msg'],false); } } catch (Exception $e) { debug_log('Failed to generate product keys, caught exception: '.$e->getMessage(),false); }

if (empty($product_keys)) { // the product key didn't generate, don't send e-mail to the customer yet. $errors = true; }

// form the customer name $customerName = $first;

if (!empty($last)) // append the last name $customerName .= ' '.$last;

$emailBody = $customerName.',

Thank you for your order. Your product key is:

'.$product_keys.'

This product key is licensed for '.$quantity.( $quantity > 1 ? ' users' : ' user' ).' of '.$AppName.'.

Thank you,

'.$CompanyName;

if (!empty($product_keys)) { // Send Email to the buyer $emailSent = mail($email, 'Your '.$AppName.' product key', $emailBody,$headers); }

// generate an array you can insert into your database $new_order_info = array( 'quantity_licenses' => $quantity, 'pkey' => $product_keys, 'pkey_emailed' => $emailSent ? '1' : '0', // 0 = no, 1 = yes 'first_name' => $first, 'last_name' => $last, 'email' => $email );

debug_log('TODO: Insert array into db: '."\r\n\r\n".print_r($new_order_info, true), true);

if (!$emailSent) { $errors = true; debug_log('Error sending product Email to '.$email.'.',false); }

LimeLM::CleanUp();}?>

This coding only use...Paymentsetting.php code only change other coding is no change...payment for money transaction is correctly working but not send product key for email...

please help me.....

Did you upload all the necessary files (LimeLM.php, PaymentSettings.php, paychecker.php, payment.php)?

If there's an error happening then you should read the debug log, like I said earlier.

Did you read the debug log? Is the debug log being written? Does PHP (or Apache) have permission to write to the debug log? If not, change the "$debug_log" variable to point to a file that PHP can actually write to.

Hai,

I upload all the necessary files (LimeLM.php, PaymentSettings.php, paychecker.php, payment.php)error:Debugging turned on All actions will be logged to log file. this error only come.

$debug = true;$debug_log = dirname(__FILE__).'/payment_debug.log';

dubug log related this two variables only used..

not have in the payment_debug.log file.

how to write the payment_debug_log file... please help me....

The easiest thing to do is to creat a new file called "payment_debug.log'" on your computer. Then copy this file to your server (in the same folder as PaymentSettings.php). Now change the file permissions of the file to Read & Write for all groups (Owner, Group, Public). You can do this with any FTP program (set the "numeric value" of the file permission to "666").

Or if you connect to the server using SSH, you can change the file permissions of the file like this:

chmod 666 payment_debug.log

Hai,

In debug_log file this type of error is came

[02/07/2012 6:57 AM] - SUCCESS :paychecker intiated by 193.105.47.7[02/07/2012 6:57 AM] - SUCCESS :Validating Moneybookers order[02/07/2012 6:57 AM] - SUCCESS :IPN successfully verified.[02/07/2012 6:57 AM] - SUCCESS :Creating product Information to send.[02/07/2012 6:57 AM] - FAILURE :Failed to generate product keys: (117) You must enter a value for the feature "Accounts". It's a required feature.[02/07/2012 6:57 AM] - SUCCESS :TODO: Insert array into db:

Array( [quantity_licenses] => 2 [pkey] => [pkey_emailed] => 0 [first_name] => [last_name] => => kavasanthi87@gmail.com) [02/07/2012 6:57 AM] - FAILURE :Error sending product Email to kavasanthi87@gmail.com.[02/07/2012 6:57 AM] - SUCCESS :paychecker finished. Please tel how to sloved...

This line tells you exactly what's wrong:

[02/07/2012 6:57 AM] - FAILURE :Failed to generate product keys: (117) You must enter a value for the feature "Accounts". It's a required feature.

That is, you have a "required" custom license feature named "Accounts", but when you're generating the product key you did not set that feature.

To set your feature values, change this line:

$xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email));

To something like this:

$xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email, array('Accounts'), array('feature value'))); 

hai,

Am using number of modules,so am passing parameter values to take and generate the product key..

first i check that coding is,

$xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email,array('Accounts', 'HR', 'License_expires','Maintenance','OutProcess','Post Spinning','Preparatory','Raw Material','Sales','Spinning','Stores','WasteCotton'),array('y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y', 'y')));

Its working correctly, but i am pass parameter means its not generate product keyAm using that coding....

$HR = $_POST['HR'] == 'on' ? 'y' : 'n';$RawMaterial = $_POST['RawMaterial'] == 'on' ? 'y' : 'n';$Stores = $_POST['Stores'] == 'on' ? 'y' : 'n';$Preparatory = $_POST['Preparatory'] == 'on' ? 'y' : 'n';$Spinning = $_POST['Spinning'] == 'on' ? 'y' : 'n';$PostSpinning = $_POST['PostSpinning'] == 'on' ? 'y' : 'n';$Outprocess = $_POST['Outprocess'] == 'on' ? 'y' : 'n';$Maintenance = $_POST['Maintenance'] == 'on' ? 'y' : 'n';$Sales = $_POST['Sales'] == 'on' ? 'y' : 'n';$Accounts = $_POST['Accounts'] == 'on' ? 'y' : 'n';$WasteCotton = $_POST['WasteCotton'] == 'on' ? 'y' : 'n';$ExpiryDate = date('Y-m-d', strtotime('+1 month'));

$xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email,array('Accounts', 'HR', 'License_expires','Maintenance','OutProcess','Post Spinning','Preparatory','Raw Material','Sales','Spinning','Stores','WasteCotton'),array($Accounts,$HR,$ExpiryDate,$Maintenance,$Outprocess,$PostSpinning,$Preparatory,$RawMaterial,$Sales,$Spinning,$Stores,$WasteCotton)));

this coding only used, but not generate product key error is came that error is,

[02/09/2012 4:12 AM] - SUCCESS :paychecker intiated by 193.105.47.7[02/09/2012 4:12 AM] - SUCCESS :Validating Moneybookers order[02/09/2012 4:12 AM] - SUCCESS :IPN successfully verified.[02/09/2012 4:12 AM] - SUCCESS :Creating product Information to send.[02/09/2012 4:12 AM] - FAILURE :Failed to generate product keys: (117) You must enter a value for the feature "Accounts". It's a required feature.[02/09/2012 4:12 AM] - SUCCESS :TODO: Insert array into db:

Array( [quantity_licenses] => 1 [pkey] => [pkey_emailed] => 0 [first_name] => [last_name] => => kavasanthi87@gmail.com) [02/09/2012 4:12 AM] - FAILURE :Error sending product Email to kavasanthi87@gmail.com.[02/09/2012 4:12 AM] - SUCCESS :paychecker finished. please help me..how to pass parameter values...

It sounds like you're not passing the feature values (or feature names) to the "GeneratePKeys" function. Of course, you need to debug it to know where the problem is.

$HR = $_POST['HR'] == 'on' ? 'y' : 'n';$RawMaterial = $_POST['RawMaterial'] == 'on' ? 'y' : 'n';$Stores = $_POST['Stores'] == 'on' ? 'y' : 'n';$Preparatory = $_POST['Preparatory'] == 'on' ? 'y' : 'n';$Spinning = $_POST['Spinning'] == 'on' ? 'y' : 'n';$PostSpinning = $_POST['PostSpinning'] == 'on' ? 'y' : 'n';$Outprocess = $_POST['Outprocess'] == 'on' ? 'y' : 'n';$Maintenance = $_POST['Maintenance'] == 'on' ? 'y' : 'n';$Sales = $_POST['Sales'] == 'on' ? 'y' : 'n';$Accounts = $_POST['Accounts'] == 'on' ? 'y' : 'n';$WasteCotton = $_POST['WasteCotton'] == 'on' ? 'y' : 'n';$ExpiryDate = date('Y-m-d', strtotime('+1 month'));




$feature_names = array('Accounts', 'HR', 'License_expires', 'Maintenance', 'OutProcess', 'Post Spinning', 'Preparatory', 'Raw Material','Sales', 'Spinning', 'Stores', 'WasteCotton');$feature_values = array($Accounts, $HR, $ExpiryDate, $Maintenance, $Outprocess, $PostSpinning, $Preparatory, $RawMaterial, $Sales, $Spinning, $Stores, $WasteCotton);


debug_log('Are these feature names correct?: '."\r\n\r\n".print_r($feature_names, true), true);debug_log('Are these feature values correct?: '."\r\n\r\n".print_r($feature_values, true), true);


$xml = new SimpleXMLElement(LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email, $feature_names, $feature_values));

hai,

In our application itself generate the product key, and email to that product key for particular customer,Login to the customer and how to edit the license feature values in that product key.. same for LimeLM.

how to select the particular product key and how to edit that product key feature values..

please help me...

Our web API functions are here: LimeLM Web API. It sounds like you're looking for limelm.pkey.setDetails.