roykin/modules/be2bill/notification.php
2016-10-21 11:39:06 +02:00

49 lines
1.6 KiB
PHP

<?php
/**
* 1997-2016 Quadra Informatique
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0) that is available
* through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0
* If you are unable to obtain it through the world-wide-web, please send an email
* to modules@quadra-informatique.fr so we can send you a copy immediately.
*
* @author Quadra Informatique <modules@quadra-informatique.fr>
* @copyright 1997-2016 Quadra Informatique
* @license http://www.opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/classes/Be2billApi.php');
/* Retrieve the classes needed from all modules installed */
require_once(_PS_MODULE_DIR_.'be2bill/classes/Be2billNotification.php');
require_once(_PS_MODULE_DIR_.'be2bill/be2bill.php');
$parameters = $_GET;
/* Extract hash value */
$hash = $parameters['HASH'];
unset($parameters['HASH']);
if (isset($parameters['EXTRADATA'])) {
$account = $parameters['EXTRADATA'];
$account = explode('-', $account);
}
if (!$account) {
$id_account = (int)MerchandConfiguration::getIdByReference($parameters['ORDERID']);
$option = $parameters['OPERATIONTYPE'];
} else {
$id_account = (int) $account[1];
$option = $account[2];
}
/* Validate hash */
if ($hash == Be2billApi::buildHash($parameters, $id_account)) {
$classe = new Be2billNotification();
$classe->notify('be2bill', $id_account, $option);
echo 'OK';
} else {
/* If Bad Hash */
die('Corrupt received data!');
}