Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions controllers/admin/AdminSaferPayOfficialFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function initOptions()
'type' => 'select-template',
'name' => SaferPayConfig::HOSTED_FIELDS_TEMPLATE,
'templateOptions' => [
"{$this->module->getPathUri()}views/img/hosted-templates/template1.jpg",
"{$this->module->getPathUri()}views/img/hosted-templates/template2.jpg",
"{$this->module->getPathUri()}views/img/hosted-templates/template3.jpg",
$this->module->getPathUri() . 'views/img/hosted-templates/template1.jpg',
$this->module->getPathUri() . 'views/img/hosted-templates/template2.jpg',
$this->module->getPathUri() . 'views/img/hosted-templates/template3.jpg',
],
],
],
Expand Down
1 change: 1 addition & 0 deletions controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected function processGetStatus()

/** @var LoggerInterface $logger */
$logger = $this->module->getService(LoggerInterface::class);

$logger->debug(sprintf('%s - Controller action ended', self::FILE_NAME), [
'context' => [
'cart_id' => $cartId,
Expand Down
6 changes: 3 additions & 3 deletions controllers/front/creditCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function initCardList()
'card_number' => $savedCard['card_number'],
'payment_method' => $savedCard['payment_method'],
'date_add' => $savedCard['date_add'],
'card_img' => "{$this->module->getPathUri()}views/img/{$savedCard['payment_method']}.png",
'card_img' => $this->module->getPathUri() . 'views/img/' . $savedCard['payment_method'] . '.png',
'controller' => self::FILE_NAME,
]);

Expand Down Expand Up @@ -102,9 +102,9 @@ public function postProcess()

if ($cardAlias->delete()) {
$this->success[] = $this->module->l('Successfully removed credit card', self::FILE_NAME);
return;
} else {
$this->errors[] = $this->module->l('Failed to remove credit card', self::FILE_NAME);
}
$this->errors[] = $this->module->l('Failed to removed credit card', self::FILE_NAME);
}

$logger->debug(sprintf('%s - Controller action ended', self::FILE_NAME));
Expand Down
5 changes: 1 addition & 4 deletions controllers/front/fail.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ public function initContent()
$this->context->language->id,
[
'action' => 'show',
],
false,
null,
false
]
)
);
}
Expand Down
7 changes: 3 additions & 4 deletions controllers/front/failIFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ public function setMedia()
'secureKey' => $secureKey,
'orderId' => $orderId,
'moduleId' => $moduleId,
],
true
]
);

$this->context->controller->registerStylesheet(
$this->module->name .'-iframe-css',
$this->module->name . '-iframe-css',
'modules/' . $this->module->name . '/views/css/front/loading.css'
);

Expand All @@ -98,7 +97,7 @@ public function setMedia()
]);

$this->context->controller->registerJavascript(
$this->module->name .'-iframe-js',
$this->module->name . '-iframe-js',
'/modules/' . $this->module->name . '/views/js/front/saferpay_iframe.js'
);
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/front/failValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*@license SIX Payment Services
*/

use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\Controller\AbstractSaferPayController;
use Invertus\SaferPay\Logger\LoggerInterface;
use Invertus\SaferPay\Repository\SaferPayOrderRepository;
Expand Down Expand Up @@ -77,7 +78,7 @@ public function postProcess()
$saferPayOrder->update();

$cartDuplicationService->restoreCart($cartId);
$isBusinessLicence = Tools::getValue(\Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE);
$isBusinessLicence = Tools::getValue(SaferPayConfig::IS_BUSINESS_LICENCE);
$controller = $isBusinessLicence ? 'failIFrame' : 'fail';

$failUrl = $this->context->link->getModuleLink(
Expand Down
53 changes: 29 additions & 24 deletions controllers/front/hostedIframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ public function initContent()
$selectedCard = Tools::getValue("selectedCreditCard_{$paymentMethod}");

$this->context->smarty->assign([
'credit_card_front_url' => "{$this->module->getPathUri()}views/img/example-card/credit-card-front.png",
'credit_card_back_url' => "{$this->module->getPathUri()}views/img/example-card/credit-card-back.png",
'tos_cms' => SaferPayConfig::isVersionAbove177() ? $this->getDefaultTermsAndConditions() : null,
'credit_card_front_url' => $this->module->getPathUri() .'views/img/example-card/credit-card-front.png',
'credit_card_back_url' => $this->module->getPathUri() . 'views/img/example-card/credit-card-back.png',
'tos_cms' => $this->getDefaultTermsAndConditions(),
'saferpay_selected_card' => $selectedCard,
]);

$logger->debug(sprintf('%s - Controller action ended', self::FILE_NAME));

$this->setTemplate(
SaferPayConfig::SAFERPAY_HOSTED_TEMPLATE_LOCATION .
'template' .
Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) .
'.tpl'
);
$this->setTemplate(SaferPayConfig::SAFERPAY_HOSTED_TEMPLATE_LOCATION . 'template' . Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) . '.tpl');

}

Expand All @@ -79,14 +74,16 @@ public function setMedia()
$this->context->controller->registerJavascript(
'remote-saferpay-fields-js-lib',
Configuration::get(SaferPayConfig::FIELDS_LIBRARY . SaferPayConfig::getConfigSuffix()),
['server' => 'remote', 'position' => 'bottom', 'priority' => 20]
[
'server' => 'remote',
'position' => 'bottom',
'priority' => 20,
]
);

$this->context->controller->registerJavascript(
'hosted-template-js-init',
'modules/' . $this->module->name . '/views/js/front/hosted-templates/template' .
Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) .
".js"
'modules/' . $this->module->name . '/views/js/front/hosted-templates/template' . Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) . '.js'
);
$this->context->controller->registerJavascript(
'hosted-template-js-submit',
Expand All @@ -95,29 +92,37 @@ public function setMedia()

$this->context->controller->registerStylesheet(
'theme-css',
'modules/' . $this->module->name . '/views/css/front/hosted-templates/template' .
Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) .
".css"
'modules/' . $this->module->name . '/views/css/front/hosted-templates/template' . Configuration::get(SaferPayConfig::HOSTED_FIELDS_TEMPLATE) . '.css'
);
}

protected function getDefaultTermsAndConditions()
{
$cms = new CMS((int) Configuration::get('PS_CONDITIONS_CMS_ID'), $this->context->language->id);
if (!SaferPayConfig::isVersionAbove177()) {
return null;
}

$cms = new CMS(
(int) Configuration::get('PS_CONDITIONS_CMS_ID'),
$this->context->language->id
);

if (!Validate::isLoadedObject($cms)) {
return false;
}

$link = $this->context->link->getCMSLink($cms, $cms->link_rewrite, (bool) Configuration::get('PS_SSL_ENABLED'));
$link = $this->context->link->getCMSLink(
$cms,
$cms->link_rewrite,
(bool) Configuration::get('PS_SSL_ENABLED')
);

$termsAndConditions = new TermsAndConditions();
$termsAndConditions
->setText(
'[' . $cms->meta_title . ']',
$link
)
->setIdentifier('terms-and-conditions-footer');
$termsAndConditions->setText(
'[' . $cms->meta_title . ']',
$link
)
->setIdentifier('terms-and-conditions-footer');

return $termsAndConditions->format();
}
Expand Down
18 changes: 15 additions & 3 deletions controllers/front/iframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,25 @@ public function postProcess()
$logger->debug(sprintf('%s - Controller called', self::FILE_NAME));

$cart = $this->context->cart;

$redirectLink = $this->context->link->getPageLink(
'order',
true,
null,
null,
[
'step' => 1,
]
);

if (!Validate::isLoadedObject($cart)) {
$logger->error(sprintf('%s - Cart not found', self::FILE_NAME), [
'context' => [],
'exceptions' => [],
]);

Tools::redirect($redirectLink);
}

if ($cart->id_customer == 0
|| $cart->id_address_delivery == 0
|| $cart->id_address_invoice == 0
Expand All @@ -63,12 +74,14 @@ public function postProcess()
}

$authorized = false;

foreach (Module::getPaymentModules() as $module) {
if ($module['name'] === $this->module->name) {
$authorized = true;
break;
}
}

if (!$authorized) {
$this->errors[] = $this->module->l('This payment method is not available.', self::FILE_NAME);

Expand Down Expand Up @@ -122,8 +135,7 @@ public function initContent()
'orderId' => Order::getIdByCartId($this->context->cart->id),
'secureKey' => $this->context->cart->secure_key,
'moduleId' => $this->module->id,
],
true
]
);
$this->redirectWithNotifications($redirectUrl);
}
Expand Down
32 changes: 14 additions & 18 deletions controllers/front/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function postProcess()

$logger->debug(sprintf('%s - Controller called', self::FILE_NAME), [
'context' => [],
'HTTP_STATUS_CODE' => http_response_code(),
'status_code' => http_response_code(),
]);

$cartId = Tools::getValue('cartId');
Expand Down Expand Up @@ -99,7 +99,10 @@ public function postProcess()

$awaitingState = \Configuration::get(SaferPayConfig::SAFERPAY_ORDER_STATE_CHOICE_AWAITING_PAYMENT);

if ($cartAdapter->orderExists($cartId) && $order->getCurrentState() != $awaitingState && $order->payment != SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT) {
if ($cartAdapter->orderExists($cartId)
&& $order->getCurrentState() != $awaitingState
&& $order->payment != SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT
) {
$logger->debug(sprintf('%s - Order already created. Dying.', self::FILE_NAME), [
'context' => [
'id_order' => $order->id,
Expand All @@ -124,11 +127,7 @@ public function postProcess()
(int) $cart->id,
$assertResponseBody->getPaymentMeans()->getBrand()->getPaymentMethod(),
(int) Configuration::get(SaferPayConfig::IS_BUSINESS_LICENCE),
-1,
null,
null,
false,
1
-1
);

$checkoutData->setOrderStatus($transactionStatus);
Expand All @@ -140,9 +139,9 @@ public function postProcess()
//NOTE must be left below assert action to get newest information.
$order = new Order($orderId);

if (!$assertResponseBody->getLiability()->getLiabilityShift() &&
in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) &&
(int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D) === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL
if (null === $assertResponseBody->getLiability()->getLiabilityShift()
&& in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS)
&& (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D) === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL
) {
/** @var SaferPayOrderStatusService $orderStatusService */
$orderStatusService = $this->module->getService(SaferPayOrderStatusService::class);
Expand All @@ -154,12 +153,6 @@ public function postProcess()
],
]);

$logger->debug(sprintf('%s - liability shift is false', self::FILE_NAME), [
'context' => [
'id_order' => $order->id,
],
]);

die($this->module->l('Liability shift is false', self::FILE_NAME));
}

Expand All @@ -169,8 +162,8 @@ public function postProcess()

// if payment does not support order capture, it means it always auto-captures it (at least with accountToAccount payment),
// so in this case if status comes back "captured" we just update the order state accordingly
if (!SaferPayConfig::supportsOrderCapture($paymentMethod) &&
$transactionStatus === TransactionStatus::CAPTURED
if (!SaferPayConfig::supportsOrderCapture($paymentMethod)
&& $transactionStatus === TransactionStatus::CAPTURED
) {
$logger->debug(sprintf('%s - order completed', self::FILE_NAME), [
'context' => [
Expand All @@ -180,6 +173,7 @@ public function postProcess()

/** @var SaferPayOrderStatusService $orderStatusService */
$orderStatusService = $this->module->getService(SaferPayOrderStatusService::class);

$orderStatusService->setComplete($order);

return;
Expand All @@ -197,6 +191,7 @@ public function postProcess()

/** @var SaferPayOrderStatusService $orderStatusService */
$orderStatusService = $this->module->getService(SaferPayOrderStatusService::class);

$orderStatusService->capture($order);
}
} catch (Exception $e) {
Expand Down Expand Up @@ -238,6 +233,7 @@ public function postProcess()

$saferPayOrder->update();
$this->releaseLock();

die($this->module->l('canceled'));
}

Expand Down
Loading