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
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
Thank you I will have a go. :)
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.
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.
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
Have you installed your plugin using an install script
Last step in my first post!
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.
If you have not used an install script the plugin will not be listed
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.
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
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 :) :)
Try creating an order using this new method as a your payment choice
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 :-):-)
8)
Hi
My cart is now at a point where I view the different payment methods and mine is not showing, others are. Is it to do with the problems I am having with the conversion from paypal.php to mine and setting the $varsToPush, they are stored in the payment_params field in the #_virtuemart_paymentmethod aren't they?
Would this affect my payment method not being able to be selected when I submit the shopping cart? At the moment I can't work out even with debugging and stepping through the code why I can't save these parameters.
Thanks :'(
Have you setup the plugin and is it shown as a payment method in the backend?
Hi
Thanks for all the help I have received.
I need to trigger my own class on the payment response for all the payment types in Virtuemart, where would be a good place to call my script?
In the Virtuemart pluginresponse view or controller?
Thank you
I hope someone can help you, way above my knowledge!
Thanks for your help, I am learning all the time and beginning to work some things out for myself, hopefully it will the correct way, if not as the saying goes you learn from your mistakes
:) :)