This page provides a detailed description of the payment plug-in structure, the basic steps in creating a VoipNow Automation Payment Plug-in, explaining the logical and physical structure of a plug-in and the way it interacts with the system.

Logical Structure

A VoipNow Plug-in consists of three parts that you can find fully described below.

Payment Plug-in Manager

It is a configuration file with which the VoipNow Automation interface generates a setup page for the plug-in. It consists of the setup/setup.xml file and the language pack files from the /language folder;

Front-end

This part of the plug-in is present in the VoipNow Automation store and generates the payment inputs, based on the requirements.xml file content (which is saved in the database and can be modified) and on the language pack files from the /language folder.

Gateway Interaction Methods

These methods form a class that enhances the communication between VoipNow Automation and the gateway that needs to be implemented. It will be located in the index.php file.

Physical Structure

A plug-in is composed of one or more files and folders and it is uploaded as an archive in the VoipNow web management interface.

The folder structure of a VoipNow Plug-in consists of the following:

The index.php File

Please find below the structure of the file.

index.php   
<?php 
        class VoipNowPaymentPlugin extends OnlinePaymentInterface implements OnlinePayment {
        // gateway interaction methods
    }
?> 

The Language Folder

The user's language support can be achieved from plug-ins as follows: STEP 1: Create a folder named /language in the plug-in root. STEP 2: Create one file for each language defined in VoipNow and place it inside the /language folder.

It is recommended that the file bears the language code. (e.g. en.php)

STEP 3: Define an array with the language pack messages inside each language file. The structure of the array is: key => value.

<?php 
    $plugin_msg_arr = array();
    $plugin_msg_arr['field_name'] = 'This message is displayed as label in Payment Plug-in Management Page.';
	$plugin_msg_arr['verification_alert'] = 'This message is displayed as alert in case of failed verification.';
?>
Keeping the array name is mandatory in order to make it functional.

STEP 4: Use the OnlinePaymentInterface::translate method described in the Plug-in Methods section to display a message in the current user language.

<?php 
	class VoipNowPaymentPlugin extends OnlinePaymentInterface implements OnlinePayment {
		final public function AuthorizePayment($params) {
			// ...
			if (!isset($params['CreditCardNumber'])) {
				// ...
				$message = self :: translate('error_missing_credit_card_number');
				// we can use the method this way because our class extends OnlinePaymentInterface
				return self :: RaiseError($code, $message);
			}
			// ...
		}
    }						
?>

The setup.xml File

The requirements.xml File

The required_inc.php File

<?php 
							
							
	$_required_params = array(
		'AuthorizePatyment' => array(
			'CreditCardType',
			'CreditCardNumber',
			'CardExpMonth',
			'CardExpYear',
			
			'InvoiceID',
			'OrderTotal',
			'IPAddress',
			
			'PayerFirstName',
			'PayerLastName',
			'PayerEmail',
			'PayerCountry'
		),
		// ...
	);
	
?>

The License File

This file contains the plug-in license information. If you want to distribute the plug-in under the General Public License (GPL) agreement, include the following paragraph:

Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify 
it under the terms of the GNU General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.
					
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License 
along with this program. If not, see http://www.gnu.org/licenses/.

The Meta File

Each plug-in must contain a meta file with standard recognition plug-in information. 4PSA VoipNow does not allow uploading and running plug-ins without the following set of informations:

The file content format is the following:

Name: Name of the plug-in
          Version: The plug-in's version, e.g.: 1.0
          Author: Name of the plug-in author
          Homepage: The plug-in's home page
          Update: The date when the plug-in was last modified