Skip to content

Commit

Permalink
Merge pull request #1102 from PrestaShopCorp/release/8.3.4.0
Browse files Browse the repository at this point in the history
Release v8.3.4.0
  • Loading branch information
Matt75 authored Aug 9, 2023
2 parents fc3579f + 6a388f3 commit 4d6fa0c
Show file tree
Hide file tree
Showing 48 changed files with 1,355 additions and 1,417 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[8.3.3.1]]></version>
<version><![CDATA[8.3.4.0]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
16 changes: 0 additions & 16 deletions config/admin/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@ services:
ps_checkout.logger.file.reader:
class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileReader'
public: true

ps_checkout.repository.orderpayment:
class: 'PrestaShop\Module\PrestashopCheckout\Repository\OrderPaymentRepository'
public: true

ps_checkout.repository.order:
class: 'PrestaShop\Module\PrestashopCheckout\Repository\OrderRepository'
public: true

ps_checkout.presenter.order.pending:
class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Order\OrderPendingPresenter'
public: true

ps_checkout.presenter.transaction:
class: 'PrestaShop\Module\PrestashopCheckout\Presenter\Transaction\TransactionPresenter'
public: true
18 changes: 18 additions & 0 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ services:
- "@ps_checkout.express_checkout.configuration"
- "@ps_checkout.pay_later.configuration"

ps_checkout.validator.batch_configuration:
class: 'PrestaShop\Module\PrestashopCheckout\Validator\BatchConfigurationValidator'
public: true

ps_checkout.cache.directory:
class: 'PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider'
public: true
Expand Down Expand Up @@ -422,6 +426,12 @@ services:
- "@ps_checkout.webhook.service.secret_token"
- ["@ps_checkout.webhook.handler.event.configuration_updated"]

ps_checkout.configuration.batch_processor:
class: 'PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor'
public: true
arguments:
- '@ps_checkout.configuration'

ps_accounts.installer:
class: 'PrestaShop\PsAccountsInstaller\Installer\Installer'
public: true
Expand Down Expand Up @@ -462,6 +472,7 @@ services:
PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentPendingQuery: "ps_checkout.query.handler.order.get_order_for_payment_pending"
PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentRefundedQuery: "ps_checkout.query.handler.order.get_order_for_payment_refunded"
PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForPaymentReversedQuery: "ps_checkout.query.handler.order.get_order_for_payment_reversed"
PrestaShop\Module\PrestashopCheckout\Order\Query\GetOrderForApprovalReversedQuery: "ps_checkout.query.handler.order.get_order_for_approval_reversed"
PrestaShop\Module\PrestashopCheckout\PayPal\Identity\Query\GetClientTokenPayPalQuery: "ps_checkout.query.handler.paypal.identity.get_client_token"
PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetCurrentPayPalOrderStatusQuery: "ps_checkout.query.handler.paypal.order.get_current_paypal_order_status"
PrestaShop\Module\PrestashopCheckout\PayPal\Order\Query\GetPayPalOrderForCheckoutCompletedQuery: "ps_checkout.query.handler.paypal.order.get_paypal_order_for_checkout_completed"
Expand Down Expand Up @@ -497,6 +508,7 @@ services:
- "@ps_checkout.cache.paypal.order"
- "@ps_checkout.checkout.checker"
- "@ps_checkout.paypal.order.service.check_transition_paypal_order_status"
- "@ps_checkout.order.state.service.order_state_mapper"

ps_checkout.event.subscriber.paypal.capture:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Capture\EventSubscriber\PayPalCaptureEventSubscriber'
Expand Down Expand Up @@ -604,6 +616,12 @@ services:
arguments:
- "@ps_checkout.repository.pscheckoutcart"

ps_checkout.query.handler.order.get_order_for_approval_reversed:
class: 'PrestaShop\Module\PrestashopCheckout\Order\QueryHandler\GetOrderForApprovalReversedQueryHandler'
public: true
arguments:
- "@ps_checkout.repository.pscheckoutcart"

ps_checkout.query.handler.paypal.identity.get_client_token:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Identity\QueryHandler\GetClientTokenPayPalQueryHandler'
public: true
Expand Down
162 changes: 130 additions & 32 deletions controllers/admin/AdminAjaxPrestashopCheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

use Monolog\Logger;
use PrestaShop\Module\PrestashopCheckout\Configuration\BatchConfigurationProcessor;
use PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration;
use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository;
use PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerDirectory;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerFactory;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileFinder;
use PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileReader;
use PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep;
use PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner;
use PrestaShop\Module\PrestashopCheckout\Order\State\Exception\OrderStateException;
use PrestaShop\Module\PrestashopCheckout\Order\State\OrderStateInstaller;
use PrestaShop\Module\PrestashopCheckout\Order\State\Service\OrderStateMapper;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider;
use PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration;
use PrestaShop\Module\PrestashopCheckout\Presenter\Order\OrderPresenter;
use PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository;
use PrestaShop\Module\PrestashopCheckout\Settings\RoundingSettings;
use PrestaShop\Module\PrestashopCheckout\Validator\BatchConfigurationValidator;
use PrestaShop\Module\PrestashopCheckout\Webhook\WebhookSecretTokenService;
use Psr\SimpleCache\CacheInterface;

class AdminAjaxPrestashopCheckoutController extends ModuleAdminController
Expand Down Expand Up @@ -68,7 +84,7 @@ public function postProcess()
public function ajaxProcessUpdatePaymentMethodsOrder()
{
$paymentOptions = json_decode(Tools::getValue('paymentMethods'), true);
/** @var PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository $fundingSourceConfigurationRepository */
/** @var FundingSourceConfigurationRepository $fundingSourceConfigurationRepository */
$fundingSourceConfigurationRepository = $this->module->getService('ps_checkout.funding_source.configuration.repository');

foreach ($paymentOptions as $key => $paymentOption) {
Expand Down Expand Up @@ -96,7 +112,7 @@ public function ajaxProcessUpdatePaymentMode()
*/
public function ajaxProcessLiveStepConfirmed()
{
/** @var \PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep $stepLive */
/** @var LiveStep $stepLive */
$stepLive = $this->module->getService('ps_checkout.step.live');
$stepLive->confirmed(true);

Expand All @@ -108,7 +124,7 @@ public function ajaxProcessLiveStepConfirmed()
*/
public function ajaxProcessLiveStepViewed()
{
/** @var \PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\LiveStep $stepLive */
/** @var LiveStep $stepLive */
$stepLive = $this->module->getService('ps_checkout.step.live');
$stepLive->viewed(true);

Expand All @@ -120,7 +136,7 @@ public function ajaxProcessLiveStepViewed()
*/
public function ajaxProcessValueBannerClosed()
{
/** @var \PrestaShop\Module\PrestashopCheckout\OnBoarding\Step\ValueBanner $valueBanner */
/** @var ValueBanner $valueBanner */
$valueBanner = $this->module->getService('ps_checkout.step.value');
$valueBanner->closed(true);

Expand All @@ -135,7 +151,7 @@ public function ajaxProcessValueBannerClosed()
*/
public function ajaxProcessEditRoundingSettings()
{
/** @var PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $paypalConfiguration */
/** @var PayPalConfiguration $paypalConfiguration */
$paypalConfiguration = $this->module->getService('ps_checkout.paypal.configuration');
$paypalConfiguration->setRoundType(RoundingSettings::ROUND_ON_EACH_ITEM);
$paypalConfiguration->setPriceRoundMode(RoundingSettings::ROUND_UP_AWAY_FROM_ZERO);
Expand All @@ -144,25 +160,16 @@ public function ajaxProcessEditRoundingSettings()
}

/**
* AJAX: Retrieve Reporting informations
* @deprecated No more used
*/
public function ajaxProcessGetReportingDatas()
{
try {
/** @var PrestaShop\Module\PrestashopCheckout\Presenter\Order\OrderPendingPresenter $pendingOrder */
$pendingOrder = $this->module->getService('ps_checkout.presenter.order.pending');
/** @var PrestaShop\Module\PrestashopCheckout\Presenter\Transaction\TransactionPresenter $transactionOrder */
$transactionOrder = $this->module->getService('ps_checkout.presenter.transaction');
$this->ajaxDie(
json_encode([
'orders' => $pendingOrder->present(),
'transactions' => $transactionOrder->present(),
])
);
} catch (Exception $exception) {
http_response_code(500);
$this->ajaxDie(json_encode(strip_tags($exception->getMessage())));
}
$this->ajaxDie(
json_encode([
'orders' => [],
'transactions' => [],
])
);
}

/**
Expand All @@ -172,7 +179,7 @@ public function ajaxProcessTogglePaymentOptionAvailability()
{
$paymentOption = json_decode(Tools::getValue('paymentOption'), true);

/** @var PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceConfigurationRepository $fundingSourceConfigurationRepository */
/** @var FundingSourceConfigurationRepository $fundingSourceConfigurationRepository */
$fundingSourceConfigurationRepository = $this->module->getService('ps_checkout.funding_source.configuration.repository');

$fundingSourceConfigurationRepository->save($paymentOption);
Expand All @@ -185,7 +192,7 @@ public function ajaxProcessTogglePaymentOptionAvailability()
*/
public function ajaxProcessUpdateCreditCardFields()
{
/** @var PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $paypalConfiguration */
/** @var PayPalConfiguration $paypalConfiguration */
$paypalConfiguration = $this->module->getService('ps_checkout.paypal.configuration');

$paypalConfiguration->setCardPaymentEnabled((bool) Tools::getValue('hostedFieldsEnabled'));
Expand All @@ -198,7 +205,7 @@ public function ajaxProcessUpdateCreditCardFields()
*/
public function ajaxProcessToggleECOrderPage()
{
/** @var \PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration $ecConfiguration */
/** @var ExpressCheckoutConfiguration $ecConfiguration */
$ecConfiguration = $this->module->getService('ps_checkout.express_checkout.configuration');
$ecConfiguration->setOrderPage((bool) Tools::getValue('status'));

Expand All @@ -212,7 +219,7 @@ public function ajaxProcessToggleECOrderPage()
*/
public function ajaxProcessToggleECCheckoutPage()
{
/** @var \PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration $ecConfiguration */
/** @var ExpressCheckoutConfiguration $ecConfiguration */
$ecConfiguration = $this->module->getService('ps_checkout.express_checkout.configuration');
$ecConfiguration->setCheckoutPage(Tools::getValue('status') ? true : false);

Expand All @@ -226,7 +233,7 @@ public function ajaxProcessToggleECCheckoutPage()
*/
public function ajaxProcessToggleECProductPage()
{
/** @var \PrestaShop\Module\PrestashopCheckout\ExpressCheckout\ExpressCheckoutConfiguration $ecConfiguration */
/** @var ExpressCheckoutConfiguration $ecConfiguration */
$ecConfiguration = $this->module->getService('ps_checkout.express_checkout.configuration');
$ecConfiguration->setProductPage(Tools::getValue('status') ? true : false);

Expand Down Expand Up @@ -370,15 +377,15 @@ public function ajaxProcessFetchOrder()
}
}

/** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider $paypalOrderProvider */
/** @var PayPalOrderProvider $paypalOrderProvider */
$paypalOrderProvider = $this->module->getService('ps_checkout.paypal.provider.order');

$paypalOrder = $paypalOrderProvider->getById($psCheckoutCart->paypal_order);
if ($paypalOrder === false) {
$paypalOrder = [];
}

/** @var \PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceTranslationProvider $fundingSourceTranslationProvider */
/** @var FundingSourceTranslationProvider $fundingSourceTranslationProvider */
$fundingSourceTranslationProvider = $this->module->getService('ps_checkout.funding_source.translation');
$presenter = new OrderPresenter($this->module, $paypalOrder);

Expand Down Expand Up @@ -452,7 +459,7 @@ public function ajaxProcessRefundOrder()
]));
}

/** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration $configurationPayPal */
/** @var PayPalConfiguration $configurationPayPal */
$configurationPayPal = $this->module->getService('ps_checkout.paypal.configuration');

$response = (new PrestaShop\Module\PrestashopCheckout\Api\Payment\Order($this->context->link))->refund([
Expand Down Expand Up @@ -722,7 +729,7 @@ public function ajaxProcessSavePaypalButtonConfiguration()
*/
public function ajaxProcessGetOrRefreshToken()
{
/** @var \PrestaShop\Module\PrestashopCheckout\Repository\PsAccountRepository $psAccountRepository */
/** @var PsAccountRepository $psAccountRepository */
$psAccountRepository = $this->module->getService('ps_checkout.repository.prestashop.account');

try {
Expand Down Expand Up @@ -790,7 +797,7 @@ public function display()

private function togglePayLaterConfiguration($method)
{
/** @var \PrestaShop\Module\PrestashopCheckout\PayPal\PayPalPayLaterConfiguration $payLaterConfiguration */
/** @var PayPalPayLaterConfiguration $payLaterConfiguration */
$payLaterConfiguration = $this->module->getService('ps_checkout.pay_later.configuration');
$payLaterConfiguration->$method(Tools::getValue('status') ? true : false);

Expand All @@ -799,7 +806,7 @@ private function togglePayLaterConfiguration($method)

public function ajaxProcessUpsertSecretToken()
{
/** @var \PrestaShop\Module\PrestashopCheckout\Webhook\WebhookSecretTokenService $webhookSecretTokenService */
/** @var WebhookSecretTokenService $webhookSecretTokenService */
$webhookSecretTokenService = $this->module->getService('ps_checkout.webhook.service.secret_token');

$secret = (string) Tools::getValue('body');
Expand Down Expand Up @@ -849,6 +856,97 @@ public function ajaxProcessCheckConfiguration()
$this->exitWithResponse($response);
}

public function ajaxProcessFetchConfiguration()
{
$query = new DbQuery();
$query->select('name, value, date_add, date_upd');
$query->from('configuration');
$query->where('name LIKE "PS_CHECKOUT_%"');

/** @var int|null $shopId When multishop is disabled, it returns null, so we don't have to restrict results by shop */
$shopId = Shop::getContextShopID(true);

// When ShopId is not NULL, we have to retrieve global values with id_shop = NULL and shop values with id_shop = ShopId
if ($shopId) {
$query->where('id_shop IS NULL OR id_shop = ' . (int) $shopId);
}

$configurations = Db::getInstance()->executeS($query);

$response = [
'httpCode' => 200,
'status' => !empty($configurations),
'configuration' => array_map(function ($configuration) {
return [
'name' => $configuration['name'],
'value' => $configuration['value'],
];
}, $configurations),
];

$this->exitWithResponse($response);
}

public function ajaxProcessGetMappedOrderStates()
{
/** @var OrderStateMapper $orderStateMapper */
$orderStateMapper = $this->module->getService('ps_checkout.order.state.service.order_state_mapper');
$mappedOrderStates = [];

try {
$mappedOrderStates = $orderStateMapper->getMappedOrderStates();
} catch (OrderStateException $exception) {
if ($exception->getCode() === OrderStateException::INVALID_MAPPING) {
(new OrderStateInstaller())->install();
}

$this->exitWithResponse([
'httpCode' => 500,
'status' => false,
'error' => $exception->getMessage(),
]);
}

$this->exitWithResponse([
'status' => true,
'mappedOrderStates' => $mappedOrderStates,
]);
}

public function ajaxProcessBatchSaveConfiguration()
{
/** @var BatchConfigurationValidator $configurationValidator */
$configurationValidator = $this->module->getService('ps_checkout.validator.batch_configuration');
/** @var BatchConfigurationProcessor $batchConfigurationProcessor */
$batchConfigurationProcessor = $this->module->getService('ps_checkout.configuration.batch_processor');

$configuration = json_decode(Tools::getValue('configuration'), true);
try {
$configurationValidator->validateAjaxBatchConfiguration($configuration);
$batchConfigurationProcessor->saveBatchConfiguration($configuration);

$this->exitWithResponse([
'status' => true,
]);
} catch (Exception $exception) {
$this->exitWithResponse([
'httpCode' => 500,
'status' => false,
'error' => $exception->getMessage(),
]);
}
}

public function ajaxProcessGetOrderStates()
{
$orderStates = OrderState::getOrderStates($this->context->language->id);

$this->exitWithResponse([
'status' => true,
'orderStates' => $orderStates,
]);
}

/**
* @param array $response
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function postProcess()
[
'configure' => 'ps_checkout',
]
)
) . '#/authentication'
);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
Expand Down
Loading

0 comments on commit 4d6fa0c

Please sign in to comment.