Skip to content

Commit

Permalink
ps16 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Jul 23, 2024
1 parent 781d604 commit f599f44
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
50 changes: 48 additions & 2 deletions controllers/front/notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ public function postProcess()
$secureKey
));

if (!$lockResult->isSuccessful()) {
die($this->module->l('Lock already exist', self::FILENAME));
if (!SaferPayConfig::isVersion17()) {
if ($lockResult > 200) {
die($this->module->l('Lock already exists', self::FILENAME));
}
} else {
if (!$lockResult->isSuccessful()) {
die($this->module->l('Lock already exists', self::FILENAME));
}
}

if ($cart->orderExists()) {
Expand Down Expand Up @@ -96,7 +102,34 @@ public function postProcess()

$checkoutData->setOrderStatus($transactionStatus);

PrestaShopLogger::addLog(
sprintf(
'Order %s has been updated to status %s',
$cart->id,
$transactionStatus
),
1,
null,
null,
null,
true
);

$checkoutProcessor->run($checkoutData);


PrestaShopLogger::addLog(
sprintf(
'Order %s has been updated to status %s',
$cart->id,
$transactionStatus
),
1,
null,
null,
null,
true
);
$orderId = $this->getOrderId($cartId);

//TODO look into pipeline design pattern to use when object is modified in multiple places to avoid this issue.
Expand Down Expand Up @@ -186,6 +219,19 @@ public function postProcess()
die($this->module->l($e->getMessage(), self::FILENAME));
}

PrestaShopLogger::addLog(
sprintf(
'Order %s has been updated to status %s',
$order->reference,
$transactionStatus
),
1,
null,
null,
null,
true
);

die($this->module->l('Success', self::FILENAME));
}

Expand Down
4 changes: 0 additions & 4 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ private function executeTransaction($orderId, $selectedCard)
);
}

private function assertTransaction($cartId) {

}

/**
* @param int $cartId
*
Expand Down
12 changes: 12 additions & 0 deletions src/Controller/AbstractSaferPayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ protected function applyLock($resource)
$this->lock->create($resource);

if (!$this->lock->acquire()) {

if (!SaferPayConfig::isVersion17()) {
return http_response_code(409);
}
return Response::respond(
$this->module->l('Resource conflict', self::FILE_NAME),
Response::HTTP_CONFLICT
Expand All @@ -93,12 +97,20 @@ protected function applyLock($resource)
$logger->payload = $resource;
$logger->save();

if (!SaferPayConfig::isVersion17()) {
return http_response_code(500);
}

return Response::respond(
$this->module->l('Internal error', self::FILE_NAME),
Response::HTTP_INTERNAL_SERVER_ERROR
);
}

if (!SaferPayConfig::isVersion17()) {
return http_response_code(200);
}

return Response::respond(
'',
Response::HTTP_OK
Expand Down

0 comments on commit f599f44

Please sign in to comment.