Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sl 249/transaction status #187

Merged
merged 3 commits into from
Aug 9, 2024
Merged
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
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,16 @@ e2e-1786-prepare:
# Run e2e tests in headless way.
e2eh1786: test-e2e-headless-1786
test-e2e-headless-1786:
make e2e1786p
make e2e1786p

prepare-zip:
rm -rf vendor && \
composer install --no-dev --optimize-autoloader && \
cp .github/.htaccess vendor/.htaccess && \
rm -rf .git .github tests cypress .docker && \
mkdir saferpayofficial && \
rsync -Rr ./ ./saferpayofficial && \
find . -maxdepth 1 ! -name saferpayofficial -exec mv {} saferpayofficial/ \; && \
find . -maxdepth 1 -type f -exec rm "{}" \; && \
cd saferpayofficial && rm -rf saferpayofficial && \
cd ../ && zip -r saferpayofficial.zip saferpayofficial/
51 changes: 0 additions & 51 deletions saferpayofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,6 @@ public function hookActionEmailSendBefore($params)
return true;
}

/** @var \Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */
$canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class);

if ($params['template'] === 'order_conf') {
return $canSendOrderConfirmationEmail->verify((int) $order->current_state);
}

if ($params['template'] === 'new_order') {
if ((int) Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL)) {
return true;
Expand All @@ -607,50 +600,6 @@ public function hookActionEmailSendBefore($params)
}
}

public function hookActionOrderHistoryAddAfter($params = [])
{
/** @var OrderHistory $orderHistory */
$orderHistory = $params['order_history'];

if (!$orderHistory instanceof OrderHistory) {
return;
}

$idOrder = (int) $orderHistory->id_order;

$internalOrder = new Order($idOrder);

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

$order = new Order($idOrder);

$orderStatus = new OrderState((int) $order->current_state);

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

/** @var \Invertus\SaferPay\Service\SaferPayMailService $mailService */
$mailService = $this->getService(\Invertus\SaferPay\Service\SaferPayMailService::class);

/** @var \Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail $canSendOrderConfirmationEmail */
$canSendOrderConfirmationEmail = $this->getService(\Invertus\SaferPay\Core\Order\Verification\CanSendOrderConfirmationEmail::class);

if ($canSendOrderConfirmationEmail->verify((int) $orderStatus->id)) {
try {
$mailService->sendNewOrderMail($order, (int) $orderStatus->id);
} catch (Exception $e) {
// emailalert module sometimes throws error which leads into failed payment issue
}

if ((int) \Configuration::get(\Invertus\SaferPay\Config\SaferPayConfig::SAFERPAY_PAYMENT_AUTHORIZED) === (int) $orderStatus->id) {
$mailService->sendOrderConfMail($order, (int) $orderStatus->id);
}
}
}

public function hookActionAdminControllerSetMedia()
{
if ('AdminOrders' === Tools::getValue('controller') &&
Expand Down
1 change: 1 addition & 0 deletions src/Api/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function post($url, $params = [])
json_encode($params)
);


$this->isValidResponse($response);

return json_decode($response->raw_body);
Expand Down
4 changes: 0 additions & 4 deletions src/Core/Order/Verification/CanSendOrderConfirmationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ private function isOrderStatusValid($orderStatusId)
return true;
}

if ((int) \Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_COMPLETED) === (int) $orderStatusId) {
return true;
}

if ((int) \Configuration::get(SaferPayConfig::STATUS_PS_OS_OUTOFSTOCK_PAID) === (int) $orderStatusId) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions upgrade/install-1.2.3.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function upgrade_module_1_2_3(SaferPayOfficial $module)
$installer->createPendingOrderStatus() &&
Db::getInstance()->execute('ALTER TABLE ' . _DB_PREFIX_ . 'saferpay_order ADD COLUMN `pending` TINYINT(1) DEFAULT 0') &&
$module->registerHook('displayOrderConfirmation') &&
$module->unregisterHook('actionOrderHistoryAddAfter') &&
Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION) &&
Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION);
}
Loading