Skip to content

Commit

Permalink
CET-537/fix: Phpstan complaint about isset($order)
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkwr committed Dec 6, 2024
1 parent 9b728a6 commit b4c6a7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Controller/Payment/Cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function __construct(
*/
public function execute()
{
$order = $this->orderService->getOrderByReference();
try {
$order = $this->orderService->getOrderByReference();
$this->orderService->cancelTwoOrder($order);
$message = __(
'Your invoice purchase with %1 has been cancelled. The cart will be restored.',
Expand All @@ -62,10 +62,9 @@ public function execute()
throw new LocalizedException($message);
} catch (Exception $exception) {
$this->orderService->restoreQuote();
if (isset($order)) {
if ($order) {
$this->orderService->failOrder($order, $exception->getMessage());
}

$this->messageManager->addErrorMessage($exception->getMessage());
return $this->getResponse()->setRedirect($this->_url->getUrl('checkout/cart'));
}
Expand Down
5 changes: 2 additions & 3 deletions Controller/Payment/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public function __construct(
*/
public function execute()
{
$order = $this->orderService->getOrderByReference();
try {
$order = $this->orderService->getOrderByReference();
$twoOrder = $this->orderService->getTwoOrderFromApi($order);
if (isset($twoOrder['state']) && $twoOrder['state'] != 'UNVERIFIED') {
if (in_array($twoOrder['state'], ['VERIFIED', 'CONFIRMED'])) {
Expand Down Expand Up @@ -103,10 +103,9 @@ public function execute()
}
} catch (Exception $exception) {
$this->orderService->restoreQuote();
if (isset($order)) {
if ($order) {
$this->orderService->failOrder($order, $exception->getMessage());
}

$this->messageManager->addErrorMessage($exception->getMessage());
return $this->getResponse()->setRedirect($this->_url->getUrl('checkout/cart'));
}
Expand Down
5 changes: 2 additions & 3 deletions Controller/Payment/Verificationfailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,18 @@ public function __construct(
*/
public function execute()
{
$order = $this->orderService->getOrderByReference();
try {
$order = $this->orderService->getOrderByReference();
$message = __(
'Your invoice purchase with %1 failed verification. The cart will be restored.',
$this->configRepository::PROVIDER
);
throw new LocalizedException($message);
} catch (Exception $exception) {
$this->orderService->restoreQuote();
if (isset($order)) {
if ($order) {
$this->orderService->failOrder($order, $exception->getMessage());
}

$this->messageManager->addErrorMessage($exception->getMessage());
return $this->getResponse()->setRedirect($this->_url->getUrl('checkout/cart'));
}
Expand Down

0 comments on commit b4c6a7c

Please sign in to comment.