Product Line with both serials and license files.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #175186

I'd like to ask about directions for next case

1) we have product line, where some products need SERIAL, and some products need license file (and only file, without any serial).

QUESTION 1: Do we need 2 different plugins? Or this can be done via single plugin?

I am asking because about file - in docs can be found only mention of onBeforeSerialDownloadFile() trigger, and it says: "Download plugins allow you to create unique downloadable files"
But serials are in generator-plugin...


2) Besides trigger depends on $serial parameter

QUESTION 2: Why file should depend on serial? In our case this have no sense.


3) Yes, I have found your own plugin AttachSerial, but it not helps at all -- a lots of own logic hides they main how to work with FILE. I have only learn, that plugin must to save file into own folder and check this in path.

QUESTION 3: If we must save generated files in the folder of plugin, how we cleanup that files if something bad happens? In our pref solution we did generate files into /tmp folder

4) so we have produce Valentina Server. When user buy it, in the email must be attached ZIP file with license file or even set of files. Our code can produce this ZIP ... What happens next?

QUESTION: HikaShop will save this file automatically into DB for this order - product ?
and then in folder of plugin file should be deleted?

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 6 months ago #175190

Hi,

1. I don't understand so I don't know.

2. HikaSerial is base on the fact that you have a unique content.
If you don't have a serial, you don't have a base to generate a unique file in the way that, if the customer re-download the file, he will receive the same file.
The file is unique depending the "serial", not unique each time he will download it.

3. The plugin "attach serial" is not the best sample for the trigger onBeforeSerialDownloadFile ; even if the code for the function is not really big.
If you follow the fact that a file depend on a serial, you can re-generate the exact same file using the serial.
You can otherwise store the file path in the "extra data" of the serial in order to resend it easily (and put it in a secure folder).

4. HikaShop or HikaSerial does not store any file into DB.
If you plugin generate a file, you have to store that file or generate it dynamically. It will be related to your plugin.
But you can use the HikaShop "secure upload folder" to store your files (like : media/com_hikashop/upload/safe/my_hikaserial_plugin/ )

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #175209

Jerome wrote: Hi,
2. HikaSerial is base on the fact that you have a unique content.
If you don't have a serial, you don't have a base to generate a unique file in the way that, if the customer re-download the file, he will receive the same file.
The file is unique depending the "serial", not unique each time he will download it.


Hi Jerome,

* well, we simply use {UserName + date + connection number to VSERVER} to generate UNIQUE and STABLE license file.
* We do not need any serial for this ....

Well, we can may be encode this info into string "UserName, Date, Count" to use it as serial in your sense ...
Sounds good?

I guess this string will be shown in the email to user ... this not harms ... okay so this can be a way may be.

Last edit: 9 years 6 months ago by ruslan_zasukhin.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #175214

Jerome wrote: 3. The plugin "attach serial" is not the best sample for the trigger onBeforeSerialDownloadFile ; even if the code for the function is not really big.
If you follow the fact that a file depend on a serial, you can re-generate the exact same file using the serial.
You can otherwise store the file path in the "extra data" of the serial in order to resend it easily (and put it in a secure folder).

4. HikaShop or HikaSerial does not store any file into DB.
If you plugin generate a file, you have to store that file or generate it dynamically. It will be related to your plugin.
But you can use the HikaShop "secure upload folder" to store your files (like : media/com_hikashop/upload/safe/my_hikaserial_plugin/ )
Regards,


Hi Jerome,

3. Well, this is the only place where onBeforeSerialDownloadFile() call was found.

4. We do not want store into DB, or keep on disk.
So ability to generate dynamically is fine for us ...

Only strange was that we need to build some SERIAL STRING :-)
Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #175229

Well, I have read onBeforeSerialDownloadFile() in that AttachSerial plugin ...
and I think I still do not see
HOW I should return file from this function?

public function onBeforeSerialDownloadFile(&$filename, &$do, &$file, &$serials) {

    // Let I have put file into absolute position.
    $pathWhereFile = "/tmp/dummy.zip";        

    What is next?
    - I should assign this into  $file?
    - or RETURN it ?
    - else?
}

Last edit: 9 years 6 months ago by ruslan_zasukhin.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 6 months ago #175230

Hi,

If you do not need a serial to generate your file, so you do not need HikaSerial and you can just use the HikaShop triggers to generate you file ; like HikaSerial does.
Like I told you, the goal of HikaSerial is to work with serials ; if you're outside of his main goal it means that you might not need it.

The HikaSerial trigger "onBeforeSerialDownloadFile" is a special "onBeforeDownloadFile" HikaShop trigger
www.hikashop.com/support/support/documen...onBeforeDownloadFile

So just don't use HikaSerial and use directly HikaShop.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #175248

Jerome wrote: If you do not need a serial to generate your file, so you do not need HikaSerial and you can just use the HikaShop triggers to generate you file ; like HikaSerial does.
Like I told you, the goal of HikaSerial is to work with serials ; if you're outside of his main goal it means that you might not need it.

Jerome wrote: The HikaSerial trigger "onBeforeSerialDownloadFile" is a special "onBeforeDownloadFile" HikaShop trigger
www.hikashop.com/support/support/documen...onBeforeDownloadFile

So just don't use HikaSerial and use directly HikaShop.


Hmm, I afraid not using HikaSerial, will bring even more questions ...

1) then we need to make plugin to HikaShop?
2) this plugin will generate file, OK. How that file will go into email ?
3) this plugin can be triggered by onBeforeDownloadFile() HikaShop trigger - okay ...

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 6 months ago #175295

Hi,

You can't attach your file in the email unless you code something in your special plugin to do so.
Using an HikaSerial or an HikaShop trigger won't change anything.
The difference is that, the HikaShop trigger is related to HikaShop and not HikaSerial.
If you have question about HikaShop triggers, please use the HikaShop forum section.

The "onBeforeSerialDownloadFile" trigger in HikaSerial works with serials, like the plugin "attach serial" works (and the source code of the plugin "attach serial" is a perfect sample of the trigger "onBeforeSerialDownloadFile").
If it's not your case (and it is not your case), you shouldn't use that trigger.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #176536

Dear Jerome,

so far we have got working serials for our products. This is very good.
Now I return back to question of license files.
Please forget our discussions before.

TASK IS:
user chose product VSERVER,
he get letter with attached ZIP file, which we can generate from info
"UserName;OS"

On this page of HikaSerial docs
www.hikashop.com/support/documentation/1...e-in-hikaserial.html

is said:

Serial possibilities
With HikaSerial (custom) plugins:
Unique file attachment

So how we can get this functionality?
What are the key moments here even if to look on AttachSerial plugin?
We do not need GUI for options in our plugin as have AttachSerial ...

All I want is, let I have file at $path = /tmp/license.zip
And I want that this file was attached

public function generate(&$pack, &$order, $quantity, &$serials) 
{
     $serial = "RuslanZasukhin;Mac";
     $serials[] = $serial;
}

public function onBeforeSerialDownloadFile(&$filename, &$do, &$file, &$serials) 
{
      $pathWhereFile = "/tmp/license.zip";        
       
      ... how to attach to email?
}


QUESTIONS ARE:

1) onBeforeSerialDownloadFile() is not called at all ... why? I need specify something before?

2) how attach file to letter which HikaShop sends?

You say once, nothing is attached to email ...
But another time you direct me to that AttachSerial plugin ... which I have read from start to end ... and I do not see too much help here about attaching to email ... May be you can point by finger into line number?

Thank you in advance.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 6 months ago #176540

Hi,

If you want to be call, you need to need to use a filename compatible with the download system ; like the plugin "attach serial" is working.
www.hikashop.com/support/documentation.h...ns-attachserial-form

Attach as Download - Indicate if the configuration could be use with dynamic download.
To create a dynamic download file, you have to add a file to the targeted product and specify the url for the file. By using the url "#hikaserial:attachserial:X" where X is the ID of your attach serial configuration, you will let the plugin generate dynamically the file during download.

When a file start with " #hikaserial: " is will trigger the " onBeforeSerialDownloadFile " event.
The filename is the entire filename and your plugin have to check that is it from him ; like " #hikaserial:mydlplugin:xxx ".

Thanks to this trigger you can :
- change the filename if you want to let HikaShop send another file which exist in your server
- send yourself a file : send the headers, the file content and do an "exit" afterwards.

If you want to attach to an email, you have to use the HikaShop email trigger events ; there is no HikaSerial event for that because HikaSerial do not send any email.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: ruslan_zasukhin

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 6 months ago #176703

Thank you very much! :)

I think that finally I have to see all mechanisms and how they work together.
I did add FILE to product, and yes this have start call that trigger, from OrderDetails page on click. GOOD. :)
I can see trigger call, and var_dump of params. All is in place what I need. GOOD. :)
And email have similar link (but it little differ) still need to check it also calls trigger.

First of all, I will try to play with ZIP archive ... to make it real download.
Then make working our alga,
Then I will try attach ZIP to email

Again, thank you a lots, Jerome! :-)

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 5 months ago #177445

Hi Jerome,

Again I need your help and advice.

I try implement call-system as you name it.
- into product I have added file "#hikaserial:valentina:licenses.zip"
- and I was able to see letter with LINK
- then I click it and get trigger onBeforeSerialDownloadFile() called.
- then our code produces correct license file after parsing of our pseudo-serial, I see it on disk

But final step -- return that file to HikaShop so download start -- NOT WORKS :-(

This is simplified a little code of function which I try ...
as you can see in comment, my function returns full path to generated file.
I assign it into $filename. I have try to assign it into $file->file_path also ...

But I still get page "Brand Listing" with message FILE NOT FOUND.

May be problem comes from Mac OS X?
I develop this under Mac OS X and MAMP....
Main site will be on Linux ...

	public function onBeforeSerialDownloadFile( &$filename, &$do, &$file, &$serials ) 
	{
		// We take serial and split it:
		$serial = $serials[0];
		$parts = explode( ";", $serial->serial_data );

		$filename = create_license_for_vserver_free( $parts, $file );

		// now $filename is "/tmp/Ruslan Zasukhin/license_win_4430337204584841"
		
		// Also I have try to add this:
		$file->file_path = $filename;
		$file->file_name = $fileName;  // full path or only file name. Both tested.
	}


Here in docs www.hikashop.com/support/documentation/6...onBeforeDownloadFile

it is said that

onBeforeDownloadFile(&$filename,&$do,&$file)
This function will be triggered by HikaShop before a file download. $filename is the path to the file, you can change it's value. $do allows you to cancel the download if you set it to false, and $file is an object containing the information about the file.

** So I guess that it is okay that I change original license.zip to generated name license_win_4430337204584841 ?

** Also I wonder. In plugin AttachSerial I did not find line of code, which changes $filename. I see only code which attaches image to letter...

** Also I wonder ... in such call-system, assume it works ...
I return file, download starts ... WHO later and how will trash this file from disk?

Last edit: 9 years 5 months ago by ruslan_zasukhin.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #177470

Hi,

You should check the filename at the beginning of the function, like we did for the plugin "attach serial".

		$startStr = 'hikaserial:attachserial:';
		$l = strlen($startStr);
		if(substr($filename, 1, $l) != $startStr) {
			return;
		}
Modifying the variable $filename will modify the same variable in the HikaShop download class ; you can look at the function "sendFile" and the call of the trigger
$dispatcher->trigger( 'onBeforeDownloadFile', array( &$filename, &$do, &$file) );
If the variable "$do" is still "true", the rest of the sendFile process will be completed, the file will be check and sent.
HikaShop use the $filename to determine the "name", I don't think that the miss of the extension should be a problem, but you should check that.

Attach serial does not change the $filename (but I wrote other little plugin which does), this plugin as been made to generate dynamically some content and send it directly to the user ; without using the HikaShop and without creating a file in the server.

If you want you can do the same by adding the send process in your plugin ; not generating the temp file but just send it on the fly.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 5 months ago #177503

Yes, I will add that protection lines on start of function. Just for now I want to get something working.

So it looks I do correct things, with assignment to $filename.
Okay I will check caller code now and may be will add logs there to see var values.

* Is it possible to see code of your small plugin?
I not very see what you mean with send on the fly without disk touch ...
You mean just make memory buffer and pass it to $filename? But they want path here no?

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #177541

Hi,

1 - No I can't provide the code of the plugin that I made for a client ; I do not have this right.
2 - Just look at the HikaShop download class or the "attach serial" plugin code ; You have to send the file data youself with the header, etc. And finish by an exit.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 37
  • Thank you received: 1
9 years 5 months ago #177546

Aha, sending in this way and exit I have see already.
I did think this is to ATTACH file to email letter.
But file, image in AttachSerial, still is generated on disk, right?

I am going try this way also after "download on call" will start to work.
If they both will work -- this can be good.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
9 years 5 months ago #177548

Hi,

But file, image in AttachSerial, still is generated on disk, right?

Not at all.

There is an option to create a temp file for the email attachment, because some SMTP provider in Joomla does not support the function "AddStringAttachment" ; but for the rest, I never write a file on disk.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.088 seconds
Powered by Kunena Forum