Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/joomla4/payplug.tar

index.html000064400000000054151160401400006530 0ustar00<html><body
bgcolor="#FFFFFF"></body></html>lib/index.html000064400000000054151160401400007276
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>lib/payplug/index.html000064400000000054151160401410010760
0ustar00<html><body
bgcolor="#FFFFFF"></body></html>lib/payplug/IPN.php000064400000003106151160401410010123
0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class IPN {

	public $amount;
	public $customData;
	public $customer;
	public $email;
	public $firstName;
	public $idTransaction;
	public $lastName;
	public $order;
	public $origin;
	public $state;

	public function __construct($headers = null, $body = null) {
		$config = Payplug::getConfig();


		if (is_null($config)) {
			throw new ParametersNotSetException();
		}
		if (is_null($body)) {
			$body = file_get_contents("php://input");
		}
		if (is_null($headers)) {
			$headers = getallheaders();
		}


		$headers = array_change_key_case($headers, CASE_UPPER);
		$signature = base64_decode($headers['PAYPLUG-SIGNATURE']);
		$publicKey = openssl_pkey_get_public($config->payplugPublicKey);

		$isValid = openssl_verify($body, $signature, $publicKey,
OPENSSL_ALGO_SHA1);

		if ( ! $isValid) {
			throw new InvalidSignatureException();
		}


		$data = json_decode($body, true);

		$this->amount = $data['amount'];
		$this->customData = $data['custom_data'];
		$this->customer = $data['customer'];
		$this->email = $data['email'];
		$this->firstName = $data['first_name'];
		$this->idTransaction = $data['id_transaction'];
		$this->lastName = $data['last_name'];
		$this->order = $data['order'];
		$this->origin = $data['origin'];
		$this->state = $data['state'];
	}
}
lib/payplug/Parameters.php000064400000002530151160401410011600
0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class Parameters {

	public static function createFromString($str) {
		$array = json_decode($str, true);

		return new Parameters(
			$array["currencies"],
			$array["maxAmount"],
			$array["minAmount"],
			$array["paymentBaseUrl"],
			$array["payplugPublicKey"],
			$array["privateKey"]
		);
	}

	public static function loadFromFile($path) {
		return self::createFromString(file_get_contents($path));
	}

	public $currencies;
	public $maxAmount;
	public $minAmount;
	public $paymentBaseUrl;
	public $payplugPublicKey;
	public $privateKey;

	public function __construct($currencies, $maxAmount, $minAmount,
$paymentBaseUrl, $payplugPublicKey, $privateKey) {
		$this->currencies = $currencies;
		$this->maxAmount = $maxAmount;
		$this->minAmount = $minAmount;
		$this->paymentBaseUrl = $paymentBaseUrl;
		$this->payplugPublicKey = $payplugPublicKey;
		$this->privateKey = $privateKey;
	}

	public function saveInFile($path) {
		file_put_contents($path, $this->toString());
	}

	public function toString() {
		return json_encode($this);
	}
}
lib/payplug/PaymentUrl.php000064400000004450151160401410011600
0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class PaymentUrl {

	public $amount;
	public $currency;
	public $customData;
	public $customer;
	public $email;
	public $firstName;
	public $ipnUrl;
	public $lastName;
	public $order;
	public $origin;
	public $returnUrl;

	public static function generateUrl($params) {
		$config = Payplug::getConfig();
		$data;
		$signature;

		if (! $config) {
			throw new ParametersNotSetException();
		}
		if (! isset($params['amount'])) {
			throw new MissingRequiredParameterException("Missing required
parameter: amount");
		}
		if (! isset($params['currency'])) {
			throw new MissingRequiredParameterException("Missing required
parameter: currency");
		}
		if (! isset($params['ipnUrl'])) {
			throw new MissingRequiredParameterException("Missing required
parameter: ipnUrl");
		}
		if (! preg_match("/^(http|https):\/\//i",
$params['ipnUrl'])) {
			throw new MalformedURLException($params['ipnUrl'] . "
doesn't starts with 'http://' or
'https://'");
		}
		if ($params['returnUrl'] != null && !
preg_match("/^(http|https):\/\//i",
$params['returnUrl'])) {
			throw new MalformedURLException($params['returnUrl'] . "
doesn't starts with 'http://' or
'https://'");
		}


		$url_params = http_build_query(array(
			"amount" => $params['amount'],
			"currency" => $params['currency'],
			"custom_data" => $params['customData'],
			"customer" => $params['customer'],
			"email" => $params['email'],
			"first_name" => $params['firstName'],
			"ipn_url" => $params['ipnUrl'],
			"last_name" => $params['lastName'],
			"order" => $params['order'],
			"origin" => $params['origin'] . "
payplug-php" . Payplug::VERSION . " PHP" . phpversion(),
			"return_url" => $params['returnUrl']
		));
		$data = urlencode(base64_encode($url_params));


		$privateKey = openssl_pkey_get_private($config->privateKey);
		openssl_sign($url_params, $signature, $privateKey, OPENSSL_ALGO_SHA1);
		$signature = urlencode(base64_encode($signature));

		return $config->paymentBaseUrl . "?data=" . $data .
"&sign=" . $signature;
	}
}
lib/payplug/Payplug.php000064400000004677151160401410011134
0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class Payplug {

	const VERSION = "0.9";

	private static $parameters;

	public static function getConfig() {
			return self::$parameters;
	}

	public static function loadParameters($email, $password, $is_test=false)
{
		$answer;
		$configUrl =
'https://www.payplug.fr/portal/ecommerce/autoconfig';
		if ($is_test === true) {
			$configUrl =
'https://www.payplug.fr/portal/test/ecommerce/autoconfig';
		}
		$curlErrNo;
		$curlErrMsg;
		$httpCode;
		$httpMsg;
		$parameters;
		$process = curl_init($configUrl);

		curl_setopt($process, CURLOPT_HEADER, true);
		curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($process, CURLOPT_SSLVERSION,
defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1);
		curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true);
		curl_setopt($process, CURLOPT_SSL_VERIFYHOST, true);
		curl_setopt($process, CURLOPT_USERPWD, $email . ':' .
$password);

		$answer = curl_exec($process);
		$headerSize = curl_getinfo($process, CURLINFO_HEADER_SIZE);
		$httpCode = curl_getinfo($process, CURLINFO_HTTP_CODE);

		$body = substr($answer, $headerSize);
		$headers = substr($answer, 0, $headerSize);
		$headers = explode("\r\n", $headers);

		$httpMsg = explode(" ", $headers[0], 3);

		$httpMsg = @$httpMsg[2];
		$curlErrNo = curl_errno($process);
		$curlErrMsg = curl_error($process);
		curl_close($process);

		if ($curlErrNo == 0) {
			$body = json_decode($body);

			if ($httpCode == 200) {
				$parameters = new Parameters(
					$body->currencies,
					$body->amount_max,
					$body->amount_min,
					$body->url,
					$body->payplugPublicKey,
					$body->yourPrivateKey
				);
			}
			elseif ($httpCode == 401) {
				throw new InvalidCredentialsException();
			}
			else {
				throw new NetworkException("HTTP error ($httpCode) :
$httpMsg", $httpCode);
			}
		}
		else {
			throw new NetworkException("CURL error ($curlErrNo) :
$curlErrMsg", $curlErrNo);
		}

		return $parameters;
	}

	public static function setConfig($parameters) {
		self::$parameters = $parameters;
	}

	public static function setConfigFromFile($path) {
		self::$parameters = Parameters::loadFromFile($path);
	}
}
lib/payplug/PayplugExceptions.php000064400000001330151160401410013155
0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

class PayplugException extends Exception
{
}

class InvalidCredentialsException extends PayplugException
{
}

class InvalidSignatureException extends PayplugException
{
}

class MalformedURLException extends PayplugException
{
}

class NetworkException extends PayplugException
{
}

class ParametersNotSetException extends PayplugException
{
}

class MissingRequiredParameterException extends PayplugException
{
}

lib/payplug.php000064400000003306151160401410007477 0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php

$extensions = array(
	"curl" => "cURL",
	"openssl" => "OpenSSL"
);
$functions = array(
	"base64_decode",
	"base64_encode",
	"json_decode",
	"json_encode",
	"urlencode"
);
$phpMin = "5.2.0";

foreach ($extensions as $name => $title) {
	if (!extension_loaded($name)) {
		throw new Exception("This library needs the $title
extension.");
	}
}
foreach ($functions as $func) {
	if (!function_exists($func)) {
		throw new Exception("This library needs the '$func'
function.");
	}
}

if (!function_exists('getallheaders')) {
	function getallheaders() {
		$headers = array();

		foreach ($_SERVER as $name => $value) {
			if (substr($name, 0, 5) == 'HTTP_') {
				$name = str_replace(' ', '-',
ucwords(strtolower(str_replace('_', ' ', substr($name,
5)))));
				$headers[$name] = $value;
			} else if ($name == "CONTENT_TYPE") {
				$headers["Content-Type"] = $value;
			} else if ($name == "CONTENT_LENGTH") {
				$headers["Content-Length"] = $value;
			} else {
				$headers[$name] = $value;
			}
	   }

	   return $headers;
	}
}

if (version_compare(phpversion(), $phpMin, "<")) {
	throw new Exception("This library needs PHP $phpMin or
newer.");
}

require_once(__DIR__ . '/payplug/IPN.php');
require_once(__DIR__ . '/payplug/Parameters.php');
require_once(__DIR__ . '/payplug/PaymentUrl.php');
require_once(__DIR__ . '/payplug/Payplug.php');
require_once(__DIR__ . '/payplug/PayplugExceptions.php');
payplug.php000064400000016252151160401410006735 0ustar00<?php
/**
 * @package	HikaShop for Joomla!
 * @version	4.4.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2021 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><?php
class plgHikashoppaymentPayplug extends hikashopPaymentPlugin
{
	var $accepted_currencies = array(
		'EUR'
	);

	var $multiple = true;
	var $name = 'payplug';
	var $pluginConfig = array(
		'email' => array('HIKA_EMAIL',
'input'),
		'password' => array('HIKA_PASSWORD',
'input'),
		'debug' => array('DEBUG', 'boolean',
'0'),
		'sandbox' => array('SANDBOX', 'boolean',
'0'),
		'cancel_url' => array('CANCEL_URL',
'input'),
		'return_url' => array('RETURN_URL',
'input'),
		'invalid_status' => array('INVALID_STATUS',
'orderstatus'),
		'verified_status' => array('VERIFIED_STATUS',
'orderstatus')
	);

	function onAfterOrderConfirm(&$order,&$methods,$method_id) {
		parent::onAfterOrderConfirm($order, $methods, $method_id);

		$return_url =
HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$order->order_id.$this->url_itemid;
		$notif_url =
HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment='.$this->name.'&notif_id='.$method_id.'&order_id='.$order->order_id.'&lang='.$this->locale.$this->url_itemid;

		require_once(dirname(__FILE__).'/lib/payplug.php');

		if(!file_exists(HIKASHOP_MEDIA."payplug_parameters.json")) {
			$this->app->enqueueMessage('The file
'.HIKASHOP_MEDIA.'payplug_parameters.json is missing. This file
is generated when you save the settings of your PayPlug payment method. So
please check that the permissions are OK in that folder and save the
settings of the the PayPlug payment method again.');
			return;
		}

		try{
			Payplug::setConfigFromFile(HIKASHOP_MEDIA."payplug_parameters.json");

			$paymentUrl = PaymentUrl::generateUrl(array(
				'amount' =>
(int)(round($order->cart->full_total->prices[0]->price_value_with_tax,2)*100),
				'currency' => 'EUR',
				'ipnUrl' => $notif_url,
				'email' => $this->user->user_email,
				'firstName' =>
@$order->cart->billing_address->address_firstname,
				'lastName' =>
@$order->cart->billing_address->address_lastname,
				'order' => $order->order_id,
				'returnUrl' => $return_url
			));
		}catch(Exception $e){
			$this->app->enqueueMessage($e->getMessage());
			return;
		}
		header("Location: $paymentUrl");
		exit;
	}

	function onPaymentNotification(&$statuses) {
		$method_id = hikaInput::get()->getInt('notif_id', 0);
		$this->pluginParams($method_id);
		$this->payment_params =& $this->plugin_params;
		if(empty($this->payment_params))
			return false;

		$vars = array();
		$filter = JFilterInput::getInstance();
		foreach($_REQUEST as $key => $value) {
			$key = $filter->clean($key);
			$value = hikaInput::get()->getString($key);
			$vars[strtolower($key)] = $value;
		}

		if( @$this->payment_params->debug ) {
			$this->writeToLog( var_export($vars, true) );
		}

		require_once(dirname(__FILE__).'/lib/payplug.php');
		try{
			Payplug::setConfigFromFile(HIKASHOP_MEDIA."payplug_parameters.json");
			$ipn = new IPN();
			if( @$this->payment_params->debug ) {
				$this->writeToLog( var_export($ipn, true) );
			}
		}catch(Exception $e){
			$this->writeToLog($e->getMessage());
			return;
		}

		if(empty($ipn->order) || empty($ipn->state))
			return false;
		$order_id = (int)$ipn->order;

		$dbOrder = $this->getOrder($order_id);
		if(empty($dbOrder)) {
			return false;
		}
		if($method_id != $dbOrder->order_payment_id)
			return false;
		$this->loadOrderData($dbOrder);

		$return_url =
hikashop_completeLink('checkout&task=after_end&order_id='
. $order_id . $this->url_itemid);
		$cancel_url =
hikashop_completeLink('order&task=cancel_order&order_id='
. $order_id . $this->url_itemid);


		$url =
HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='.$order_id.$this->url_itemid;
		$order_text =
"\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',$dbOrder->order_number,HIKASHOP_LIVE);
		$order_text .=
"\r\n".str_replace('<br/>',"\r\n",JText::sprintf('ACCESS_ORDER_WITH_LINK',$url));

		$history = new stdClass();
		$history->notified = 0;
		$history->data = '';
		$email = new stdClass();

		$completed = ($ipn->state == 'paid');
		$amount = (int)(round($dbOrder->order_full_price,2)*100);
		if( !$completed ||$ipn->amount != $amount ) {
			$order_status = $this->payment_params->invalid_status;
			$history->data .= "\n\n" . 'payment with code ' .
$ipn->idTransaction;

			$email->body =
str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','PayPlug',$order_status)).'
'.JText::_('STATUS_NOT_CHANGED')."\r\n\r\n".$order_text;
		 	$email->subject =
JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','PayPlug',$order_status,$dbOrder->order_number);

			$this->modifyOrder($order_id, $order_status, $history,$email);
			return false;
		}

		if($dbOrder->order_status ==
$this->payment_params->verified_status) {
			if( @$this->payment_params->debug ) {
				$this->writeToLog( 'Already confirmed' );
			}
			return true;
		}

		$order_status = $this->payment_params->verified_status;
		$vars['payment_status'] = $ipn->state;
		$history->data .= "\n\n" . 'Transaction id: ' .
$ipn->idTransaction;
		$history->notified = 1;
		$email->subject =
JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','PayPlug',
$vars['payment_status'], $dbOrder->order_number);
		$email->body =
str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS',
'PayPlug', $vars['payment_status'])).'
'.JText::sprintf('ORDER_STATUS_CHANGED',$statuses[$order_status])."\r\n\r\n".$order_text;

		$this->modifyOrder($order_id,$order_status,$history,$email);
		return true;
	}

	function onPaymentConfigurationSave(&$element) {
		$app = JFactory::getApplication();
		if(empty($element->payment_params->email)){
			$app->enqueueMessage(JText::sprintf('ENTER_INFO_REGISTER_IF_NEEDED',
'PayPlug', JText::_('HIKA_EMAIL'), 'PayPlug',
'http://www.payplug.fr'), 'error');
		}elseif(empty($element->payment_params->password)){
			$app->enqueueMessage(JText::sprintf('ENTER_INFO_REGISTER_IF_NEEDED',
'PayPlug', JText::_('HIKA_PASSWORD'),
'PayPlug', 'http://www.payplug.fr'),
'error');
		}else{
			require_once(dirname(__FILE__).'/lib/payplug.php');
			try{
				$parameters =
Payplug::loadParameters($element->payment_params->email,
$element->payment_params->password,
(int)$element->payment_params->sandbox);
				$parameters->saveInFile(HIKASHOP_MEDIA."payplug_parameters.json");
			}catch(Exception $e){
				$msg = $e->getMessage();
				if(empty($msg))
					$msg = 'Error: ' . get_class($e);
				$app->enqueueMessage($msg);
			}
		}
		return true;
	}

	function getPaymentDefaultValues(&$element) {
		$element->payment_name = 'PayPlug';
		$element->payment_description = 'You can pay by credit card using
this payment method';
		$element->payment_images = 'MasterCard,VISA,Credit_card';

		$element->payment_params->email = '';
		$element->payment_params->password = '';
		$element->payment_params->invalid_status = 'cancelled';
		$element->payment_params->verified_status = 'confirmed';
	}
}
payplug.xml000064400000002241151160401410006737 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="plugin" version="1.5"
method="upgrade" group="hikashoppayment">
	<name>Hikashop PayPlug payment plugin</name>
	<creationDate>12 février 2021</creationDate>
	<version>4.4.1</version>
	<author>Hikari Software</author>
	<authorEmail>dev@hikashop.com</authorEmail>
	<authorUrl>http://www.hikashop.com</authorUrl>
	<copyright>(C) 2010-2021 HIKARI SOFTWARE. All rights
reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
	<description>This plugin enables you to setup your PayPlug payment
system</description>
	<files>
		<filename plugin="payplug">payplug.php</filename>
		<folder>lib</folder>
	</files>
	<params addpath="/components/com_hikashop/params">
		<param name="pluginoptions" type="pluginoptions"
default="plugin" label="hikashop"
description="HikaShop options" />
	</params>
	<config>
		<fields name="params"
addfieldpath="/components/com_hikashop/fields">
			<fieldset name="basic">
				<field id="pluginoptions" name="pluginoptions"
type="pluginoptions" label="hikashop"
description="HikaShop options" />
			</fieldset>
		</fields>
	</config>
</extension>