AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/voscatalogues/plugins/djcatalog2payment/payu/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/voscatalogues/plugins/djcatalog2payment/payu/payu.php
<?php
/**
 * @package DJ-Catalog2
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

//jimport('joomla.plugin.plugin');

class plgDjcatalog2paymentPayu extends JPlugin {
	
	public function __construct(&$subject, $config = array())
	{
		parent::__construct($subject, $config);
		$this->loadLanguage();
	}
	
	protected function isAllowed($plgInfo, $type = 'djcatalog2payment') {
		if (empty($plgInfo)) return  false;
		return (bool)($plgInfo->plugin == $this->_name && $this->_type == $type);
	}
	
	public function onContentPrepareForm($form, $data) {
		if ($form->getName() != 'com_djcatalog2.payment') {
			return ;
		}
		
		$plugin = '';
		
		if (!empty($data) && !empty($data->plugin)) {
			$plugin = $data->plugin;
		} else {
			$jform = JFactory::getApplication()->input->get('jform', array(), 'array');
			if (!empty($jform) && isset($jform['plugin'])) {
				$plugin = $jform['plugin'];
			}
		}
		
		if ($plugin != $this->_name) {
			return true;
		}
		
		return $form->loadFile(dirname(__FILE__).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'configuration.xml', false);
	}
	
	public function onDJC2BeforeSaveOrder($context, $table, $isNew, $plgInfo) {
		if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
	}
	
	public function onDJC2AfterSaveOrder($context, $table, $isNew, $plgInfo) {
		if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
	}
	
	public function onDJC2CheckoutDetailsDisplay($context, $plgInfo) {
		if ($context != 'com_djcatalog2.checkout.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
		
		$html = '';
		if (trim(strip_tags($plgInfo->description)) != '' ) {
			$html = '<h4>'.$plgInfo->name.'</h4>';
			$html .= $plgInfo->description;
		}
		return $html;
	}
	
	public function onDJC2OrderDetailsDisplay($context, $order, $plgInfo) {
        if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
            return;
        }
        $app = JFactory::getApplication();
        
        $message = '';
        if ($app->input->get('view') == 'order' && $app->input->get('error')) {
            $message = JText::_('PLG_DJCATALOG2PAYMENT_PAYU_ERROR_TEXT');
        } else if ($app->input->get('success') == '1') {
            $message = JText::_('PLG_DJCATALOG2PAYMENT_PAYU_RETURN_TEXT');
        }
        
        if ($order->status != 'A' && $order->status != 'N') {
            return;
        }
        $html = '<div class="payuinfo">';
        
        if ($message) {
            $html .= '<p class="payualert">'.$message.'</p>';
        }
        
        $html .= '<p class="payumessage">';
        $html .= JText::_('PLG_DJCATALOG2PAYMENT_PAYU_INFO_TEXT');
        $html .= '</p>';
        $paymentUrl = JRoute::_('index.php?option=com_djcatalog2&task=paymentProcess&oid='.$order->id.'&plg='.$plgInfo->plugin.'&plgid='.$plgInfo->id);
        $html .= '<p class="payubutton">';
        $html .= '<a href="'.$paymentUrl.'" class="button btn btn-primary payubtn">'.JText::_('PLG_DJCATALOG2PAYMENT_PAYU_BTN').'</a>';
        $html .= '</p>';
        $html .= '</div>';
        return $html;
    }
	
	public function onDJC2PaymentProcess($context, $order, $plgInfo) {
		if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
		
		$posId = $plgInfo->params->get('MerchantPosId');
		$signatureKey = $plgInfo->params->get('SignatureKey');
		
		if (!$posId || !$signatureKey) {
			throw new Exception(JText::_('PLG_DJCATALOG2PAYMENT_PAYU_ERROR_MISSING_PARAMS'), 400);
		}
		
		$app = JFactory::getApplication();
		$websiteName = $app->get('sitename', JURI::base());
		
		require_once JPath::clean(dirname(__FILE__).'/lib/openpayu.php');
		
		$post_variables = array();
		$post_variables['notifyUrl'] = JRoute::_('index.php?option=com_djcatalog2&task=paymentResponse&plg='.$plgInfo->plugin.'&plgid='.$plgInfo->id.'&oid='.$order->id, false, (JUri::getInstance()->isSSL() ? 1 : -1));
		$post_variables['continueUrl'] = JRoute::_(DJCatalogHelperRoute::getOrderRoute($order->id).'&success=1', false, (JUri::getInstance()->isSSL() ? 1 : -1));
		$post_variables['customerIp'] = $_SERVER['REMOTE_ADDR'];
		$post_variables['merchantPosId'] = $posId;
		$post_variables['description'] = JText::sprintf('PLG_DJCATALOG2PAYMENT_PAYU_ORDER_DESCRIPTION', $order->order_number, $websiteName);
		$post_variables['currencyCode'] = (!empty($order->currency)) ? $order->currency : 'PLN';
		$post_variables['totalAmount'] = (int)($order->grand_total * 100);
		$post_variables['extOrderId'] = $order->id.'-'.time();
		
		$i = 0;
		$post_variables['products'] = array();
		foreach($order->items as $item) {
			$post_variables['products'][$i] = array();
			$post_variables['products'][$i]['name'] = (stripslashes($item->item_name));
			$post_variables['products'][$i]['unitPrice'] = (int)((($item->total) * 100) / $item->quantity);
			$post_variables['products'][$i]['quantity'] = ceil($item->quantity);
			$i++;
		}
		
		if ($order->payment_total > 0) {
			$post_variables['products'][$i] = array();
			$post_variables['products'][$i]['name'] = (stripslashes(JText::_('COM_DJCATALOG2_PAYMENT_METHOD') . ' - ' . $order->payment_method));
			$post_variables['products'][$i]['unitPrice'] = (int)($order->payment_total * 100);
			$post_variables['products'][$i]['quantity'] = 1;
			$i++;
		}
		
		if ($order->delivery_total > 0) {
			$post_variables['products'][$i] = array();
			$post_variables['products'][$i]['name'] = (stripslashes(JText::_('COM_DJCATALOG2_DELIVERY_METHOD') . ' - ' . $order->delivery_method));
			$post_variables['products'][$i]['unitPrice'] = (int)($order->delivery_total * 100);
			$post_variables['products'][$i]['quantity'] = 1;
			$i++;
		}
		
		$post_variables['buyer'] = array();
		$post_variables['buyer']['email'] = $order->email;
		$post_variables['buyer']['firstName'] = (stripslashes($order->firstname));
		$post_variables['buyer']['lastName'] = (stripslashes($order->lastname));
		
		
		OpenPayU_Configuration::setEnvironment('secure');
		OpenPayU_Configuration::setMerchantPosId($posId); // POS ID (Checkout)
		OpenPayU_Configuration::setSignatureKey($signatureKey); // Second MD5 key

		$orderFormUrl = OpenPayU_Configuration::getServiceUrl() . 'orders';
		
		$usortedFormFieldValuesAsArray = array();
		$htmlFormFields = OpenPayU_Util::convertArrayToHtmlForm($post_variables, "", $usortedFormFieldValuesAsArray);
		ksort($usortedFormFieldValuesAsArray);
		$sortedFormFieldValuesAsString = implode('', array_values($usortedFormFieldValuesAsArray));

		$signature = OpenPayU_Util::generateSignData(
				$sortedFormFieldValuesAsString,
				OpenPayU_Configuration::getHashAlgorithm(),
				OpenPayU_Configuration::getMerchantPosId(),
				OpenPayU_Configuration::getSignatureKey()
		);
		
		$html = '<!doctype html><html lang="en-US"><head><meta charset="UTF-8" /><title>'.JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION').'</title></head>';
		$html .= '<body><div style="margin: auto; text-align: center;">';
		$html .= '<p>'.JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION').'</p>';
		$html .= '<form method="POST" action="'.$orderFormUrl.'" name="payuform">';
		$html .= '<noscript><input type="submit"  value="' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION_BUTTON') . '" /></noscript>';
		//$html .= '<input type="submit"  value="' . JText::_('COM_DJCATALOG2_PAYMENT_REDIRECTION_BUTTON') . '" />';
		$html .= $htmlFormFields;
		$html .= '<input type="hidden" name="OpenPayu-Signature" value="'.$signature.'" />';
		$html .= '</form></div>';
		
		$html.= ' <script type="text/javascript">';
		$html.= ' document.payuform.submit();';
		$html.= ' </script></body></html>';
		
		echo $html;
		
		$app->close();
		
	}
	
	public function onDJC2PaymentDiscover($context, $plgInfo) {
		if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
		$app = JFactory::getApplication();
		if ($app->input->getInt('oid') > 0) {
			return $app->input->getInt('oid');
		}
	}
	
	public function onDJC2PaymentResponse($context, $order, $model, $plgInfo) {
		if ($context != 'com_djcatalog2.order.payment' || !$this->isAllowed($plgInfo)) {
			return;
		}
		
		require_once JPath::clean(dirname(__FILE__).'/lib/openpayu.php');
		
		$posId = $plgInfo->params->get('MerchantPosId');
		$signatureKey = $plgInfo->params->get('SignatureKey');
		$app = JFactory::getApplication();
		
		if (!$posId || !$signatureKey) {
			throw new Exception(JText::_('PLG_DJCATALOG2PAYMENT_PAYU_ERROR_MISSING_PARAMS'), 400);
		}
		
		OpenPayU_Configuration::setEnvironment('secure');
		OpenPayU_Configuration::setMerchantPosId($posId); // POS ID (Checkout)
		OpenPayU_Configuration::setSignatureKey($signatureKey); // Second MD5 key
		
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			$body = file_get_contents('php://input');
			$data = trim($body);
		
			try {
				if (!empty($data)) {
					$result = OpenPayU_Order::consumeNotification($data);
				}
                
				if ($result->getResponse()->order->orderId) {
		
					/* Check if OrderId exists in Merchant Service, update Order data by OrderRetrieveRequest */
					$retOrders = OpenPayU_Order::retrieve($result->getResponse()->order->orderId);
                    
					if($retOrders->getStatus() == 'SUCCESS') {
						$retOrder = isset($retOrders->getResponse()->orders[0]) ? $retOrders->getResponse()->orders[0] : false;
						
						if (!$retOrder) {
							throw new OpenPayU_Exception('Invalid order', 400);
						}
						
						$paymentStatus = $retOrder->status;//$result->getResponse()->order->status; //NEW PENDING CANCELED REJECTED COMPLETED WAITING_FOR_CONFIRMATION
						
						switch ($paymentStatus) {
							case 'PENDING': {
								// do nothing
								break;
							}
							case 'REJECTED': {
								// do nothing - only seller may reject the payment
							}
							
							case 'CANCELED':
							case 'CANCELLED': {
								// do not change the status, maybe user will make the payment again
								break;
							}
							
							case 'COMPLETED': {
								// confirm the order unless it has already been rejected or confirmed
								if ($order->status == 'A' || $order->status == 'N') {
									$model->changeStatus($order, 'P', true, true, JText::_('PLG_DJCATALOG2PAYMENT_PAYU_PAYMENT_COMPLETED')); 
								}
								break;
							}
							
							case 'WAITING_FOR_CONFIRMATION': {
								if ($order->status == 'A' || $order->status == 'N') {
									$model->changeStatus($order, 'P', false, true, JText::_('PLG_DJCATALOG2PAYMENT_PAYU_WATING_FOR_CONFIRMATION'));
								}
								break;
							}
							default: break;
							
						}
						
						//the response should be status 200
						header("HTTP/1.1 200 OK");
						$app->close();
					} else {
						throw new OpenPayU_Exception('Invalid order', 400);
					}
				}
			} catch (OpenPayU_Exception $e) {
				echo $e->getMessage();
				$app->close();
			}
		}
	}
}



Anon7 - 2022
AnonSec Team