diff --git a/_dev/js/front/src/api/ps-checkout.api.js b/_dev/js/front/src/api/ps-checkout.api.js index fea682dfc..36dba4707 100644 --- a/_dev/js/front/src/api/ps-checkout.api.js +++ b/_dev/js/front/src/api/ps-checkout.api.js @@ -146,7 +146,11 @@ export class PsCheckoutApi extends BaseClass { if (isJsonResponse) { if (false === response.ok || response.status >= 400) { return response.json().then((response) => { - if (actions?.restart && response.body && 85 === response.body.error.code) { + if ( + actions?.restart && + response.body && + 85 === response.body.error.code + ) { return actions.restart(); } @@ -221,6 +225,8 @@ export class PsCheckoutApi extends BaseClass { window.location.href = new URL( this.config.checkoutCheckoutUrl ).toString(); + + return; } throw new Error(this.$('checkout.form.error.label')); diff --git a/config.xml b/config.xml index 1b0afe4cc..7d19005c4 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_checkout - + @@ -10,4 +10,4 @@ 1 1 - \ No newline at end of file + diff --git a/controllers/front/cancel.php b/controllers/front/cancel.php index ac4d507e7..d0ced054e 100644 --- a/controllers/front/cancel.php +++ b/controllers/front/cancel.php @@ -72,24 +72,19 @@ public function postProcess() $reason = isset($bodyValues['reason']) ? Tools::safeOutput($bodyValues['reason']) : null; $error = isset($bodyValues['error']) ? Tools::safeOutput($bodyValues['error']) : null; - if (empty($orderId)) { - $this->exitWithResponse([ - 'httpCode' => 400, - 'body' => 'Missing PayPal Order Id', - ]); - } - - /** @var CommandBusInterface $commandBus */ - $commandBus = $this->module->getService('ps_checkout.bus.command'); + if ($orderId) { + /** @var CommandBusInterface $commandBus */ + $commandBus = $this->module->getService('ps_checkout.bus.command'); - $commandBus->handle(new CancelCheckoutCommand( - $this->context->cart->id, - $orderId, - PsCheckoutCart::STATUS_CANCELED, - $fundingSource, - $isExpressCheckout, - $isHostedFields - )); + $commandBus->handle(new CancelCheckoutCommand( + $this->context->cart->id, + $orderId, + PsCheckoutCart::STATUS_CANCELED, + $fundingSource, + $isExpressCheckout, + $isHostedFields + )); + } $this->module->getLogger()->log( $error ? 400 : 200, @@ -97,6 +92,7 @@ public function postProcess() [ 'PayPalOrderId' => $orderId, 'FundingSource' => $fundingSource, + 'id_cart' => $this->context->cart->id, 'isExpressCheckout' => $isExpressCheckout, 'isHostedFields' => $isHostedFields, 'reason' => $reason, diff --git a/ps_checkout.php b/ps_checkout.php index c928004f3..1a34754b6 100755 --- a/ps_checkout.php +++ b/ps_checkout.php @@ -112,7 +112,7 @@ class Ps_checkout extends PaymentModule // Needed in order to retrieve the module version easier (in api call headers) than instanciate // the module each time to get the version - const VERSION = '7.3.6.0'; + const VERSION = '7.3.6.1'; const INTEGRATION_DATE = '2022-14-06'; @@ -133,7 +133,7 @@ public function __construct() // We cannot use the const VERSION because the const is not computed by addons marketplace // when the zip is uploaded - $this->version = '7.3.6.0'; + $this->version = '7.3.6.1'; $this->author = 'PrestaShop'; $this->currencies = true; $this->currencies_mode = 'checkbox'; @@ -376,9 +376,6 @@ public function uninstallTabs() public function getContent() { try { - $mboInstaller = new \Prestashop\ModuleLibMboInstaller\DependencyBuilder($this); - $requiredDependencies = $mboInstaller->handleDependencies(); - $hasRequiredDependencies = $mboInstaller->areDependenciesMet(); /** @var \PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts $psAccountsFacade */ $psAccountsFacade = $this->getService('ps_accounts.facade'); /** @var \PrestaShop\PsAccountsInstaller\Installer\Presenter\InstallerPresenter $psAccountsPresenter */ @@ -387,8 +384,6 @@ public function getContent() $contextPsAccounts = $psAccountsPresenter->present($this->name); } catch (Exception $exception) { $contextPsAccounts = []; - $requiredDependencies = []; - $hasRequiredDependencies = false; $this->getLogger()->error( 'Failed to get PsAccounts context', [ @@ -422,6 +417,27 @@ public function getContent() } $this->context->controller->addJS($boSdkUrl, false); + $isShopContext = !(Shop::isFeatureActive() && Shop::getContext() !== Shop::CONTEXT_SHOP); + $requiredDependencies = []; + $hasRequiredDependencies = true; + + if ($isShopContext) { + try { + $mboInstaller = new \Prestashop\ModuleLibMboInstaller\DependencyBuilder($this); + $requiredDependencies = $mboInstaller->handleDependencies(); + $hasRequiredDependencies = $mboInstaller->areDependenciesMet(); + } catch (Exception $exception) { + $this->getLogger()->error( + 'Failed to get required dependencies', + [ + 'exception' => get_class($exception), + 'exceptionCode' => $exception->getCode(), + 'exceptionMessage' => $exception->getMessage(), + ] + ); + } + } + $this->context->smarty->assign([ 'requiredDependencies' => $requiredDependencies, 'hasRequiredDependencies' => $hasRequiredDependencies,