Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 5, 20159 yr 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
October 5, 20159 yr Community Expert 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
October 5, 20159 yr Author 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 ){ }
October 5, 20159 yr Community Expert Hi, You can fetch the purchase/member data inside the method /* \IPS\nexus\Purchase object */ $purchase = $this->purchase; /* \IPS\Member object */ $member = $this->purchase->member; Note that both of these will be objects, not arrays.
January 4, 20169 yr 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 ) .
January 4, 20169 yr 5 minutes ago, Nathan Explosion said: Long shot.... Mdfive.php Standard.php test.php . YES!! That's it .. but also .. what I had before INkey.php .. didn't work with IN .. does work with In .. Thank you! .
January 4, 20169 yr 3 minutes ago, IN10TION said: . YES!! That's it .. but also .. what I had before INkey.php .. didn't work with IN .. does work with In .. Thank you! . it's completely new codes then 3x however it has a mind of its own
Archived
This topic is now archived and is closed to further replies.