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

PIPRES-489/PrestaShop 9 compatibility #1014

Draft
wants to merge 13 commits into
base: release-6.2.5
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ env.MODULE_NAME }}
path: ./
path: ./
12 changes: 12 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ services:
- '@subscription_options_data_provider'
- 'subscription_options': 'Mollie\Subscription\Form\Options\SubscriptionOptionsType'
- 'SubscriptionOptions'

Mollie\Subscription\Controller\Symfony\SubscriptionFAQController:
class: Mollie\Subscription\Controller\Symfony\SubscriptionFAQController
public: true
autoconfigure: true
autowire: true # Optional, but useful for dependency injection

Mollie\Subscription\Controller\Symfony\SubscriptionController:
class: Mollie\Subscription\Controller\Symfony\SubscriptionController
public: true
autowire: true
autoconfigure: true
13 changes: 8 additions & 5 deletions controllers/admin/AdminMollieAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class AdminMollieAjaxController extends ModuleAdminController
public function postProcess()
{
$action = Tools::getValue('action');

$this->context->smarty->assign('bootstrap', true);

switch ($action) {
case 'togglePaymentMethod':
$this->togglePaymentMethod();
Expand Down Expand Up @@ -80,7 +83,7 @@ private function togglePaymentMethod()
}
$method->update();

$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'success' => true,
'paymentStatus' => (int) $method->enabled,
Expand All @@ -100,7 +103,7 @@ private function resendPaymentMail()

$response = $molliePaymentMailService->sendSecondChanceMail($orderId);

$this->ajaxDie(json_encode($response));
$this->ajaxRender(json_encode($response));
}

/**
Expand All @@ -119,7 +122,7 @@ private function testApiKeys()
$apiKeysTestInfo = $apiTestFeedbackBuilder->buildParams();

$this->context->smarty->assign($apiKeysTestInfo);
$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'template' => $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/api_test_results.tpl'),
]
Expand All @@ -141,7 +144,7 @@ private function validateLogo()
$returnText = '';
// Check image format
if ('jpg' !== $imageFileType && 'png' !== $imageFileType) {
$returnText = $this->l('Upload a .jpg or .png file.');
$returnText = $this->module->l('Upload a .jpg or .png file.');
$isUploaded = 0;
}

Expand All @@ -151,7 +154,7 @@ private function validateLogo()
$returnText = basename($_FILES['fileToUpload']['name']);
} else {
$isUploaded = 0;
$returnText = $this->l('Something went wrong when uploading your logo.');
$returnText = $this->module->l('Something went wrong when uploading your logo.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminMollieLogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected function ajaxResponse($value = null, $controller = null, $method = nul
$logger = $this->module->getService(LoggerInterface::class);

try {
$this->ajaxDie($value, $controller, $method);
$this->ajaxRender($value, $controller, $method);
} catch (\Exception $exception) {
$logger->error('Could not return ajax response', [
'context' => [
Expand Down
4 changes: 2 additions & 2 deletions controllers/admin/AdminMollieSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public function postProcess()

Media::addJsDef([
'description_message' => addslashes($this->module->l('Enter a description')),
'min_amount_message' => addslashes($this->l('You have entered incorrect min amount')),
'max_amount_message' => addslashes($this->l('You have entered incorrect max amount')),
'min_amount_message' => addslashes($this->module->l('You have entered incorrect min amount')),
'max_amount_message' => addslashes($this->module->l('You have entered incorrect max amount')),

'payment_api' => addslashes(Mollie\Config\Config::MOLLIE_PAYMENTS_API),
'ajaxUrl' => addslashes($this->context->link->getAdminLink('AdminMollieAjax')),
Expand Down
12 changes: 6 additions & 6 deletions controllers/front/applePayDirectAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function getApplePaySession()
);
$response = $handler->handle($command);

$this->ajaxDie(json_encode($response));
$this->ajaxRender(json_encode($response));
}

private function updateShippingMethod()
Expand All @@ -94,7 +94,7 @@ private function updateShippingMethod()
);
$response = $handler->handle($command);

$this->ajaxDie(json_encode($response));
$this->ajaxRender(json_encode($response));
}

private function updateAppleShippingContact()
Expand Down Expand Up @@ -142,7 +142,7 @@ private function updateAppleShippingContact()
];
}

$this->ajaxDie(json_encode($result));
$this->ajaxRender(json_encode($result));
}

private function createApplePayOrder()
Expand All @@ -167,21 +167,21 @@ private function createApplePayOrder()
);
$response = $handler->handle($command);
if (!$response['success']) {
$this->ajaxDie(json_encode($response));
$this->ajaxRender(json_encode($response));
}

//we need to recover created order with customer settings so that we can show order confirmation page
OrderRecoverUtility::recoverCreatedOrder($this->context, $cart->id_customer);

$this->ajaxDie(json_encode($response));
$this->ajaxRender(json_encode($response));
}

private function getTotalApplePayCartPrice()
{
$cartId = Tools::getValue('cartId');
$cart = new Cart($cartId);

$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'total' => $cart->getOrderTotal(),
]
Expand Down
10 changes: 5 additions & 5 deletions controllers/front/bancontactAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function createTransaction()
);
$newPayment = $this->module->getApiClient()->payments->create($paymentData->jsonSerialize(), ['include' => 'details.qrCode']);

$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'qr_code' => $newPayment->details->qrCode->src,
]
Expand All @@ -96,7 +96,7 @@ private function checkForPaidTransaction()
$cart = Context::getContext()->cart;

$proc = function () use ($cart) {
$orderId = Order::getOrderByCartId($cart->id);
$orderId = Order::getIdByCartId($cart->id);
/* @phpstan-ignore-next-line */
if (!$orderId) {
throw new OrderCreationException('Order was not created in webhook', OrderCreationException::ORDER_IS_NOT_CREATED);
Expand All @@ -115,15 +115,15 @@ private function checkForPaidTransaction()
]
);
} catch (RetryOverException $e) {
$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'success' => false,
]
));
}

if (!$orderId) {
$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'success' => false,
]
Expand All @@ -143,7 +143,7 @@ private function checkForPaidTransaction()
);
OrderRecoverUtility::recoverCreatedOrder($this->context, $cart->id_customer);

$this->ajaxDie(json_encode(
$this->ajaxRender(json_encode(
[
'success' => true,
'redirectUrl' => $successUrl,
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/fail.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function init()

$redirectLink = 'index.php?controller=history';

$orderId = (int) Order::getOrderByCartId((int) $this->id_cart); /* @phpstan-ignore-line */
$orderId = (int) Order::getIdByCartId((int) $this->id_cart); /* @phpstan-ignore-line */

$this->id_order = $orderId;
$this->secure_key = Tools::getValue('secureKey');
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function initContent()

try {
if ($method === PaymentMethod::BANKTRANSFER) {
$orderId = Order::getOrderByCartId($cart->id);
$orderId = Order::getIdByCartId($cart->id);
$order = new Order($orderId);
$paymentMethodRepository->addOpenStatusPayment(
$cart->id,
Expand Down
4 changes: 2 additions & 2 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function initContent()
// any paid payments for this cart?

if (false === $data['mollie_info']) {
$data['mollie_info'] = $paymentMethodRepo->getPaymentBy('order_id', (int) Order::getOrderByCartId($idCart));
$data['mollie_info'] = $paymentMethodRepo->getPaymentBy('order_id', (int) Order::getIdByCartId($idCart));
}
if (false === $data['mollie_info']) {
$data['mollie_info'] = [];
Expand Down Expand Up @@ -220,7 +220,7 @@ protected function processGetStatus()
}

/* @phpstan-ignore-next-line */
$orderId = (int) Order::getOrderByCartId((int) $cart->id);
$orderId = (int) Order::getIdByCartId((int) $cart->id);
/** @phpstan-ignore-line */
$order = new Order((int) $orderId);

Expand Down
4 changes: 2 additions & 2 deletions mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public function hookDisplayAdminOrder($params)
'errorDisplay' => Configuration::get(Mollie\Config\Config::MOLLIE_DISPLAY_ERRORS),
]);

return $this->display(__FILE__, 'order_info.tpl');
return $this->display($this->getLocalPath(), 'views/templates/hook/order_info.tpl');
}

/**
Expand Down Expand Up @@ -701,7 +701,7 @@ public function hookActionEmailSendBefore($params)
}

$cart = new Cart($params['cart']->id);
$orderId = Order::getOrderByCartId($cart->id);
$orderId = Order::getIdByCartId($cart->id);
$order = new Order($orderId);

if (!Validate::isLoadedObject($order)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Application/CommandHandler/CreateApplePayOrderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function handle(CreateApplePayOrder $command): array

// we need to wait for webhook to create the order. That's why we wait here for few seconds and check if order is created
$proc = function () use ($command) {
$orderId = Order::getOrderByCartId($command->getCartId());
$orderId = Order::getIdByCartId($command->getCartId());
/* @phpstan-ignore-next-line */
if (!$orderId) {
throw new OrderCreationException('Order was not created in webhook', OrderCreationException::ORDER_IS_NOT_CREATED);
Expand Down Expand Up @@ -146,7 +146,7 @@ public function handle(CreateApplePayOrder $command): array
[
'id_cart' => (int) $cart->id,
'id_module' => (int) $this->module->id,
'id_order' => Order::getOrderByCartId($cart->id),
'id_order' => Order::getIdByCartId($cart->id),
'key' => $cart->secure_key,
]
);
Expand Down
8 changes: 4 additions & 4 deletions src/Handler/Order/OrderCreationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen

$paymentFeeData = $this->paymentFeeProvider->getPaymentFee($paymentMethod, (float) $originalAmount);

if (Order::getOrderByCartId((int) $cartId)) {
if (Order::getIdByCartId((int) $cartId)) {
return 0;
}

Expand All @@ -159,7 +159,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen
);

/* @phpstan-ignore-next-line */
$orderId = (int) Order::getOrderByCartId((int) $cartId);
$orderId = (int) Order::getIdByCartId((int) $cartId);

$this->createRecurringOrderEntity(new Order($orderId), $paymentMethod->id_method);

Expand Down Expand Up @@ -199,7 +199,7 @@ public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePaymen
);

/* @phpstan-ignore-next-line */
$orderId = (int) Order::getOrderByCartId((int) $cartId);
$orderId = (int) Order::getIdByCartId((int) $cartId);

$this->orderPaymentFeeHandler->addOrderPaymentFee($orderId, $apiPayment);

Expand Down Expand Up @@ -231,7 +231,7 @@ public function createBankTransferOrder($paymentData, Cart $cart)
$cart->secure_key
);

$orderId = Order::getOrderByCartId($cart->id);
$orderId = Order::getIdByCartId($cart->id);
$order = new Order($orderId);

$environment = (int) Configuration::get(Mollie\Config\Config::MOLLIE_ENVIRONMENT);
Expand Down
Loading
Loading