first commit

This commit is contained in:
2024-11-05 12:22:50 +01:00
commit e5682a3912
19641 changed files with 2948548 additions and 0 deletions

View File

@@ -0,0 +1,365 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/../../core/core.php');
require_once(dirname(__FILE__).'/paymentStatus.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class Paylane3dsValidationModuleFrontController extends ModuleFrontController
{
protected $orderConfirmationUrl = 'index.php?controller=order-confirmation';
public function isOldPresta()
{
return version_compare(_PS_VERSION_, '1.7', '<');
}
public function postProcess()
{
if ($this->isOldPresta()) {
$this->postProcess16();
return;
}
$cartId = (int)Tools::getValue('cart_id');
PrestaShopLogger::addLog('process return url', 1, null, 'Cart', $cartId, true);
$orderId = Order::getOrderByCartId($cartId);
PrestaShopLogger::addLog('order id:', 1, null, 'Order', $orderId, true);
$payment = Tools::getValue('payment_method');
if ($payment == 'CREDITCARD') {
$payment = 'CreditCard';
}
if (isset($payment)) {
require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $payment . '.php');
$paylane = new Paylane();
$handler = new $payment($paylane);
try {
$responseStatus = $this->getResponseStatus();
$result = $handler->handle3DSPayment($responseStatus);
if ($result['success']) {
$responseStatus['transaction_id'] = $result['id_sale'];
if (isset($result['order_status'])) {
$orderStatus = $result['order_status'];
} else {
$orderStatus = 'CLEARED';
}
$responseStatus['paylane_status'] = $orderStatus;
$responseStatus['status'] = PaylanePaymentCore::paymentStatus($responseStatus['paylane_status']);
} else {
$errorStatus = PaylanePaymentCore::getErrorMessage(
array('error_text' => $result['error']['error_description'])
);
$this->redirectError($errorStatus);
}
} catch (Exception $e) {
$errorStatus = PaylanePaymentCore::getErrorMessage(array('error_text' => $e->getMessage()));
$this->redirectError($errorStatus);
}
} else {
$responseStatus = $this->getResponseStatus();
}
//$responseStatus = $this->getResponseStatus();
//$result = $this->handle3DSPayment($responseStatus);
PrestaShopLogger::addLog('Paylane - return url order ID:'. $orderId, 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $responseStatus); //LK
if ($orderId) {
PrestaShopLogger::addLog('validate order', 1, null, 'Cart', $cartId, true);
$this->validateOrder($cartId, $responseStatus['transaction_id']);
} else {
PrestaShopLogger::addLog('prestashop order not found', 1, null, 'Cart', $cartId, true);
//$this->checkPaymentStatus($cartId, $responseStatus); //LK
}
}
protected function getResponseStatus() {
$responseStatus = array();
$responseStatus['paylane_status'] = Tools::getValue('status');
$responseStatus['status'] = PaylanePaymentCore::paymentStatus($responseStatus['paylane_status']);
$responseStatus['amount'] = Tools::getValue('amount');
$responseStatus['currency'] = Tools::getValue('currency');
$responseStatus['description'] = Tools::getValue('description');
$responseStatus['hash'] = Tools::getValue('hash');
$responseStatus['transaction_id'] = Tools::getValue('id_sale');
$responseStatus['payment_method'] = (Tools::getValue('payment_method')) ? Tools::getValue('payment_method') : Tools::getValue('payment_type');
$responseStatus['error_code'] = Tools::getValue('error_code');
$responseStatus['error_text'] = Tools::getValue('error_text');
$responseStatus['id_3dsecure_auth'] = Tools::getValue('id_3dsecure_auth');
return $responseStatus;
}
protected function validateOrder($cartId, $transactionId)
{
$order = $this->module->getOrderByTransactionId($transactionId);
PrestaShopLogger::addLog('transaction log order : '.print_r($order, true), 1, null, 'Cart', $cartId, true);
if (empty($order) || empty($order['order_status'])) {
PrestaShopLogger::addLog('Paylane - status url late', 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $transactionId);
} elseif ($order['order_status'] == $this->module->failedStatus) {
$paymentResponse = unserialize($order['payment_response']);
$errorStatus = PaylanePaymentCore::getErrorMessage($paymentResponse);
$this->redirectError($errorStatus);
} else {
if ($this->context->cart->OrderExists() == false) {
$responseStatus = $this->getResponseStatus();
PrestaShopLogger::addLog('Paylane - check order from return url', 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $responseStatus);
} else {
PrestaShopLogger::addLog(
'Paylane - redirect success validate return url',
1,
null,
'Cart',
$cartId,
true
);
$this->redirectSuccess($cartId);
}
}
}
protected function checkPaymentStatus($cartId, $responseStatus)
{
$cart = $this->context->cart;
$fieldParams = array();
PrestaShopLogger::addLog('Paylane - check Payment Status', 1, null, 'Cart', $cartId, true);
PrestaShopLogger::addLog(
'Paylane - check payment status:'. print_r($responseStatus, true),
1,
null,
'Cart',
$cartId,
true
);
if (isset($responseStatus) && $responseStatus['status'] !== '-2') {
$PaymentStatus = new PaylanePaymentStatusModuleFrontController();
$isTransactionLogValid = $PaymentStatus->isTransactionLogValid($responseStatus['transaction_id']);
if (!$isTransactionLogValid) {
$orderTotal = $responseStatus['amount'];
$transactionLog = $PaymentStatus->setTransactionLog($orderTotal, $responseStatus);
PrestaShopLogger::addLog('Paylane - transactionLog: '. print_r($transactionLog, true), 1, null, 'Cart', $cartId, true);
$generatedMd5Sig = $this->module->generateMd5sig($responseStatus);
$isPaymentSignatureEqualsGeneratedSignature =
$this->module->isPaymentSignatureEqualsGeneratedSignature(
$responseStatus['hash'],
$generatedMd5Sig
);
$generatedAntiFraudHash = $this->module->generateAntiFraudHash(
$cartId,
$responseStatus['payment_method'],
$cart->date_add
);
$isFraud = $this->module->isFraud($generatedAntiFraudHash, Tools::getValue('secure_method'));
$additionalInformation =
$PaymentStatus->getAdditionalInformation(
$responseStatus,
$isPaymentSignatureEqualsGeneratedSignature,
$isFraud
);
PrestaShopLogger::addLog(
'Paylane - save transaction log from return URL',
1,
null,
'Cart',
$cartId,
true
);
$PaymentStatus->saveTransactionLog($transactionLog, 0, $additionalInformation);
$PaymentStatus->validatePayment($cartId, $responseStatus, $responseStatus['status']);
}
$this->redirectSuccess($cartId);
} elseif (isset($responseStatus) && $responseStatus['status'] == '-2') {
$PaymentStatus = new PaylanePaymentStatusModuleFrontController();
$currency = $this->context->currency;
$customer = new Customer($cart->id_customer);
$this->module->validateOrder(
(int)$cart->id,
$PaymentStatus->getPaymentStatus($responseStatus),
$amount = sprintf('%01.2f', $cart->getOrderTotal()),
$this->getPaymentName($responseStatus['payment_method']),
null,
array(),
(int)$currency->id,
false,
$customer->secure_key
);
$errorStatus = PaylanePaymentCore::getErrorMessage($responseStatus);
$this->redirectError($errorStatus);
} else {
$this->redirectPaymentReturn();
}
}
protected function getPaymentName($paymentType)
{
$paymentMethod = PaylanePaymentCore::getPaymentMethodByPaymentType($paymentType);
if ($this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType) == 'PAYLANE_FRONTEND_PM_'.$paymentType) {
$paymentName = $paymentMethod['name'];
} else {
$paymentName = $this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType);
}
$isPaylane = strpos($paymentName, 'Paylane');
if ($isPaylane === false) {
$paymentName = 'Paylane '.$paymentName;
}
return $paymentName;
}
protected function redirectError($returnMessage)
{
$this->errors[] = $returnMessage;
$this->redirectWithNotifications($this->context->link->getPageLink('order', true, null, array(
'step' => '3')));
}
protected function redirectPaymentReturn()
{
$url = $this->context->link->getModuleLink('paylane', 'paymentReturn', array(
'secure_key' => $this->context->customer->secure_key), true);
PrestaShopLogger::addLog('rediret to payment return : '.$url, 1, null, 'Cart', $this->context->cart->id, true);
Tools::redirect($url);
exit;
}
protected function redirectSuccess($cartId)
{
Tools::redirect(
$this->orderConfirmationUrl.
'&id_cart='.$cartId.
'&id_module='.(int)$this->module->id.
'&key='.$this->context->customer->secure_key
);
}
public function postProcess16()
{
if (method_exists('Tools', 'getAllValues')) {
$params = Tools::getAllValues();
} else {
$params = $_POST + $_GET;
}
if (isset($params['payment']) && isset($params['payment']['additional_information'])) {
$paymentParams = $params['payment']['additional_information'];
} else {
$paymentParams = null;
}
$idSale = null;
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_FAILED');
$displayName = $this->module->displayName;
if (!isset($params['payment_type'])){
$params['payment_type'] = 'CreditCard';
}
if (isset($params['payment_type'])) {
require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $params['payment_type'] . '.php');
$paylane = Module::getInstanceByName('paylane');
$paymentParams = $params;
$handler = new $params['payment_type']($paylane);
$result = $handler->handle3DSPayment($paymentParams);
if ($result['success']) {
$idSale = $result['id_sale'];
if (isset($result['order_status'])) {
$orderStatus = $result['order_status'];
} else {
$orderStatus = Configuration::get('PS_OS_PAYMENT');
}
}
$paymentLabelPath = 'paylane_' . Tools::strtolower($params['payment_type']) . '_label';
$displayName .= ' | ' . Configuration::get($paymentLabelPath);
}
$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}
$customer = new Customer($cart->id_customer);
$currency = $this->context->currency;
$amount = sprintf('%01.2f', $cart->getOrderTotal());
$extraVars = null;
if (!is_null($idSale)) {
$extraVars = array(
'transaction_id' => $idSale
);
}
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$this->module->validateOrder(
(int)$cart->id,
$orderStatus,
$amount,
$displayName,
null,
$extraVars,
(int)$currency->id,
false,
$customer->secure_key
);
$redirectUrl = 'index.php?controller=order-confirmation&id_cart=';
$redirectUrl .= (int)$cart->id.'&id_module='.(int)$this->module->id;
$redirectUrl .= '&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key;
Tools::redirect($redirectUrl);
}
}

View File

@@ -0,0 +1,138 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
/**
* Only Prestashop 1.6
*/
class PaylaneGeneralModuleFrontController extends ModuleFrontController
{
const STATUS_ERROR = 'ERROR';
const STATUS_CLEARED = 'CLEARED';
const STATUS_PENDING = 'PENDING';
const STATUS_PERFORMED = 'PERFORMED';
public $ssl = true;
/**
* @see FrontController::postProcess()
*/
public function postProcess()
{
$cookie = Context::getContext()->cookie;
$paymentType = $cookie->payment_type;
if (!$paymentType) {
Tools::redirect('index.php?controller=order&step=1');
}
if (method_exists('Tools', 'getAllValues')) {
$params = Tools::getAllValues();
} else {
$params = $_POST + $_GET;
}
$status = $params['status'];
$amount = $params['amount'];
$currency = $params['currency'];
$cartId = $params['description'];
$hash = $params['hash'];
$idSale = isset($params['id_sale']) ? $params['id_sale'] : null;
$hashSalt = Configuration::get('PAYLANE_GENERAL_HASH');
$hashCode = $hashSalt . '|' . $status . '|' . $cartId . '|';
$hashCode .= $amount . '|' . $currency . '|' . $idSale;
$hashComputed = sha1($hashCode);
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_FAILED');
if ($hash === $hashComputed) {
if ($status === self::STATUS_PENDING) {
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_PENDING');
}
//if ($status === self::STATUS_PERFORMED) {
// $orderStatus = Configuration::get('paylane_order_performed_status');
//}
if ($status === self::STATUS_CLEARED || $status === self::STATUS_PERFORMED) {
$orderStatus = Configuration::get('PS_OS_PAYMENT');
}
if ($status === self::STATUS_ERROR) {
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_FAILED');
}
} else {
Tools::redirect('index.php?controller=order&step=1');
}
$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}
$customer = new Customer($cart->id_customer);
$currency = $this->context->currency;
$extraVars = null;
if (!is_null($idSale)) {
$extraVars = array(
'transaction_id' => $idSale
);
}
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$displayName = $this->module->displayName . ' | ' . Configuration::get('paylane_'.$paymentType.'_label');
unset($cookie->payment_type);
if( !($idOrder = Order::getOrderByCartId($cartId)) ) {
$this->module->validateOrder(
(int)$cartId,
$orderStatus,
$amount,
$displayName,
null,
$extraVars,
(int)$currency->id,
false,
$customer->secure_key
);
} else {
$order = new Order($idOrder);
$order->setCurrentState($orderStatus);
}
$redirectUrl = 'index.php?controller=order-confirmation&id_cart=';
$redirectUrl .= (int)$cart->id.'&id_module='.(int)$this->module->id;
$redirectUrl .= '&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key;
Tools::redirect($redirectUrl);
}
}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;

View File

@@ -0,0 +1,169 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
class Order16 extends Order {
public static function getOrderByCartId_Paylane($id_cart)
{
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'orders`
WHERE `id_cart` = '.(int)$id_cart
.Shop::addSqlRestriction();
$result = Db::getInstance()->getRow($sql);
return isset($result['id_order']) ? new self((int) $result['id_order']) : null;
}
}
class PaylaneNotificationModuleFrontController extends ModuleFrontController
{
const NOTIFICATION_TYPE_SALE = 'S';
const NOTIFICATION_TYPE_REFUND = 'R';
public $ssl = true;
public function initContent()
{
if ($this->isOldPresta()) {
parent::initContent();
}
if (method_exists('Tools', 'getAllValues')) {
$params = Tools::getAllValues();
} else {
$params = $_POST + $_GET;
}
if (!empty(Configuration::get('PAYLANE_NOTIFICATION_USER')) && !empty(Configuration::get('PAYLANE_NOTIFICATION_PASSWORD'))) {
if (!isset($_SERVER['PHP_AUTH_USER'])
|| !isset($_SERVER['PHP_AUTH_PW'])
|| Configuration::get('PAYLANE_NOTIFICATION_USER') != $_SERVER['PHP_AUTH_USER']
|| Configuration::get('PAYLANE_NOTIFICATION_PASSWORD') != $_SERVER['PHP_AUTH_PW']) {
$this->failAuthorization();
}
}
if (empty($params['communication_id'])) {
die('Empty communication id');
}
if (!empty($params['token']) && Configuration::get('PAYLANE_NOTIFICATION_TOKEN') !== $params['token']) {
die('Wrong token');
}
$this->handleAutoMessages($params['content']);
die($params['communication_id']);
}
protected function failAuthorization()
{
// authentication failed
header("WWW-Authenticate: Basic realm=\"Secure Area\"");
header("HTTP/1.0 401 Unauthorized");
exit();
}
public function isOldPresta()
{
return version_compare(_PS_VERSION_, '1.7', '<');
}
protected function handleAutoMessages($messages)
{
foreach ($messages as $message) {
if (empty($message['text'])) {
// Message without Prestashop cart ID - skip
continue;
}
$idSale = $message['id_sale'];
$cartId = $message['text'];
$amount = $message['amount'];
$currCode = $message['currency_code'];
$transType = $message['type'];
// Get order by id_cart
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
if ($this->isOldPresta()) {
$order = Order16::getOrderByCartId_Paylane($cartId);
} else {
$order = Order::getByCartId($cartId);
}
if (empty($order))
{
$cart = new Cart($cartId);
$customer = new Customer($cart->id_customer);
$currency = new Currency($cart->id_currency);
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$this->module->validateOrder(
$cart->id,
Configuration::get('PS_OS_PAYMENT'),
$total,
$this->module->displayName,
null,
array(),
(int)$currency->id,
false,
$customer->secure_key
);
$orderId = Order::getByCartId($cartId);
$db->update('order_payment', array(
'transaction_id' => $idSale,
'payment_method' => $orderId->payment
), 'order_reference = "'.$orderId->reference.'"');
}
if (!empty($order)) {
if ((float) $order->total_paid !== (float) $amount) {
die('Wrong amount');
}
switch ($message['type']) {
case self::NOTIFICATION_TYPE_SALE:
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_CLEARED');
$order->setCurrentState($orderStatus);
$db->update('order_payment', array(
'transaction_id' => $idSale,
'payment_method' => $order->payment
), 'order_reference = "'.$order->reference.'"');
break;
case self::NOTIFICATION_TYPE_REFUND:
break;
default:
die('Unrecognized message type (' . $message['type'] . ')');
}
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
/**
* Only Prestashop 1.6
*/
class PaylanePaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;
public function __construct()
{
parent::__construct();
$this->display_column_left = false;
}
/**
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}
//if is submit data create order
// if(!empty(Tools::getValue('description')) && !Order::getOrderByCartId(Tools::getValue('description'))) {
// $this->createOrder();
// }
if (method_exists('Tools', 'getAllValues')) {
$params = Tools::getAllValues();
} else {
$params = $_POST + $_GET;
}
if (!isset($params) || !isset($params['payment_type'])) {
Tools::redirect('index.php?controller=order');
} else {
if ($params['payment_type'] == 'Blik') {
$file_name = 'BLIK';
} else {
$file_name = $params['payment_type'];
}
require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $file_name . '.php');
$paylane = Module::getInstanceByName('paylane');
$handler = new $params['payment_type']($paylane);
$templateVars = $handler->getTemplateVars();
$pathSsl = Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/';
$this->context->smarty->assign(array_merge(array(
'nbProducts' => $cart->nbProducts(),
'this_path' => $this->module->getPathUri(),
'this_path_bw' => $this->module->getPathUri(),
'this_path_ssl' => $pathSsl
), $templateVars));
if ($params['payment_type'] === 'PayPal') {
$params['payment_type'] = 'Paypal';
}
$this->setTemplate('payment_form/' . $this->toSnakeCase($params['payment_type']) . '16.tpl');
//?paypal
}
}
protected function toSnakeCase($input)
{
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
foreach ($ret as &$match) {
$match = $match == Tools::strtoupper($match) ? Tools::strtolower($match) : lcfirst($match);
}
return implode('_', $ret);
}
protected function createOrder(){
die(
$this->module->validateOrder(
(int)$this->context->cart->id,
(int)Configuration::get('PAYLANE_PAYMENT_STATUS_PENDING'),
sprintf('%01.2f', $this->context->cart->getOrderTotal(true, Cart::BOTH)),
'Paylane ',
null,
[],
(int)$this->context->cart->id_currency,
false,
$this->context->customer->secure_key
)
);
}
}

View File

@@ -0,0 +1,224 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/../../core/core.php');
class PaylanePaymentAbstractModuleFrontController extends ModuleFrontController
{
protected $paymentMethod = '';
protected $paymentClass = '';
protected $templateName = 'module:paylane/views/templates/front/paylane_PAYMENT_METHOD.tpl';
//protected $templateName16 = _PS_MODULE_DIR_ . 'paylane/views/templates/front/payment_form/payment16_PAYMENT_METHOD.tpl';
public $ssl = true;
public $display_column_left = false;
public function initContent()
{
parent::initContent();
$cart = $this->context->cart;
$messageLog =
'Paylane - start payment process, method : '. $this->paymentMethod .
' by customer id : ' . $cart->id_customer;
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cart->id, true);
PrestaShopLogger::addLog('Paylane - get post parameters', 1, null, 'Cart', $cart->id, true);
$postParameters = $this->getPostParameters();
$messageLog = 'Paylane - post parameters : ' . print_r($postParameters, true);
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cart->id, true);
PrestaShopLogger::addLog('Paylane - get widget url', 1, null, 'Cart', $cart->id, true);
$redirectUrl = $this->getRedirectUrl();
PrestaShopLogger::addLog('Paylane - widget url : ' . $redirectUrl, 1, null, 'Cart', $cart->id, true);
$this->context->smarty->assign(array(
'fullname' => $this->context->customer->firstname ." ". $this->context->customer->lastname,
'lang' => $this->getLang(),
'redirectUrl' => $redirectUrl, //paylane response
'postParameters' => $postParameters,
'paymentMethod' => $this->paymentMethod,
'total' => $this->context->cart->getOrderTotal(true, Cart::BOTH),
));
/*
if ($this->isOldPresta()) {
$this->context->smarty->assign($this->getTemplateVars());
$templateName = str_replace(
'PAYMENT_METHOD', strtolower($this->paymentMethod), $this->templateName16
);
$this->context->smarty->fetch($templateName);
} else {
$templateName = str_replace(
'PAYMENT_METHOD', strtolower($this->paymentMethod), $this->templateName
);
$this->setTemplate($templateName);
}
*/
$templateName = str_replace(
'PAYMENT_METHOD', strtolower($this->paymentMethod), $this->templateName
);
$this->setTemplate($templateName);
}
protected function isOldPresta()
{
return version_compare(_PS_VERSION_, '1.7', '<');
}
protected function getRedirectUrl() {
return PaylanePaymentCore::getPaylaneRedirectUrl();
}
private function redirectError($returnMessage)
{
$this->errors[] = $this->module->getLocaleErrorMapping($returnMessage);
$this->redirectWithNotifications($this->context->link->getPageLink('order', true, null, array(
'step' => '3')));
}
private function getPostParameters()
{
$cart = $this->context->cart;
$contextLink = $this->context->link;
$customer = new Customer($cart->id_customer);
$address = new Address((int)$cart->id_address_delivery);
$country = new Country($address->id_country);
$currency = new Currency((int)$cart->id_currency);
$cartDetails = $cart->getSummaryDetails();
$dateTime = PaylanePaymentCore::getDateTime();
$paylaneSettings = $this->getPaylaneSettings();
if (empty($paylaneSettings['merchant_id'])
|| empty($paylaneSettings['hash'])
) {
$messageLog = 'Paylane - general setting is not completed. either of the parameter is not filled';
PrestaShopLogger::addLog($messageLog, 3, null, 'Cart', $cart->id, true);
$this->redirectError('ERROR_GENERAL_REDIRECT');
}
$postParameters = array();
$postParameters['merchant_id'] = $paylaneSettings['merchant_id'];
$postParameters['public_key_api'] = $paylaneSettings['public_key_api'];
$postParameters['transaction_id'] = str_pad((int)($cart->id), 4, "0", STR_PAD_LEFT);
$postParameters['return_url'] = $contextLink->getModuleLink(
'paylane',
'validation',
array('cart_id' => $cart->id, 'secure_key' => $customer->secure_key, 'payment_method' => $this->paymentMethod),
true
);
$postParameters['3dsreturn_url'] = $contextLink->getModuleLink(
'paylane',
'3dsvalidation',
array('cart_id' => $cart->id, 'secure_key' => $customer->secure_key, 'payment_method' => $this->paymentMethod),
true
);
$postParameters['status_url'] = $this->getStatusUrl();
$postParameters['cancel_url'] = $contextLink->getPageLink('order', true, null, array('step' => '3'));
$postParameters['language'] = strtolower($this->getLang());
$postParameters['customer_email'] = $this->context->customer->email;
$postParameters['customer_firstname'] = $this->context->customer->firstname;
$postParameters['customer_lastname'] = $this->context->customer->lastname;
$postParameters['customer_address'] = $address->address1;
$postParameters['customer_zip'] = $address->postcode;
$postParameters['customer_city'] = $address->city;
$postParameters['customer_country'] = $country->iso_code;
$postParameters['amount'] = $cart->getOrderTotal(true, Cart::BOTH);
$postParameters['hash'] = PaylanePaymentCore::generateHash(
str_pad((int)($cart->id), 4, "0", STR_PAD_LEFT),
(float)($cart->getOrderTotal(true)),
$currency->iso_code,
'S'
);
$postParameters['transaction_type'] = 'S';
$postParameters['currency'] = $currency->iso_code;
$postParameters['transaction_description'] = $this->getProductsName($cart->getProducts());
$messageLog = 'Paylane - get post parameters : ' . print_r($postParameters, true);
return array_merge($postParameters, $this->getTemplateVars());
}
protected function getTemplateVars() {
return array();
}
private function getProductsName($products)
{
$description = array();
foreach($products as $product) {
$description[] = $product['name'];
}
return implode(',', $description);
}
private function getStatusUrl()
{
$cart = $this->context->cart;
$cartId = $this->context->cart->id;
$paymentMethod = $this->paymentMethod;
$cartDate = $cart->date_add;
$statusUrl = $this->context->link->getModuleLink(
'paylane',
'paymentStatus',
array(
'payment_method' => $this->paymentMethod,
'cart_id' => $cartId,
'payment_key' => $this->module->generateAntiFraudHash($cartId, $paymentMethod, $cartDate)
),
true
);
return $statusUrl;
}
private function getLang()
{
$cart = $this->context->cart;
$language = new Language((int)$cart->id_lang);
$languageCode = $language->iso_code;
return Tools::strtoupper($languageCode);
}
private function getPaylaneSettings()
{
$paylaneSettings = array();
$paylaneSettings['merchant_id'] = Configuration::get('PAYLANE_GENERAL_MERCHANTID');
$paylaneSettings['hash'] = Configuration::get('PAYLANE_GENERAL_HASH');
$paylaneSettings['login_api'] = Configuration::get('PAYLANE_GENERAL_LOGIN_API');
$paylaneSettings['public_key_api'] = Configuration::get('PAYLANE_GENERAL_PUBLIC_KEY_API');
$paylaneSettings['password_api'] = Configuration::get('PAYLANE_GENERAL_PASSWORD_API');
return $paylaneSettings;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/ApplePay.php');
class PaylanePaymentApplepayModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'APPLEPAY';
public function getTemplateVars()
{
$payment = new ApplePay();
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,40 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/BankTransfer.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class PaylanePaymentBanktransferModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'BANKTRANSFER';
public function getTemplateVars()
{
$paylane = new Paylane();
$payment = new BankTransfer($paylane);
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/BLIK.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class PaylanePaymentBlikModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'BLIK';
public function getTemplateVars()
{
$paylane = new Paylane();
$payment = new Blik($paylane);
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/CreditCard.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class PaylanePaymentCreditcardModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'CREDITCARD';
public function getTemplateVars()
{
$paylane = new Paylane();
$payment = new CreditCard($paylane);
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/DirectDebit.php');
class PaylanePaymentDirectdebitModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'DIRECTDEBIT';
public function getTemplateVars()
{
$payment = new DirectDebit();
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/GooglePay.php');
class PaylanePaymentGooglePayModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'GOOGLEPAY';
public function getTemplateVars()
{
$payment = new GooglePay();
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/Ideal.php');
class PaylanePaymentIdealModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'IDEAL';
public function getTemplateVars()
{
$payment = new Ideal();
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/PayPal.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class PaylanePaymentPaypalModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'PAYPAL';
public function getTemplateVars()
{
$paylane = new Paylane();
$payment = new PayPal($paylane);
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,38 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
class PaylanePaymentReturnModuleFrontController extends ModuleFrontController
{
public function initContent()
{
parent::initContent();
$this->context->smarty->assign(array(
'shop_name' => $this->context->shop->name
));
$this->setTemplate('module:paylane/views/templates/front/payment_return.tpl');
}
}

View File

@@ -0,0 +1,37 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
class PaylanePaymentSecureformModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'SECUREFORM';
protected function getRedirectUrl() {
return PaylanePaymentCore::getPaylaneRedirectSecureFormUrl();
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/paymentAbstract.php');
require_once(_PS_MODULE_DIR_ . 'paylane/class/Sofort.php');
class PaylanePaymentSofortModuleFrontController extends PaylanePaymentAbstractModuleFrontController
{
protected $paymentMethod = 'SOFORT';
public function getTemplateVars()
{
$payment = new Sofort();
return $payment->getTemplateVars();
}
}

View File

@@ -0,0 +1,381 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
class PaylanePaymentStatusModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$status = Tools::getValue('status');
if ($status) {
$cartId = Tools::getValue('cart_id');
$orderId = Order::getOrderByCartId($cartId);
Context::getContext()->cart = new Cart((int)$cartId);
PrestaShopLogger::addLog('Paylane - use status_url', 1, null, 'Cart', $cartId, true);
PrestaShopLogger::addLog('Paylane - get payment response from status_url', 1, null, 'Cart', $cartId, true);
$paymentResponse = $this->getPaymentResponse();
$messageLog = 'Paylane - payment response from status_url : ' . print_r($paymentResponse, true);
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cartId, true);
$orderId = Order::getOrderByCartId($cartId);
$isTransactionLogValid = $this->isTransactionLogValid($paymentResponse['transaction_id']);
$order = $this->module->getOrderByTransactionId($paymentResponse['transaction_id']);
if (!$isTransactionLogValid) {
$cart = $this->context->cart;
$orderTotal = $paymentResponse['amount'];
$transactionLog = $this->setTransactionLog($orderTotal, $paymentResponse);
$generatedMd5Sig = $this->module->generateMd5sig($paymentResponse);
$isPaymentSignatureEqualsGeneratedSignature = $this->module->isPaymentSignatureEqualsGeneratedSignature(
$paymentResponse['md5sig'],
$generatedMd5Sig
);
$generatedAntiFraudHash = $this->module->generateAntiFraudHash(
$cartId,
$this->getPaymentMethod(),
$cart->date_add
);
$isFraud = $this->module->isFraud($generatedAntiFraudHash, Tools::getValue('secure_payment'));
$additionalInformation =
$this->getAdditionalInformation(
$paymentResponse,
$isPaymentSignatureEqualsGeneratedSignature,
$isFraud
);
PrestaShopLogger::addLog(
'Paylane - save transaction log from status URL',
1,
null,
'Cart',
$cartId,
true
);
$this->saveTransactionLog($transactionLog, 0, $additionalInformation);
if ($orderId) {
$order = $this->module->getOrderByTransactionId($paymentResponse['transaction_id']);
$messageLog = 'Paylane - use status_url on existed order';
PrestaShopLogger::addLog($messageLog, 1, null, 'Order', $orderId, true);
if ($order['order_status'] == $this->module->pendingStatus) {
$messageLog = 'Paylane - use status_url on pending status';
PrestaShopLogger::addLog($messageLog, 1, null, 'Order', $orderId, true);
$this->updateTransactionLog($paymentResponse, $order['id_order']);
$this->module->updatePaymentStatus($order['id_order'], $paymentResponse['status']);
}
die('ok');
}
$this->validatePayment($cartId, $paymentResponse);
}
} else {
$messageLog = 'Paylane - no payment response from gateway';
PrestaShopLogger::addLog($messageLog, 3, null, 'Cart', 0, true);
die('no response from gateway.');
}
die('end');
}
public function validatePayment($cartId, $paymentResponse, $status = '')
{
Context::getContext()->cart = new Cart((int)$cartId);
$cart = $this->context->cart;
Context::getContext()->currency = new Currency((int)$cart->id_currency);
$customer = new Customer($cart->id_customer);
$messageLog =
'Paylane - Module Status : '. $this->module->active .
', Customer Id : '. $cart->id_customer .
', Delivery Address : '. $cart->id_address_delivery .
', Invoice Address : '. $cart->id_address_invoice;
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cart->id, true);
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0
|| $cart->id_address_invoice == 0 || !$this->module->active
|| !Validate::isLoadedObject($customer)) {
PrestaShopLogger::addLog('Paylane - customer datas are not valid', 3, null, 'Cart', $cart->id, true);
die('Erreur etc.');
}
$this->processSuccessPayment($customer, $paymentResponse, $status);
}
protected function processSuccessPayment($customer, $paymentResponse, $status)
{
$cart = $this->context->cart;
$cartId = $cart->id;
$currency = $this->context->currency;
if ($paymentResponse['status'] == $this->module->clearedStatus
|| $paymentResponse['status'] == $this->module->pendingStatus
|| $paymentResponse['status'] == $this->module->performedStatus
) {
$generatedMd5Sig = $this->module->generateMd5sig($paymentResponse);
$isPaymentSignatureEqualsGeneratedSignature =
$this->module->isPaymentSignatureEqualsGeneratedSignature(
$paymentResponse['hash'],
$generatedMd5Sig
);
$generatedAntiFraudHash =
$this->module->generateAntiFraudHash($cartId, $this->getPaymentMethod(), $cart->date_add);
$isFraud = false;
if (!empty(Tools::getValue('payment_key'))) {
$isFraud = $this->module->isFraud($generatedAntiFraudHash, Tools::getValue('payment_key'));
}
if (!$isPaymentSignatureEqualsGeneratedSignature && !empty($paymentResponse['hash'])) {
$paymentResponse['status'] = $this->module->failedStatus;
$messageLog = 'Paylane - invalid credential detected';
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cartId, true);
} elseif ($isFraud) {
$paymentResponse['status'] = $this->module->fraudStatus;
$messageLog = 'Paylane - fraud detected';
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cartId, true);
}
} else {
$errorMessage = 'PAYLANE_ERROR_99_GENERAL';
if ($paymentResponse['status'] == $this->module->failedStatus
&& isset($paymentResponse['error_code'])) {
$errorMessage = $this->getErrorMessage($paymentResponse);
}
$messageLog = 'Paylane - order has not been successfully created : '. $errorMessage;
PrestaShopLogger::addLog($messageLog, 3, null, 'Cart', $cartId, true);
die('payment failed');
}
$orderTotal = $paymentResponse['amount'];
$transactionLog = $this->setTransactionLog($orderTotal, $paymentResponse);
PrestaShopLogger::addLog('Paylane - get payment status', 1, null, 'Cart', $cartId, true);
if (!empty($status)) {
$paymentResponse['status'] = $status;
}
$paymentStatus = $this->getPaymentStatus($paymentResponse);
PrestaShopLogger::addLog('Paylane - payment status : '. $paymentStatus, 1, null, 'Cart', $cartId, true);
if(!($idOrder = Order::getOrderByCartId($cartId)) ) {
$this->module->validateOrder(
$cartId,
$paymentStatus,
$transactionLog['amount'],
$transactionLog['payment_name'],
null,
array(),
$currency->id,
false,
$customer->secure_key
);
}
// } else {
// $order = new Order($idOrder);
// $order->setCurrentState($paymentStatus);
// }
$orderId = $this->module->currentOrder;
$this->context->cookie->paylane_paymentName = $transactionLog['payment_name'];
$serializedResponse = serialize($paymentResponse);
$this->updateTransactionLog(
$paymentResponse['transaction_id'],
$paymentResponse,
$serializedResponse,
$orderId
);
$messageLog = 'Paylane - order ('. $orderId .') has been successfully created';
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $cartId, true);
}
protected function getPaymentResponse()
{
$paymentResponse = array();
foreach ($_REQUEST as $parameter => $value) {
$parameter = Tools::strtolower($parameter);
$paymentResponse[$parameter] = $value;
}
$paymentResponse['paylane_status'] = $paymentResponse['status'];
$paymentResponse['status'] = PaylanePaymentCore::paymentStatus($paymentResponse['paylane_status']);
return $paymentResponse;
}
public function getPaymentStatus($paymentResponse)
{
switch ($paymentResponse['status']) {
case $this->module->pendingStatus:
return Configuration::get('PAYLANE_PAYMENT_STATUS_PENDING');
case $this->module->performedStatus:
return Configuration::get('PAYLANE_PAYMENT_STATUS_PERFORMED');
case $this->module->failedStatus:
return Configuration::get('PAYLANE_PAYMENT_STATUS_FAILED');
default:
return Configuration::get('PS_OS_PAYMENT');
}
}
public function setTransactionLog($orderTotal, $paymentResponse)
{
$transactionLog = array();
$transactionLog['transaction_id'] = $paymentResponse['transaction_id'];
$transactionLog['payment_type'] = $this->getPaymentType($paymentResponse);
$transactionLog['payment_method'] = 'PAYLANE_FRONTEND_PM_'.$this->getPaymentMethod();
$transactionLog['payment_name'] = $this->getPaymentName($transactionLog['payment_type']);
$transactionLog['status'] = $paymentResponse['status'];
$transactionLog['currency'] = $paymentResponse['currency'];
$transactionLog['amount'] = $this->getPaymentAmount($orderTotal, $paymentResponse);
$transactionLog['payment_response'] = serialize($paymentResponse);
return $transactionLog;
}
protected function getPaymentMethod()
{
return (Tools::getValue('payment_method')) ? Tools::getValue('payment_method') : Tools::getValue('payment_type');
}
protected function getPaymentType($paymentResponse)
{
return $paymentResponse['payment_method'];
}
protected function getPaymentName($paymentType)
{
$paymentMethod = PaylanePaymentCore::getPaymentMethodByPaymentType($paymentType);
if ($this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType) == 'PAYLANE_FRONTEND_PM_'.$paymentType) {
$paymentName = $paymentMethod['name'];
} else {
$paymentName = $this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType);
}
$isPaylane = strpos($paymentName, 'Paylane');
if ($isPaylane === false) {
$paymentName = 'Paylane '.$paymentName;
}
return $paymentName;
}
protected function getPaymentAmount($orderTotal, $paymentResponse)
{
if (!empty($paymentResponse['amount'])) {
return $paymentResponse['amount'];
}
return $orderTotal;
}
public function getAdditionalInformation($paymentResponse, $isFraud)
{
$additionalInfo = array();
if (isset($paymentResponse['ip_country'])) {
$additionalInfo['PAYLANE_BACKEND_ORDER_ORIGIN'] = $paymentResponse['ip_country'];
}
if ($isFraud) {
$additionalInfo['BACKEND_TT_FRAUD'] = $paymentResponse['status'];
}
return serialize($additionalInfo);
}
public function saveTransactionLog($transactionLog, $orderId, $additionalInformation)
{
$sql = "INSERT INTO "._DB_PREFIX_."endora_paylane_order_ref (
id_order,
transaction_id,
payment_method,
order_status,
ref_id,
payment_code,
currency,
amount,
add_information,
payment_response
)
VALUES "."('".
(int)$orderId."','".
pSQL($transactionLog['transaction_id'])."','".
pSQL($transactionLog['payment_method'])."','".
pSQL($transactionLog['status'])."','".
pSQL($transactionLog['transaction_id'])."','".
pSQL($transactionLog['payment_type'])."','".
pSQL($transactionLog['currency'])."','".
(float)$transactionLog['amount']."','".
pSQL($additionalInformation)."','".
pSQL($transactionLog['payment_response']).
"')";
PrestaShopLogger::addLog('Paylane - save transaction log : ' . $sql, 1, null, 'Order', $orderId, true);
if (!Db::getInstance()->execute($sql)) {
PrestaShopLogger::addLog('Paylane - failed when saving transaction log', 3, null, 'Order', $orderId, true);
die('Erreur etc.');
}
PrestaShopLogger::addLog('Paylane - transaction log succefully saved', 1, null, 'Order', $orderId, true);
}
protected function updateTransactionLog($transactionId, $paymentResponse, $serializedResponse, $orderId)
{
$sql = "UPDATE "._DB_PREFIX_."endora_paylane_order_ref SET
id_order = '".pSQL($orderId)."',
order_status = '".pSQL($paymentResponse['status'])."',
payment_response = '".pSQL($serializedResponse)."'
where transaction_id = '".pSQL($transactionId)."'";
$messageLog = 'Paylane - update payment response from status_url : ' . $sql;
PrestaShopLogger::addLog($messageLog, 1, null, 'Order', $orderId, true);
if (!Db::getInstance()->execute($sql)) {
$messageLog = 'Paylane - failed when updating payment response from status_url';
PrestaShopLogger::addLog($messageLog, 3, null, 'Order', $orderId, true);
die('Erreur etc.');
}
PrestaShopLogger::addLog('Paylane - status_url response succefully updated', 1, null, 'Order', $orderId, true);
}
public function isTransactionLogValid($transactionId)
{
$order = $this->module->getOrderByTransactionId($transactionId);
// var_dump($order);exit;
$messageLog = 'Paylane - existing order : ' . print_r($order, true);
PrestaShopLogger::addLog($messageLog, 1, null, 'Cart', $this->context->cart->id, true);
if (!empty($order)) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,358 @@
<?php
/*
* 2005-2016 PayLane sp. z.o.o.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@Paylane.pl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PayLane to newer
* versions in the future. If you wish to customize PayLane for your
* needs please refer to http://www.Paylane.pl for more information.
*
* @author PayLane <info@paylane.pl>
* @copyright 2005-2019 PayLane sp. z.o.o.
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PayLane sp. z.o.o.
*/
require_once(dirname(__FILE__).'/../../core/core.php');
require_once(dirname(__FILE__).'/paymentStatus.php');
require_once(_PS_MODULE_DIR_ . 'paylane/paylane.php');
class PaylaneValidationModuleFrontController extends ModuleFrontController
{
protected $orderConfirmationUrl = 'index.php?controller=order-confirmation';
public function isOldPresta()
{
return version_compare(_PS_VERSION_, '1.7', '<');
}
public function postProcess()
{
if ($this->isOldPresta()) {
$this->postProcess16();
return;
}
$cartId = (int)Tools::getValue('cart_id');
PrestaShopLogger::addLog('process return url', 1, null, 'Cart', $cartId, true);
$orderId = Order::getOrderByCartId($cartId);
PrestaShopLogger::addLog('order id:', 1, null, 'Order', $orderId, true);
$payment = Tools::getValue('payment');
$paymentParams = null;
if (isset($payment) && isset($payment['additional_information'])) {
$paymentParams = $payment['additional_information'];
}
if (isset($paymentParams['type'])) {
require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $paymentParams['type'] . '.php');
$paylane = new Paylane();
$handler = new $paymentParams['type']($paylane);
try {
$responseStatus = $this->getResponseStatus();
$result = $handler->handlePayment($paymentParams);
if ($result['success']) {
$responseStatus['transaction_id'] = $result['id_sale'];
if (isset($result['order_status'])) {
$orderStatus = $result['order_status'];
} else {
$orderStatus = 'CLEARED';
}
$responseStatus['paylane_status'] = $orderStatus;
$responseStatus['status'] = PaylanePaymentCore::paymentStatus($responseStatus['paylane_status']);
} else {
$errorStatus = PaylanePaymentCore::getErrorMessage(
array('error_text' => $result['error']['error_description'])
);
$this->redirectError($errorStatus);
}
} catch (Exception $e) {
$errorStatus = PaylanePaymentCore::getErrorMessage(array('error_text' => $e->getMessage()));
$this->redirectError($errorStatus);
}
} else {
$responseStatus = $this->getResponseStatus();
}
PrestaShopLogger::addLog('Paylane - return url order ID:'. $orderId, 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $responseStatus); //LK
if ($orderId) {
PrestaShopLogger::addLog('validate order', 1, null, 'Cart', $cartId, true);
$this->validateOrder($cartId, $responseStatus['transaction_id']);
} else {
PrestaShopLogger::addLog('prestashop order not found', 1, null, 'Cart', $cartId, true);
//$this->checkPaymentStatus($cartId, $responseStatus); //LK
}
}
protected function getResponseStatus() {
$responseStatus = array();
$responseStatus['paylane_status'] = Tools::getValue('status');
$responseStatus['status'] = PaylanePaymentCore::paymentStatus($responseStatus['paylane_status']);
$responseStatus['amount'] = Tools::getValue('amount');
$responseStatus['currency'] = Tools::getValue('currency');
$responseStatus['description'] = Tools::getValue('description');
$responseStatus['hash'] = Tools::getValue('hash');
$responseStatus['transaction_id'] = Tools::getValue('id_sale');
$responseStatus['payment_method'] = (Tools::getValue('payment_method')) ? Tools::getValue('payment_method') : Tools::getValue('payment_type');
$responseStatus['error_code'] = Tools::getValue('error_code');
$responseStatus['error_text'] = Tools::getValue('error_text');
return $responseStatus;
}
protected function validateOrder($cartId, $transactionId)
{
$order = $this->module->getOrderByTransactionId($transactionId);
PrestaShopLogger::addLog('transaction log order : '.print_r($order, true), 1, null, 'Cart', $cartId, true);
if (empty($order) || empty($order['order_status'])) {
PrestaShopLogger::addLog('Paylane - status url late', 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $transactionId);
} elseif ($order['order_status'] == $this->module->failedStatus) {
$paymentResponse = unserialize($order['payment_response']);
$errorStatus = PaylanePaymentCore::getErrorMessage($paymentResponse);
$this->redirectError($errorStatus);
} else {
if ($this->context->cart->OrderExists() == false) {
$responseStatus = $this->getResponseStatus();
PrestaShopLogger::addLog('Paylane - check order from return url', 1, null, 'Cart', $cartId, true);
$this->checkPaymentStatus($cartId, $responseStatus);
} else {
PrestaShopLogger::addLog(
'Paylane - redirect success validate return url',
1,
null,
'Cart',
$cartId,
true
);
$this->redirectSuccess($cartId);
}
}
}
protected function checkPaymentStatus($cartId, $responseStatus)
{
$cart = $this->context->cart;
$fieldParams = array();
PrestaShopLogger::addLog('Paylane - check Payment Status', 1, null, 'Cart', $cartId, true);
PrestaShopLogger::addLog(
'Paylane - check payment status:'. print_r($responseStatus, true),
1,
null,
'Cart',
$cartId,
true
);
if (isset($responseStatus) && $responseStatus['status'] !== '-2') {
$PaymentStatus = new PaylanePaymentStatusModuleFrontController();
$isTransactionLogValid = $PaymentStatus->isTransactionLogValid($responseStatus['transaction_id']);
if (!$isTransactionLogValid) {
$orderTotal = $responseStatus['amount'];
$transactionLog = $PaymentStatus->setTransactionLog($orderTotal, $responseStatus);
PrestaShopLogger::addLog('Paylane - transactionLog: '. print_r($transactionLog, true), 1, null, 'Cart', $cartId, true);
$generatedMd5Sig = $this->module->generateMd5sig($responseStatus);
$isPaymentSignatureEqualsGeneratedSignature =
$this->module->isPaymentSignatureEqualsGeneratedSignature(
$responseStatus['hash'],
$generatedMd5Sig
);
$generatedAntiFraudHash = $this->module->generateAntiFraudHash(
$cartId,
$responseStatus['payment_method'],
$cart->date_add
);
$isFraud = $this->module->isFraud($generatedAntiFraudHash, Tools::getValue('secure_method'));
$additionalInformation =
$PaymentStatus->getAdditionalInformation(
$responseStatus,
$isPaymentSignatureEqualsGeneratedSignature,
$isFraud
);
PrestaShopLogger::addLog(
'Paylane - save transaction log from return URL',
1,
null,
'Cart',
$cartId,
true
);
$PaymentStatus->saveTransactionLog($transactionLog, 0, $additionalInformation);
$PaymentStatus->validatePayment($cartId, $responseStatus, $responseStatus['status']);
}
$this->redirectSuccess($cartId);
} elseif (isset($responseStatus) && $responseStatus['status'] == '-2') {
$PaymentStatus = new PaylanePaymentStatusModuleFrontController();
$currency = $this->context->currency;
$customer = new Customer($cart->id_customer);
$this->module->validateOrder(
(int)$cart->id,
$PaymentStatus->getPaymentStatus($responseStatus),
$amount = sprintf('%01.2f', $cart->getOrderTotal()),
$this->getPaymentName($responseStatus['payment_method']),
null,
array(),
(int)$currency->id,
false,
$customer->secure_key
);
$errorStatus = PaylanePaymentCore::getErrorMessage($responseStatus);
$this->redirectError($errorStatus);
} else {
$this->redirectPaymentReturn();
}
}
protected function getPaymentName($paymentType)
{
$paymentMethod = PaylanePaymentCore::getPaymentMethodByPaymentType($paymentType);
if ($this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType) == 'PAYLANE_FRONTEND_PM_'.$paymentType) {
$paymentName = $paymentMethod['name'];
} else {
$paymentName = $this->module->l('PAYLANE_FRONTEND_PM_'.$paymentType);
}
$isPaylane = strpos($paymentName, 'Paylane');
if ($isPaylane === false) {
$paymentName = 'Paylane '.$paymentName;
}
return $paymentName;
}
protected function redirectError($returnMessage)
{
$this->errors[] = $returnMessage;
$this->redirectWithNotifications($this->context->link->getPageLink('order', true, null, array(
'step' => '3')));
}
protected function redirectPaymentReturn()
{
$url = $this->context->link->getModuleLink('paylane', 'paymentReturn', array(
'secure_key' => $this->context->customer->secure_key), true);
PrestaShopLogger::addLog('rediret to payment return : '.$url, 1, null, 'Cart', $this->context->cart->id, true);
Tools::redirect($url);
exit;
}
protected function redirectSuccess($cartId)
{
Tools::redirect(
$this->orderConfirmationUrl.
'&id_cart='.$cartId.
'&id_module='.(int)$this->module->id.
'&key='.$this->context->customer->secure_key
);
}
public function postProcess16()
{
if (method_exists('Tools', 'getAllValues')) {
$params = Tools::getAllValues();
} else {
$params = $_POST + $_GET;
}
if (isset($params['payment']) && isset($params['payment']['additional_information'])) {
$paymentParams = $params['payment']['additional_information'];
} else {
$paymentParams = null;
}
$idSale = null;
$orderStatus = Configuration::get('PAYLANE_PAYMENT_STATUS_FAILED');
$displayName = $this->module->displayName;
if (isset($params['payment_type'])) {
require_once(_PS_MODULE_DIR_ . 'paylane/class/' . $params['payment_type'] . '.php');
$paylane = Module::getInstanceByName('paylane');
$handler = new $params['payment_type']($paylane);
$result = $handler->handlePayment($paymentParams);
if ($result['success']) {
$idSale = $result['id_sale'];
if (isset($result['order_status'])) {
$orderStatus = $result['order_status'];
} else {
$orderStatus = Configuration::get('PS_OS_PAYMENT');
}
}
$paymentLabelPath = 'paylane_' . Tools::strtolower($params['payment_type']) . '_label';
$displayName .= ' | ' . Configuration::get($paymentLabelPath);
}
$cart = $this->context->cart;
if (!$this->module->checkCurrency($cart)) {
Tools::redirect('index.php?controller=order');
}
$customer = new Customer($cart->id_customer);
$currency = $this->context->currency;
$amount = sprintf('%01.2f', $cart->getOrderTotal());
$extraVars = null;
if (!is_null($idSale)) {
$extraVars = array(
'transaction_id' => $idSale
);
}
if (!Validate::isLoadedObject($customer)) {
Tools::redirect('index.php?controller=order&step=1');
}
$this->module->validateOrder(
(int)$cart->id,
$orderStatus,
$amount,
$displayName,
null,
$extraVars,
(int)$currency->id,
false,
$customer->secure_key
);
$redirectUrl = 'index.php?controller=order-confirmation&id_cart=';
$redirectUrl .= (int)$cart->id.'&id_module='.(int)$this->module->id;
$redirectUrl .= '&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key;
Tools::redirect($redirectUrl);
}
}