Jump to content

Custom license keys in 4.0 not working


guyroch
 Share

Recommended Posts

In 3.4 I would create a trial.php with the following and it would generate my custom key...

<?php

class licenseKey_trial
{
   public static function generate( $member, $purchase )
   {
      return 'some-trial-key-here'.rand(1,100);
   }
}

 

When I do the same in 4.0 I get an error.  Initially I was getting a file/class not found but then I noticed the capital letters in 4.0 and added them. Now I no longer get a file/class not found but instead I get error ex256 on checkout.

<?php

class LicenseKey_Trial
{
   public static function generate( $member, $purchase )
   {
      return 'some-trial-key-here'.rand(1,100);
   }
}

 

Where can I get the new documentation for generating custom license keys in 4.0?

Thank you

Guylain

 

 

 

 

 

Edited by guyroch
Link to comment
Share on other sites

Hi,

There's a few more changes involved, here's a similar basic license key generation file.

<?php

namespace IPS\nexus\Purchase\LicenseKey;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
	exit;
}

/**
 * License Key Model - MD5
 */
class _Mdfive extends \IPS\nexus\Purchase\LicenseKey
{	
	/**
	 * Generates a License Key
	 *
	 * @return	string
	 */
	public function generate()
	{
		return md5( uniqid() );
	}
}

Remember, classes in IPS4 should start with an underscore

Link to comment
Share on other sites

Well I got further, the key was generated, woohoo!

However, I can not pass $member and $purchase as parameters, otherwise the call errors out still.

I need both these arrays to generate the license key.  What are the parameters in 4?

public static function generate( $member, $purchase ){

}

 

Edited by guyroch
Link to comment
Share on other sites

  • 2 months later...
On 10/5/2015 at 8:08 PM, Stuart Silvester said:

Hi,

There's a few more changes involved, here's a similar basic license key generation file.


<?php

namespace IPS\nexus\Purchase\LicenseKey;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
	exit;
}

/**
 * License Key Model - MD5
 */
class _Mdfive extends \IPS\nexus\Purchase\LicenseKey
{	
	/**
	 * Generates a License Key
	 *
	 * @return	string
	 */
	public function generate()
	{
		return md5( uniqid() );
	}
}

Remember, classes in IPS4 should start with an underscore

.

Hi,

I'm fighting this LicenseKey too .. but my problem is in the naming file/class ..

I've copied the file " Mdfive.php " to " test.php " ..

renamed the class name " _Mdfive " to " _test " ..

on the product page, " store and purchase settings " .. " License Key " .. in the list it shows : " lkey_test "

" lkey_test " is a name that I didn't use/set anywhere ..

anyway, I select that and try to change a customers product license key and it gives me a blank screen ..

MD5 & Standard works flawlessly ..

If I change the code in the file Mdfive.php (what I need) then it works also ..

So .. how I make " test.php " work ? ( it is in the right folder, same permissions as Mdfive.php & Standard.php )

 

.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...