News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

New plugin development

Started by darkmorning, June 20, 2013, 15:03:05 PM

Previous topic - Next topic

darkmorning

Hi everyone

I am new here (also relatively new to Joomla development) and have spent a while looking around trying to find the correct topic to ask.

I am starting to write a payment plugin for VirtueMart 2 and Joomla 2.5  I have not found an example Joomla 2.5 manifest for Virtuemart - have I missed it? I haven't got my plugin working yet and have a few questions.

I am using Joomla 2.5.9 and Virtuemart 2.0.20b.

Initially I have been having some problems finding where I should put the various files when writing my manifest:

Where do I put the install sql files please? ( or should i use the _ createTable() if so how does it work)

Where do I put the image file that is linked to the radio button when choosing the payment method?

Also when I am writing plgVmOnSelectPayment is there any example code - if not does a whole form get written here if so where does the form post to ?

Any help and direction would be very much appreciated.


Thank you

AH

Hi
For a new payment plugin you will need:-

New Folder plugins/vmpayment/netaxept
netaxept.php Plugin in this folder - gets it all working!
netaxept.xml file - loads the installation files to the relevant directories / sets the parameters for the plugin page etc

Folder sitename/administrator/language/en-GB obviously adjust for Norwegian
en-gb.plg_vmpayment_netaxp.ini and .sys
This provides Text for plugin config page and frontend

If it is HTML Post Form based - then you could start by modifying the existing PayPal or one of the other plugins

It is really simple to clone and adjust for your own plugin if they are similar to an existing plugin.

Using paypal clone as an example:-

Start by copying the paypal folder to a new folder in the sitename/plugins/vmpayment folder
decide on the new name for your method and use this as the name of the folder e.g. netaxept

Now have a folder called netaxept in the plugin/vmpayment that contains :- paypal.php and paypal.xml
Rename these to netaxp.xxx

You need to have some language files so sitename/administrator/language/en-GB  copy and rename the en-gb.plg_vmpayment_paypal.ini and .sys
to en-gb.plg_vmpayment_netaxept.ini and .sys

You can then get into the code and start adjusting from paypal to netaxp
In netaxept.php you will need to do this along with lots of other stuff!!!


if (!class_exists ('vmPSPlugin')) {
require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php');
}

class plgVmPaymentNetaxept extends vmPSPlugin {






When you come to want it to install as a package you will need an installation script file as well:_

In your installation zipped packaged (when you have it all working! )
An installation script - gets it all loaded to joomla
netaxept.script.php
Something like this should work for installation


<?php
defined
('_JEXEC') or die('Restricted access');
/**
 * Installation script for the plugin
 *
 * @copyright Copyright (C) 2013 Reinhold Kainhofer, office@open-tools.net
 * @license GPL v3+,  http://www.gnu.org/copyleft/gpl.html 
 */

class plgVmPaymentnetaxeptInstallerScript
{
    
/**
     * Constructor
     *
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     */
//     public function __constructor(JAdapterInstance $adapter);
 
    /**
     * Called before any type of action
     *
     * @param   string  $route  Which action is happening (install|uninstall|discover_install)
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     *
     * @return  boolean  True on success
     */
//     public function preflight($route, JAdapterInstance $adapter);
 
    /**
     * Called after any type of action
     *
     * @param   string  $route  Which action is happening (install|uninstall|discover_install)
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     *
     * @return  boolean  True on success
     */
//     public function postflight($route, JAdapterInstance $adapter);
 
    /**
     * Called on installation
     *
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     *
     * @return  boolean  True on success
     */
    
public function install(JAdapterInstance $adapter)
    {
        
// enabling plugin
        
$db =& JFactory::getDBO();
        
$db->setQuery('update #__extensions set enabled = 1 where type = "plugin" and element = "netaxept" and folder = "vmpayment"');
        
$db->query();
        
        return 
True;
    }
 
    
/**
     * Called on update
     *
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     *
     * @return  boolean  True on success
     */
//     public function update(JAdapterInstance $adapter)
//     {
//         jimport( 'joomla.filesystem.file' ); 
//         $file = JPATH_ROOT . DS . "administrator" . DS . "language" . DS . "en-GB" . DS . "en-GB.plg_vmshopper_ordernumber.sys.ini";
//         if (JFile::exists($file)) JFile::delete($file); 
//         $file = JPATH_ROOT . DS . "administrator" . DS . "language" . DS . "de-DE" . DS . "de-DE.plg_vmshopper_ordernumber.sys.ini"; 
//         if (JFile::exists($file)) JFile::delete($file); 
//         return true;
//     }
 
    /**
     * Called on uninstallation
     *
     * @param   JAdapterInstance  $adapter  The object responsible for running this script
     */
    
public function uninstall(JAdapterInstance $adapter)
    {
        
// Remove plugin table
        
$db =& JFactory::getDBO();
        
$db->setQuery('DROP TABLE `#__virtuemart_payment_plg_netaxept`;');
        
$db->query();
    }
}



Or something like this - this is what i did for a new paypal pro using hosted and iframe options UK
Regards
A

Joomla 4.4.5
php 8.1

darkmorning


darkmorning

Hi

I have now created a set of files for an install but I do not have a listing of my payment method in the VirtueMart installation.

Having looked at my sql installation I don't have the sql that adds my payment method to that list.

Does anyone know which database tables I need to add rows to and could give me some guidance on the sql to add to my install please?

Thanks in advance.






AH

The dbase tables creation should be part of the plugin code

If the table does not exist it should create one

See the paypal.php code in plugins for where this is done.
Regards
A

Joomla 4.4.5
php 8.1

darkmorning

Hi

Having looked at the paypal.php I can find where a table is created to keep the paypal payment plugin data but nothing that creates the entry to list the payment method in the Virtuemart Administrator Payment method. I currently only have paypal in the Virtuemart Payment method list. Looking at the fields in paypal.php I need a 'virtuemart_paymentmethod_id' and do not have anything in that table.

I am puzzled, how did this plugin get into the list, I'm obviously missing something here.

Thanks


AH

Have you installed your plugin using an install script

Last step in my first post!
Regards
A

Joomla 4.4.5
php 8.1

reinhold

Is the plugin listed in the Joomla plugin manager?
You need to enable the plugin there, and then you can create a new payment method of that type in the Virtuemart administration area. That step will create the virtuemart_paymentmethod_id for the method.

AH

If you have not used an install script the plugin will not be listed
Regards
A

Joomla 4.4.5
php 8.1

darkmorning

ooops with everything I had to do I have overlooked the script as the last step!

I will have a go at that now.

Thanks very much.

darkmorning

I have now used the install script, I have an entry in the extensions table, but I still do not have a payment option in the Virtuemart Payment Method list.

I have also enabled the Plugin in Joomla extensions.

I have a getTableSQLFields () function with the fields I need for the new payment method but I can't find this table in the database after install. Also does it automatically name itself as I can't see anywhere to name the table?

This is where my lack of experience shows, I really appreciate your help.


Thanks

darkmorning

Hi

I have now added a new Payment method in Virtue mart Payment methods, one step further on down the line.

I now need to understand why my database table is not is being created on install.

This is great I am getting somewhere.

Thanks again :) :)

AH

Try creating an order using this new method as a your payment choice
Regards
A

Joomla 4.4.5
php 8.1

darkmorning

Thanks for this, my cart is not quite ready for a test purchase yet

I have also had to manually install my database table, not sure why it won't install at the moment. Until my cart is ready I will look at the responses from the payment provider.


Moving forward :-):-)


AH

Regards
A

Joomla 4.4.5
php 8.1