Skip to content

Commit

Permalink
Merge pull request #88 from Invertus/SL-133-iframe-fail-issues
Browse files Browse the repository at this point in the history
SL-133 iframe fail issues
  • Loading branch information
tomjas1997 authored Nov 16, 2022
2 parents 8e80bf9 + 27a5771 commit 1485c45
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 101 deletions.
7 changes: 0 additions & 7 deletions config/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ services:
Invertus\SaferPay\Service\CartDuplicationService:
class: Invertus\SaferPay\Service\CartDuplicationService

Invertus\SaferPay\Service\SaferPay3DSecureService:
class: Invertus\SaferPay\Service\SaferPay3DSecureService
arguments:
- '@Invertus\SaferPay\Service\SaferPayOrderStatusService'
- '@Invertus\SaferPay\Repository\SaferPayOrderRepository'
- '@Invertus\SaferPay\Service\CartDuplicationService'

Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate:
class: Invertus\SaferPay\Builder\OrderConfirmationMessageTemplate
arguments:
Expand Down
6 changes: 6 additions & 0 deletions controllers/front/fail.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\Controller\AbstractSaferPayController;
use Invertus\SaferPay\Service\CartDuplicationService;
use PrestaShop\PrestaShop\Adapter\Order\OrderPresenter;

class SaferPayOfficialFailModuleFrontController extends AbstractSaferPayController
Expand Down Expand Up @@ -86,6 +87,11 @@ public function init()
if ($order->module !== $this->module->name) {
Tools::redirect($redirectLink);
}

/** @var CartDuplicationService $cartDuplicationService */
$cartDuplicationService = $this->module->getService(CartDuplicationService::class);
$cartDuplicationService->restoreCart($this->id_cart);

$this->order_presenter = new OrderPresenter();
}

Expand Down
11 changes: 3 additions & 8 deletions controllers/front/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\Controller\AbstractSaferPayController;
use Invertus\SaferPay\DTO\Response\Assert\AssertBody;
use Invertus\SaferPay\Repository\SaferPayOrderRepository;
use Invertus\SaferPay\Service\SaferPay3DSecureService;
use Invertus\SaferPay\Service\SaferPayOrderStatusService;
use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAssertion;
use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionRefundAssertion;

class SaferPayOfficialNotifyModuleFrontController extends AbstractSaferPayController
{
Expand Down Expand Up @@ -57,8 +54,8 @@ public function postProcess()
//NOTE must be left below assert action to get newest information.
$order = new Order($orderId);

/** @var SaferPay3DSecureService $secureService */
$secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class);
/** @var SaferPayOrderStatusService $orderStatusService */
$orderStatusService = $this->module->getModuleContainer()->get(SaferPayOrderStatusService::class);

$paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D);

Expand All @@ -67,7 +64,7 @@ public function postProcess()
in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) &&
$paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL
) {
$secureService->cancelPayment($order);
$orderStatusService->cancel($order);

die($this->module->l('Liability shift is false', self::FILENAME));
}
Expand All @@ -81,8 +78,6 @@ public function postProcess()
$paymentBehaviour === SaferPayConfig::DEFAULT_PAYMENT_BEHAVIOR_CAPTURE &&
$assertResponseBody->getTransaction()->getStatus() !== 'CAPTURED'
) {
/** @var SaferPayOrderStatusService $orderStatusService */
$orderStatusService = $this->module->getModuleContainer()->get(SaferPayOrderStatusService::class);
$orderStatusService->capture($order);
}
} catch (Exception $e) {
Expand Down
9 changes: 2 additions & 7 deletions controllers/front/successHosted.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@

use Invertus\SaferPay\Config\SaferPayConfig;
use Invertus\SaferPay\Controller\AbstractSaferPayController;
use Invertus\SaferPay\DTO\Response\Assert\AssertBody;
use Invertus\SaferPay\Enum\ControllerName;
use Invertus\SaferPay\Repository\SaferPayOrderRepository;
use Invertus\SaferPay\Service\SaferPay3DSecureService;
use Invertus\SaferPay\Service\SaferPayOrderStatusService;
use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAuthorization;

Expand Down Expand Up @@ -73,16 +70,14 @@ public function postProcess()
$selectedCard
);

/** @var SaferPay3DSecureService $secureService */
$secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class);

$paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D);

if (
!$authResponseBody->getLiability()->getLiabilityShift() &&
in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) &&
$paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL
) {
$secureService->cancelPayment($order);
$orderStatusService->cancel($order);

$this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME);

Expand Down
17 changes: 4 additions & 13 deletions controllers/front/successIFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
use Invertus\SaferPay\Controller\AbstractSaferPayController;
use Invertus\SaferPay\Enum\ControllerName;
use Invertus\SaferPay\Exception\Api\SaferPayApiException;
use Invertus\SaferPay\Repository\SaferPayOrderRepository;
use Invertus\SaferPay\Service\Request\AuthorizationRequestObjectCreator;
use Invertus\SaferPay\Service\SaferPay3DSecureService;
use Invertus\SaferPay\Service\SaferPayOrderStatusService;
use Invertus\SaferPay\Service\TransactionFlow\SaferPayTransactionAuthorization;

Expand Down Expand Up @@ -78,7 +75,7 @@ public function postProcess()
$this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME);
$this->redirectWithNotifications($this->context->link->getModuleLink(
$this->module->name,
ControllerName::FAIL_VALIDATION,
ControllerName::FAIL_IFRAME,
[
'cartId' => $cartId,
'secureKey' => $secureKey,
Expand All @@ -89,23 +86,20 @@ public function postProcess()
));
}

/** @var SaferPay3DSecureService $secureService */
$secureService = $this->module->getModuleContainer()->get(SaferPay3DSecureService::class);

$paymentBehaviourWithout3DS = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D);

if (
$authResponseBody->getLiability()->getThreeDs() &&
!$authResponseBody->getLiability()->getLiabilityShift() &&
in_array($order->payment, SaferPayConfig::SUPPORTED_3DS_PAYMENT_METHODS) &&
$paymentBehaviourWithout3DS === SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D_CANCEL
) {
$secureService->cancelPayment($order);
$orderStatusService->cancel($order);

$this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME);

$this->redirectWithNotifications($this->context->link->getModuleLink(
$this->module->name,
ControllerName::FAIL,
ControllerName::FAIL_IFRAME,
[
'cartId' => $cartId,
'secureKey' => $secureKey,
Expand All @@ -125,10 +119,7 @@ public function postProcess()
$authResponseBody->getLiability()->getThreeDs()
) {
$orderStatusService->capture($order);
Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey));
}

Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey));
}

public function initContent()
Expand Down
66 changes: 0 additions & 66 deletions src/Service/SaferPay3DSecureService.php

This file was deleted.

0 comments on commit 1485c45

Please sign in to comment.