News:

Support the VirtueMart project and become a member

Main Menu

Writing your own payment plugin/module

Started by markus.palsson, June 01, 2013, 07:34:05 AM

Previous topic - Next topic

markus.palsson

Hi,

I'm in the process of integrating credit card payment to my store but there are no available modules/plugins for my service provider (Netaxept, former NETS). I have a friend helping me with the development, and he has made a couple of successful test transactions outside vm2 just to test the transaction interface, but the problem is just that: how do we integrate it into a VM2 payment module/plugin? Is there any tutorials available on the subjuect of creating payment modules, or maybe skeleton code examples, or other documentation? I could really need some pointers to get started. Is it super advanced? My friend is a skilled programmer, but he has no previous experience with neither joomla nor vm.


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


It really depends how the NETS (big Nordic PSP) interface works -
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();
    }
}



Regards
A

Joomla 4.4.5
php 8.1

markus.palsson

Hi Hutson,

Thanks for taking the time. Yeah, sounds like a good idea to use an existing plugin and modify it, but how do I know if e.g. PayPal is similar in structure? The documentation states that the communication between webshop and payment provider is based either on REST or Web Services. Does that mean it is not html form based? Here is a link to the documentation: http://www.betalingsterminal.no/Netthandel-forside/Teknisk-veiledning/API/ (yes, it's in english... ).

Best Regards,
Markus

AH

No the paypal plugin does not look to be a good starting point a simple starting point and, at this point, I find myself completely out of my depth  :'(

Maybe someone else in the forums can suggest a way forward help - but you just have to wait and see if any responses are provided.
Regards
A

Joomla 4.4.5
php 8.1

shogan78

Hi,

Does anyone know if this project was actually completed? I'm in desperate need of a Netaxept payment plugin...

AH

Regards
A

Joomla 4.4.5
php 8.1

themeparrot

Quote from: shogan78 on January 23, 2014, 18:55:29 PM
Hi,

Does anyone know if this project was actually completed? I'm in desperate need of a Netaxept payment plugin...

We have developed it. You can get it from here: http://themeparrot.com/extensions/item/9-bbs-nets-netaxept-payment-gateway-for-virtuemart.html