With this tutorial you can add a custom method of payment to VikRentCar.

First of all, create a file called my_payment_method.php and upload it into the folder /administrator/components/com_vikrentcar/payments/

<?php
defined('_JEXEC') OR die('Restricted Area');
error_reporting(0);

class vikRentCarPayment {
	
	private $order_info;
	
	public function __construct ($order) {
		$this->order_info=$order;
	}
	
	public function showPayment () {
		/** See the code below to build this method */
	}
	
	public function validatePayment () {
		/** See the code below to build this method */
	}
	
}
?>		

The method showPayment() of the object VikRentCarPayment is invoked every time a user visits the standby-order page. Make this method write the form that sends data to your gateway. The method can use the values contained in the array $order_info to build the form. This is what the array contains, then follow the example of the methods showPayment() and validatePayment() to build your own class:

<?php
$order_info = array (
	'account_name' => 'Payments Account', /** Configuration Setting */
	'transaction_currency' => 'Currency Code', /** Configuration Setting */
	'vehicle_name' => 'Car Name', 
	'transaction_name' => 'Payment Transaction Name', /** Configuration Setting */
	'order_total' => 'Order Total',
	'currency_symb' => 'Currency Symbol', /** Configuration Setting */
	'net_price' => 'Net Price',
	'tax' => 'Tax',
	'return_url' => 'Return Url', /** This is where the Gateway should redirect */
	'error_url' => 'Error Url', /** The Gateway should redirect here in case of error */
	'notify_url' => 'Notify Url', /** The Gateway should send data back to this link */
	'total_to_pay' => 'Total to Pay', /** Including payments charge */
	'total_net_price' => 'Total Net Price', /** Including payments charge without tax */
	'total_tax' => 'Total Tax', /** Tax of Total to Pay */
	'leave_deposit' => 'Leave a Deposit', /** It can be 0 or 1 */
	'percentdeposit' => 'Percentage of Deposit', /** Integer or decimal without % */
	'payment_info' => array(
						'name' => 'Name of Payment',
						'note' => 'Note',
						'charge' => 'Charge or Discount'
						)
);

/** This is how the method showPayment() can access the array */

public function showPayment () {
	$form="<form action=\"https://yourbankgateway\" method=\"post\">";
	$form.="<input type=\"hidden\" name=\"your_post_data\" value=\"".$this->order_info['total_to_pay']."\"/>";
	$form.="<input type=\"submit\" name=\"_submit\" value=\"Pay Now!\"/>";
	$form.="</form>";
	
	echo $form;

}

/** This is an example of the method validatePayment 
 *  that should return an array containing the 
 *  information of the Gateway response */

public function validatePayment () {
	$array_result = array();
	$array_result['verified'] = 0;
	$array_result['tot_paid'] = ''; /** This value will be saved in the DB */
	
	/** In case of error the log will be sent by email to the admin */
	$log='';
	
	/** Process your gateway response here */
	if($success) {
		$array_result['verified'] = 1;
		/** Set a value for $log */
		/** Set a value for $array_result['tot_paid'] */
	}
	$array_result['log'] = $log;
	
	/** Return the array to VikRentCar */
	return $array_result;
}

/** This is an example of the method afterValidation 
 *  that should just redirect the user or the gateway
 *  to the order page showing an error message or success.
 *  This method is only needed in case the task that verifies the payment
 *  (notify_url) must write an output. Gateways for seamless transactions
 *  always need this method */
public function afterValidation ($esit = 0) {
	$redirect_url = 'index.php?option=com_vikrentcar&task=vieworder&sid='.$this->order_info['sid'].'&ts='.$this->order_info['ts'];
	
	if($esit < 1) {
		$responsetxt = ""; 
		//Your error message, retrieve it from the session or with a method that retrieves a class variable
		//that was stored by the method validatePayment()
		JError::raiseWarning('', (strlen(trim($responsetxt)) > 0 ? $responsetxt.'<br/>' : '').'The payment was not verified, please try again');
	}else {
		$app =& JFactory::getApplication();
		$app->enqueueMessage('Thank you! The payment was verified successfully');
	}
	
	$mainframe =& JFactory::getApplication();
	$mainframe->redirect($redirect_url);
	exit;
	//
}


?>		

You are now able to create the payment from the administrator side of VikRentCar.

Extensionsforjoomla.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
e4j - Extensionsforjoomla.com - VAT N. 02196010975