Login Form

Donations

Thank you for your donation.

Amount:   USD

How to develop plugins for "Payperdownload" component? PDF Print E-mail
Written by Ratmil   
Tuesday, 02 November 2010 17:37

Payperdownload initial goal was to sell access to downloads using Phocadownload. Later on using plugins Payperdownload was able to be used with other download manager, and not only download manager but also other components. On installation the following plugins are installed by default:

Content Articles: This plugin enables selling access to Joomla content articles.
PhocaDownload file: You can make users pay for downloading Phocadownload files.
Kunena Access: With this plugin you give reading or posting access only to users who have previously bought a license.
jDownload file: The same as Phocadownload but using jDownload component.

There are plugins for other components such as Remository, K2, Akeeba Release System, Sobi2 and Sobipro but if you want to integrate it with other components you would need to learn how to develop a plugin.
The best way to know how is to take a look at one of the plugins, Phocadownload for example but you can also read this article for better understanding.

The type of plugin has to be "payperdownloadplus". And you will need to implement the following events:

Plugin events.

"PayPerDownload" plugins can accept the following events:
- onIsActive
- onRenderConfig
- onGetSaveData
- onValidateAccess
- onAjaxCall- onRenderPaymentForm (starting from Payperdownlaod v1.0.5)
- onPaymentReceived (starting from Payperdownlaod v1.0.5)

 

Event "onIsActive".
This event is triggered when the user wants to define a new resource he wants to restrict access to. This event receives only one parameter of type array. The plugin must add an entry to this array with information about itself and the entry has to be an array with the following keys: "name", "description" and "image". The value for "name" has to be a unique for the plugin, "description" would be a small text shown to the user and "image" is the path to an image representing the resource.

Event "onRenderConfig".
This event is triggered after the user has selected the type of resource and now has to define exactly what he wants for access restriction.
In this event the plugin would render the html code to select, for example, what Phoca Download file, category or section he wants restricted. The parameter for this is the name of the plugin and you (as developer) has to check the plugin name is the same you provided on the "onIsActive" event, if it isn't you shouldn't do anything.
It is importance to notice that the html code is inserted inside a table and you should render "tr" and "td" tags.

Event "onGetSaveData".
This event is triggered when the resource is about to be saved to database. There are six parameters for this event and most of them have to be set by the plugin.
$resourceId : This value set here is should be an id for the resource defined. For example the id of the PhocaDownload file but it could be anything the plugin wants to set, it just has to be an integer.

$pluginName : This is the name of the plugin and as in the previous event it has to be checked that it is the correct name plugin if it is not nothing should be done.
$resourceName: Set by the plugin, this value will be used as name for the resource.
$resourceParams: Anything else used to define the resource.
$optionParameter: This should be the value of the "option" parameter used when the resource is to be accessed. For PhocaDownload files it would be "com_phocadownload".
$resourceDesc: Set by the plugin, this value will be used as a description for the resource.


Event "onValidateAccess".

In this event the plugin should decide if one the defined resources is about to be accessed. If it is the case the required license has to be specified.
Parameters for this event:

$option: The value of the option parameter. For the PhocaDownload example it should be checked that this value is "com_phocadownload".

$resources: An array of resources loaded from database. Each object in the array has the following properties: resource_id, resource_type, license_id and resource_params. The plugins uses these values to validate if the resource is restricted or not.

$allowAccess: The plugin will return false if the resource is restricted, true otherwise.

$requiredLicenses: If the resource is restricted the plugin will return the ids of the licenses required. This id is received as the property license_id in the resource array.

$requiredResources: The ids of the resources that need payment.

Event "onAjaxCall".

You can implement this event to use ajax for your plugin on the back-end. To raise this event from java script you would call an url like the following:
“/administrator/index.php?option=com_payperdownloadplus&adminpage=resources&task=ajaxCall&plugin=Yourpluginname”.
This event takes two parameters:
$plugin: The name of your plugin. It has to be the same value as the plugin parameter as passed in ajax call.
$output: In this parameter you will write the result that will be returned to the ajax call.

Event “getReturnPage”.
This event is to specify a returning page after a successful payment.
Parameters:
$option: As with other events this parameter holds the value of the current “option” request parameter. You have to check it is the correct one for the component you developing the plugin, if it is not you shouldn’t do anything.
$returnPage: This is an output parameter. Here you will specify the returning page.

Event “onCheckDecreaseDownloadCount”.
This event was introduced after the component had the added feature of limiting the number of downloads allowed. It is used to specify if your plugin support this feature.
Parameters:
$option: The same as in the rest of events. Check if matches the component you are developing a plugin for.




Last Updated on Saturday, 17 March 2012 12:47
 

Comments  

 
0 #2 dody 2011-11-02 06:27
how to use payperdownload plugin to sell access download for Jdownload ?
Quote
 
 
0 #1 tt 2011-06-21 05:36
:-) ;-) :-| :-* :-* :zzz :P :roll: :P :roll:
Quote
 

Add comment


Security code
Refresh