<?php
/*
* A hikashop payment invoice plugin. This is the main file of the plugin.
*/

// You need to extend from the hikashopPaymentPlugin class which already define lots of functions in order to simplify your work
class plgHikashoppaymentDt_hikashop extends hikashopPaymentPlugin
{
	var $multiple = true; // Multiple plugin configurations. It should usually be set to true
	var $name = 'dt_hikashop'; //Payment plugin name (the name of the PHP file)


	// The constructor is optional if you don't need to initialize some parameters of some fields of the configuration and not that it can also be done in the getPaymentDefaultValues function as you will see later on
	function __construct(&$subject, $config)
	{
		return parent::__construct($subject, $config);
	}


	//This function is called at the end of the checkout. That's the function which should display your payment gateway redirection form with the data from HikaShop
	function onAfterOrderConfirm(&$order,&$methods,$method_id)
	{
		parent::onAfterOrderConfirm($order,$methods,$method_id); // This is a mandatory line in order to initialize the attributes of the payment method
		
		$amount = round($order->cart->full_total->prices[0]->price_value_with_tax,2)*100;
		
		$order_details='order_user_id='.$order->order_user_id.'&order_number='.$order->order_number.'&order_id='.$order->order_id.'&amount='.$amount;
		
		$invoice_url='https://api.rivhit.co.il/paypal/PaypalIpnListener.aspx?'.$order_details;
		
		$ch = curl_init($invoice_url);
		
		$r = curl_exec($ch);
		
	}
}
?>