PrestaShop Forum

The best place in the world to ask questions about PrestaShop and get advice from our passionate community!

PrestaShop Forum

Jump to content

[MODULE] Serial Generator

16 replies to this topic
#1
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
I've finally finished writing this module!
You can download it @ http://attendview.com/serialgen.tar

All the instructions needed are included in the modules config page.
Main part is you need to provide a script that actually generates the key. Since every program can have a different algorithm to generate a key, there is no point in trying to make a 1 for all. Especially since the key has to validate against your application.

Your keygen file can be PHP, CGI, whatever you want, just see the instructions for all the info.

This was tested with PS 1.1.0.5 (I'll be testing it on 1.2 soon)
I've tested this as thoroughly as I can, both on my test setup and our production system.
If you do notice any problems, please post it here and I will try my best to help.
Thank you.

UPDATE: after a bit more thought I've realized that the way the return from the keygen script to the module is handled is very specific to what I needed it for. Since our sales are mostly one or two line items with a qty of 1, the modle wasn't setup for multiple qtys. I will be working on a more flexible version soon. For now I hope my work on this helps someone get what they need out of PS.

Attached Files



#2
funklab

    PrestaShop Newbie

  • Members
  • Pip
  • 4 posts
Hi,

Wow, that's an impressive module.
I'm looking for something similar.

Is there anyone else who has a shop with downloads only and uses a serial module?

#3
emcyze

    PrestaShop Newbie

  • Members
  • Pip
  • 8 posts
Great module,

will test it and post review later.
Thanks

#4
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
Thanks for the comments. Let me know if you guys find any issues.

#5
mrandre

    PrestaShop Apprentice

  • Members
  • PipPip
  • 33 posts
if i make a credit.php file and save it under serielgen folder,... everything is fine, but it does not work, the file containing example :

<?
public function GenerateSerial()
{
GenerateSerial = array("key1"="16854|2589", "key2"="1020", "key3"="15068");

return GenerateSerial;
}
?>

whats wrong ? did anyone get this to work and does anyone have an example ?

#6
adamus007p

    PrestaShop Apprentice

  • Members
  • PipPip
  • 177 posts
shoul I put keygen do class folder?


I try this one but in 6 line there are an error
<?
class myclass12345
{
public function GenerateSerial($order_id, $order_detail)
{
GenerateSerial = array("key1"="abc", "key2"="aaa", "key3"="cba")

return GenerateSerial;
}}
?>
Multi Digital Files Download, upload - Sell digital products

pro dj samples for DJs and for music production

#7
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
mrandre & adamus007p - Could you provide a bit more info on your setup? What error are you getting? Have you debugged the php code to see where the failure is?

Remember that the included scripts expect the key to be returned in a particular manner. What values are you passing to the script?

I havn't touched this script since 9/09 so I'm a bit rusty, but remember that this was tested on an order version of PS. I'll be reevaluating the module next time we update our store. Likely when PS 1.4 is released.

#8
adamus007p

    PrestaShop Apprentice

  • Members
  • PipPip
  • 177 posts
I don't debugged

first i have error that there is no file in class folder, when I add there file I have new error:

Parse error: syntax error, unexpected '=' in /home/{ftpname}/ftp/{sitedir}/classes/mykyegererator.php on line 6


please give an example how should look goog keymaker.php file
Multi Digital Files Download, upload - Sell digital products

pro dj samples for DJs and for music production

#9
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
What does line 6 of you mykeygenerator.php look like?

Also, as far as i remember you mykeygenerator.php file should be in the same forder as the module.

#10
adamus007p

    PrestaShop Apprentice

  • Members
  • PipPip
  • 177 posts
:mykeygenerator.php
6 line: GenerateSerial = array(“key1”=“abc”, “key2”=“aaa”, “key3”=“cba”)

<?
class myclass12345
{
public function GenerateSerial($order_id, $order_detail)
{
GenerateSerial = array(“key1”=“abc”, “key2”=“aaa”, “key3”=“cba”)

return GenerateSerial;
}}
?>

1. I copied :mykeygenerator.php to module folder
2. I wrote :mykeygenerator.php path
3. when I make point2, there is an error - that file :mykeygenerator.php doesn't exist in folder class.

so maybe i have wroten wrong this path??



please give an example right patch of key and an example of generetaSerial script


thank you
Multi Digital Files Download, upload - Sell digital products

pro dj samples for DJs and for music production

#11
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
my do you have ":mykeygenerator.php", what is the : for?
try putting it in the module folder and ommit the :

If that doesn't work, try using the name I use keygen_script.php.

Your array structure doesn't look right. I'd have to load PS locally and debug to double check the format. I don't have time for that right now, but maybe next week.

Till then your best bet is to download komodo idea and debug locally if you can. Or use echo statements to see the variables.

I'm fiddling with this and note that the path to keygen script must be like this "/keygen_script.php". Notice that "/" at the beginning.

from the php manual http://php.net/manua...types.array.php I think the returned format should be like this

array( 'key01' => 'abc', 'key02' => 'xyz')


That should be the correct format.

If it helps, in my case I have a cgi script returning key01=abc, I then use php's parse_str to explode that into the array seen above.

#12
adamus007p

    PrestaShop Apprentice

  • Members
  • PipPip
  • 177 posts
1. when i copy serilgen to modules and add keygen_script.php and config it(/keygen_script.php), there are error

Warning: include_once(/home/my_server/ftp/my_serversamples/classes/keygen_script.php) [function.include-once]: failed to open stream: No such file or directory in /home/my_server/ftp/my_serversamples/classes/Module.php(325) : eval()'d code on line 80

Warning: include_once() [function.include]: Failed opening '/home/my_server/ftp/my_serversamples/classes/keygen_script.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/my_server/ftp/my_serversamples/classes/Module.php(325) : eval()'d code on line 80
Multi Digital Files Download, upload - Sell digital products

pro dj samples for DJs and for music production

#13
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
This was tested on PS 1.1.0.5 and I just confirmed on my PS dev install thats from SVN that it still works. The errors

Warning: include_once(/home/my_server/ftp/my_serversamples/classes/keygen_script.php) [function.include-once]: failed to open stream: No such file or directory in /home/my_server/ftp/my_serversamples/classes/Module.php(325) : eval()‘d code on line 80

Warning: include_once() [function.include]: Failed opening ‘/home/my_server/ftp/my_serversamples/classes/keygen_script.php’ for inclusion (include_path=’.:/usr/local/lib/php’) in /home/my_server/ftp/my_serversamples/classes/Module.php(325) : eval()‘d code on line 80

do show up on the payment screen, but the module still functions as expected.

I did need to comment out line 459 and remove the and on 458. I think there was a field change between versions. BUT IT WORKS!

#14
shaiss

    PrestaShop Apprentice

  • Members
  • PipPip
  • 67 posts
Pm me your keygen script and I'll try debugging it for you

#15
MikeH117

    PrestaShop Newbie

  • Members
  • Pip
  • 1 posts
Hi folks,

This is my first post.

I know next to nothing of PHP but can cut code. I'm keen to implement the module found here:

http://www.prestasho...erial_generator

but it doesn't have a keygen file. Could anybody show me any working code that I could adapt? Please....?

Regards,

Mike H

#16
Prestahelp.com

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
does anyone have a working script

#17
Prestahelp.com

    PrestaShop Newbie

  • Members
  • Pip
  • 2 posts
does anyone have a working script