From 895061e7091dd9a0e0b5aaadead2573d2258fb50 Mon Sep 17 00:00:00 2001 From: RafaMelazzo Date: Mon, 8 Jul 2024 15:01:50 -0300 Subject: [PATCH 1/4] improve: allow integration in the default scope --- .../Config/Form/Field/HubIntegration.php | 20 ++- Controller/Adminhtml/Hub/Index.php | 129 +++++---------- Model/Api/HubCommand.php | 152 +++++++++--------- 3 files changed, 127 insertions(+), 174 deletions(-) diff --git a/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php b/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php index c7fa226a..024b164a 100644 --- a/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php +++ b/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php @@ -97,12 +97,20 @@ private function getBaseIntegrateUrl(): string $this->getPublicAppKey() ); - $params = sprintf( - '?redirect=%swebsite/%s/&install_token/%s', - $this->getRedirectUrl(), - Magento2CoreSetup::getCurrentStoreId(), - $this->getInstallToken() - ); + if($this->getRequest()->getParam('website') !== null) { + $params = sprintf( + '?redirect=%swebsite/%s/&install_token/%s', + $this->getRedirectUrl(), + Magento2CoreSetup::getCurrentStoreId(), + $this->getInstallToken() + ); + } else { + $params = sprintf( + '?redirect=%s&install_token/%s', + $this->getRedirectUrl(), + $this->getInstallToken() + ); + } return $baseUrl . $params; } diff --git a/Controller/Adminhtml/Hub/Index.php b/Controller/Adminhtml/Hub/Index.php index 4161cf3c..8632ff6a 100644 --- a/Controller/Adminhtml/Hub/Index.php +++ b/Controller/Adminhtml/Hub/Index.php @@ -6,6 +6,9 @@ use Magento\Framework\App\Cache\Manager; use Magento\Framework\App\Config\Storage\WriterInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\Webapi\Exception as MagentoException; use Magento\Store\Model\StoreManagerInterface; @@ -50,18 +53,14 @@ public function __construct( /** * Index action * - * @return \Magento\Framework\Controller\ResultInterface + * @return ResultInterface + * @throws MagentoException|LocalizedException + * @throws \Exception */ public function execute() { $params = $this->requestObject->getParams(); - $websiteId = isset($params['website']) - ? $params['website'] - : $this->storeManager->getDefaultStoreView()->getWebsiteId(); - - $storeId = $this->storeManager->getWebsite($websiteId) - ->getDefaultStore()->getId(); - $this->storeManager->setCurrentStore($storeId); + $websiteId = $params['website'] ?? 0; Magento2CoreSetup::bootstrap(); @@ -85,161 +84,109 @@ public function execute() } $url = $this->getUrl('adminhtml/system_config/edit/section/payment'); - header('Location: ' . explode('?', $url ?? '')[0] . 'website/' . $websiteId); + $header = 'Location: ' . explode('?', $url ?? '')[0]; + if (!empty($websiteId)) { + $header .= 'website/' . $websiteId; + } + header($header); exit; } + /** + * @param $websiteId + * @return string + * @throws NoSuchEntityException + */ private function getCallbackUrl($websiteId) { $baseUrl = $this->storeManager->getStore()->getBaseUrl(); - return $baseUrl . "rest/V1/pagarme/hub/command?websiteId=" . $websiteId; - } - - private function getWebHookkUrl() - { - $baseUrl = $this->storeManager->getStore()->getBaseUrl(); - return $baseUrl . "rest/V1/pagarme/webhook"; - } - - private function allWebsitesIntegrated($currentWebsiteId) - { - $websites = $this->storeManager->getWebsites(); - $magento2CoreSetup = new Magento2CoreSetup(); - - foreach ($websites as $websiteId => $website) { - $storeId = $this->storeManager->getWebsite($websiteId) - ->getDefaultStore()->getId(); + $callbackUrl = $baseUrl . "rest/V1/pagarme/hub/command"; - $this->storeManager->setCurrentStore($storeId); - - $magento2CoreSetup->loadModuleConfigurationFromPlatform(); - $currentConfiguration = Magento2CoreSetup::getModuleConfiguration(); - - $isSameWebsite = $websiteId === intval($currentWebsiteId); - - if (!$isSameWebsite && !$currentConfiguration->isHubEnabled()) { - return false; - } + if (!empty($websiteId)) { + $callbackUrl .= "?websiteId=" . $websiteId; } - return true; + return $callbackUrl; } - private function removeDefaultConfigKeys() + /** + * @return string + * @throws NoSuchEntityException + */ + private function getWebHookkUrl() { - $this->configWriter->save( - "pagarme_pagarme/global/secret_key", - null, - 'default', - 0 - ); - - $this->configWriter->save( - "pagarme_pagarme/global/public_key", - null, - 'default', - 0 - ); - - $this->configWriter->save( - "pagarme_pagarme/global/secret_key_test", - null, - 'default', - 0 - ); - - $this->configWriter->save( - "pagarme_pagarme/global/public_key_test", - null, - 'default', - 0 - ); - $this->configWriter->save( - "pagarme_pagarme/hub/account_id", - null, - 'default', - 0 - ); - - $this->configWriter->save( - "pagarme_pagarme/hub/merchant_id", - null, - 'default', - 0 - ); + $baseUrl = $this->storeManager->getStore()->getBaseUrl(); + return $baseUrl . "rest/V1/pagarme/webhook"; } private function updateStoreFields($websiteId) { $currentConfiguration = Magento2CoreSetup::getModuleConfiguration(); + $scope = !empty($websiteId) ? "websites" : "default"; $this->configWriter->save( "pagarme_pagarme/hub/install_id", $currentConfiguration->getHubInstallId()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/hub/environment", $currentConfiguration->getHubEnvironment()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/global/secret_key", $currentConfiguration->getSecretKey()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/global/public_key", $currentConfiguration->getPublicKey()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/hub/account_id", $currentConfiguration->getAccountId()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/hub/merchant_id", $currentConfiguration->getMerchantId()->getValue(), - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/global/test_mode", 0, - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/global/secret_key_test", null, - 'websites', + $scope, $websiteId ); $this->configWriter->save( "pagarme_pagarme/global/public_key_test", null, - 'websites', + $scope, $websiteId ); - if ($this->allWebsitesIntegrated($websiteId)) { - $this->removeDefaultConfigKeys(); - } - $this->cacheManager->clean(['config']); } } diff --git a/Model/Api/HubCommand.php b/Model/Api/HubCommand.php index 4fdceddb..edb5abbf 100644 --- a/Model/Api/HubCommand.php +++ b/Model/Api/HubCommand.php @@ -50,6 +50,10 @@ public function __construct( $this->storeManager = $storeManager; } + /** + * @throws MagentoException + * @throws \Exception + */ public function execute() { $params = json_decode( @@ -57,13 +61,8 @@ public function execute() ); $paramsFromUrl = $this->request->getParams(); - $this->websiteId = isset($paramsFromUrl['websiteId']) - ? $paramsFromUrl['websiteId'] - : $this->storeManager->getDefaultStoreView()->getWebsiteId(); + $this->websiteId = $paramsFromUrl['websiteId'] ?? 0; - $storeId = $this->storeManager->getWebsite($this->websiteId) - ->getDefaultStore()->getId(); - $this->storeManager->setCurrentStore($storeId); Magento2CoreSetup::bootstrap(); $hubIntegrationService = new HubIntegrationService(); @@ -83,80 +82,79 @@ public function execute() return "Command $params->command executed successfully"; } - $commandMessage = $this->$command(); - return $commandMessage; + return $this->$command(); } public function uninstallCommand() { - if (!$this->websiteId) { - $this->websiteId = 1; - } - $this->configWriter->save( - "pagarme_pagarme/hub/install_id", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/hub/environment", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/global/secret_key", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/global/public_key", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/global/secret_key_test", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/global/public_key_test", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/hub/account_id", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/hub/merchant_id", - null, - 'websites', - $this->websiteId - ); - - $this->configWriter->save( - "pagarme_pagarme/hub/account_errors", - null, - 'websites', - $this->websiteId - ); - - $this->cacheManager->clean(['config']); - - return "Hub uninstalled successfully"; +// if (!$this->websiteId) { +// $this->websiteId = 1; +// } +// $this->configWriter->save( +// "pagarme_pagarme/hub/install_id", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/hub/environment", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/global/secret_key", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/global/public_key", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/global/secret_key_test", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/global/public_key_test", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/hub/account_id", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/hub/merchant_id", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->configWriter->save( +// "pagarme_pagarme/hub/account_errors", +// null, +// 'websites', +// $this->websiteId +// ); +// +// $this->cacheManager->clean(['config']); +// +// return "Hub uninstalled successfully"; } } From 7ac92fa85d1bdfd03d17da1db1e75630ec812799 Mon Sep 17 00:00:00 2001 From: RafaMelazzo Date: Tue, 16 Jul 2024 16:48:41 -0300 Subject: [PATCH 2/4] fix: integration behaviour --- .../Config/Form/Field/HubIntegration.php | 57 ++++--- Concrete/Magento2CoreSetup.php | 54 +++---- Controller/Adminhtml/Hub/Index.php | 49 +++++- Model/Account.php | 2 +- Model/Api/HubCommand.php | 144 +++++++++--------- Observer/DashConfigValidatorObserver.php | 3 +- etc/adminhtml/system/global.xml | 3 +- .../layout/adminhtml_system_config_edit.xml | 1 + .../adminhtml/web/css/integration_buttons.css | 31 +++- view/adminhtml/web/js/global.js | 77 ++++++++++ 10 files changed, 285 insertions(+), 136 deletions(-) create mode 100644 view/adminhtml/web/js/global.js diff --git a/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php b/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php index 024b164a..e05ce128 100644 --- a/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php +++ b/Block/Adminhtml/System/Config/Form/Field/HubIntegration.php @@ -5,8 +5,8 @@ use Exception; use Magento\Backend\Block\Template\Context; use Magento\Config\Block\System\Config\Form\Field; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Data\Form\Element\AbstractElement; -use Magento\Framework\Phrase; use Pagarme\Core\Hub\Services\HubIntegrationService; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; use Pagarme\Pagarme\Model\Account; @@ -18,12 +18,16 @@ class HubIntegration extends Field */ private $account; + protected $scopeConfig; + public function __construct( Account $account, + ScopeConfigInterface $scopeConfig, Context $context, array $data = [] ) { $this->account = $account; + $this->scopeConfig = $scopeConfig; parent::__construct($context, $data); } @@ -32,31 +36,46 @@ public function __construct( * @return string * @throws Exception */ - protected function _renderValue(AbstractElement $element) + protected function _renderValue(AbstractElement $element): string { Magento2CoreSetup::bootstrap(); - $installId = Magento2CoreSetup::getModuleConfiguration() - ->getHubInstallId(); - - $hubUrl = $this->getHubUrl($installId); - $buttonText = $this->getButtonText($installId); + $installId = Magento2CoreSetup::getModuleConfiguration()->getHubInstallId(); + $installIdValue = !empty($installId) ? $installId->getValue() : ''; + $defaultInstallId = $this->scopeConfig->getValue( + 'pagarme_pagarme/hub/install_id', + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + 0 + ); + $defaultInstallId = $defaultInstallId ?? ''; - $html = ''; + $html = sprintf( + '', + $installIdValue === $defaultInstallId ? 'default' : 'scope' + ); $html .= $this->_getElementHtml($element); + $hidden = ' hidden'; + + $html .= sprintf( + '%s', + $this->getBaseIntegrateUrl(), + $installId ? $hidden : '', + __("Integrate With Pagar.me") + ); $html .= sprintf( - '%s', - $hubUrl, - $buttonText + '%s', + $this->getHubUrl($installId), + $installId ? '' : $hidden, + __("View Integration") ); if ($this->account->hasMerchantAndAccountIds()) { - $dashUrl = $this->account->getDashUrl(); $html .= sprintf( - '%s', - $dashUrl, + '%s', + $this->account->getDashUrl(), + $installId ? '' : $hidden, __('Access Pagar.me Dash') ); } @@ -66,16 +85,6 @@ protected function _renderValue(AbstractElement $element) return $html; } - /** - * @param $installId - * @return Phrase - */ - private function getButtonText($installId): Phrase - { - return $installId - ? __("View Integration") : __("Integrate With Pagar.me"); - } - /** * @param $installId * @return string diff --git a/Concrete/Magento2CoreSetup.php b/Concrete/Magento2CoreSetup.php index a61ec500..1b7801cc 100644 --- a/Concrete/Magento2CoreSetup.php +++ b/Concrete/Magento2CoreSetup.php @@ -6,7 +6,7 @@ use Magento\Config\Model\Config as Magento2ModelConfig; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -use Magento\Store\Model\ScopeInterface as ScopeInterface; +use Magento\Store\Model\ScopeInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Filesystem\DirectoryList; @@ -74,19 +74,19 @@ protected function setConfig() { self::$config = [ AbstractModuleCoreSetup::CONCRETE_DATABASE_DECORATOR_CLASS => - Magento2DatabaseDecorator::class, + Magento2DatabaseDecorator::class, AbstractModuleCoreSetup::CONCRETE_PLATFORM_ORDER_DECORATOR_CLASS => - Magento2PlatformOrderDecorator::class, + Magento2PlatformOrderDecorator::class, AbstractModuleCoreSetup::CONCRETE_PLATFORM_INVOICE_DECORATOR_CLASS => - Magento2PlatformInvoiceDecorator::class, + Magento2PlatformInvoiceDecorator::class, AbstractModuleCoreSetup::CONCRETE_PLATFORM_CREDITMEMO_DECORATOR_CLASS => - Magento2PlatformCreditmemoDecorator::class, + Magento2PlatformCreditmemoDecorator::class, AbstractModuleCoreSetup::CONCRETE_DATA_SERVICE => - Magento2DataService::class, + Magento2DataService::class, AbstractModuleCoreSetup::CONCRETE_PLATFORM_PAYMENT_METHOD_DECORATOR_CLASS => - Magento2PlatformPaymentMethodDecorator::class, + Magento2PlatformPaymentMethodDecorator::class, AbstractModuleCoreSetup::CONCRETE_PRODUCT_DECORATOR_CLASS => - Magento2PlatformProductDecorator::class + Magento2PlatformProductDecorator::class ]; } @@ -295,7 +295,7 @@ private static function fillWithPixConfig( $configData->pixConfig = self::fillDataObj($storeConfig, $options, $pixObject, $section); } - + private static function fillWithGooglePayConfig( stdClass $configData, ScopeConfigInterface $storeConfig @@ -541,40 +541,34 @@ public static function getDefaultStoreViewCode() public static function getCurrentStoreId() { $objectManager = ObjectManager::getInstance(); - $config = $objectManager->get(Magento2ModelConfig::class); - $storeInterfaceName = '\Magento\Store\Model\StoreManagerInterface'; - $storeManager = $objectManager->get($storeInterfaceName); + $requestClass = '\Magento\Framework\App\RequestInterface'; + $request = $objectManager->get($requestClass); - $store = $storeManager->getWebsite()->getId(); + if ($request->getControllerName() !== 'system_config') { + $storeInterfaceName = '\Magento\Store\Model\StoreManagerInterface'; + $storeManager = $objectManager->get($storeInterfaceName); - if ($config->getScope() == 'websites') { - $store = $config->getScopeId(); + return $storeManager->getStore()->getWebsite()->getId(); } - if ($config->getScope() == 'stores') { - $store = $storeManager - ->getStore($config->getScopeId()) - ->getWebsite() - ->getId(); + if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) { + return $request->getParam(ScopeInterface::SCOPE_WEBSITE); } - if ($config->getScope() == 'default') { - $store = $storeManager->getDefaultStoreView()->getStoreId(); + if ($request->getParam(ScopeInterface::SCOPE_STORE)) { + return $request->getParam(ScopeInterface::SCOPE_STORE); } - return $store; + return 0; } + /** + * @return int + */ public static function getDefaultStoreId() { - $objectManager = ObjectManager::getInstance(); - $storeInterfaceName = '\Magento\Store\Model\StoreManagerInterface'; - $storeManager = $objectManager->get($storeInterfaceName); - - $defaultStoreView = $storeManager->getDefaultStoreView(); - - return $defaultStoreView->getStoreId(); + return 0; } /** diff --git a/Controller/Adminhtml/Hub/Index.php b/Controller/Adminhtml/Hub/Index.php index 8632ff6a..06fd2145 100644 --- a/Controller/Adminhtml/Hub/Index.php +++ b/Controller/Adminhtml/Hub/Index.php @@ -2,8 +2,10 @@ namespace Pagarme\Pagarme\Controller\Adminhtml\Hub; +use Magento\Backend\App\Action; use Magento\Backend\App\Action\Context; use Magento\Framework\App\Cache\Manager; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Config\Storage\WriterInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\ResultInterface; @@ -11,11 +13,12 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\Webapi\Exception as MagentoException; +use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Pagarme\Core\Hub\Services\HubIntegrationService; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; -class Index extends \Magento\Backend\App\Action +class Index extends Action { protected $resultPageFactory; protected $configWriter; @@ -60,7 +63,9 @@ public function __construct( public function execute() { $params = $this->requestObject->getParams(); + $scopeUrl = $this->getScopeUrl(); $websiteId = $params['website'] ?? 0; + $this->storeManager->setCurrentStore($websiteId); Magento2CoreSetup::bootstrap(); @@ -85,13 +90,49 @@ public function execute() $url = $this->getUrl('adminhtml/system_config/edit/section/payment'); $header = 'Location: ' . explode('?', $url ?? '')[0]; - if (!empty($websiteId)) { - $header .= 'website/' . $websiteId; + if (!empty($websiteId) && !empty($scopeUrl)) { + $header .= $scopeUrl . '/' . $websiteId; } header($header); exit; } + /** + * @return string + */ + public function getScopeName(): string + { + $request = $this->requestObject; + + if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) { + return ScopeInterface::SCOPE_WEBSITES; + } + + if ($request->getParam(ScopeInterface::SCOPE_STORE)) { + return ScopeInterface::SCOPE_STORES; + } + + return ScopeConfigInterface::SCOPE_TYPE_DEFAULT; + } + + /** + * @return string|null + */ + private function getScopeUrl() + { + $request = $this->requestObject; + + if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) { + return ScopeInterface::SCOPE_WEBSITE; + } + + if ($request->getParam(ScopeInterface::SCOPE_STORE)) { + return ScopeInterface::SCOPE_STORE; + } + + return null; + } + /** * @param $websiteId * @return string @@ -122,7 +163,7 @@ private function getWebHookkUrl() private function updateStoreFields($websiteId) { $currentConfiguration = Magento2CoreSetup::getModuleConfiguration(); - $scope = !empty($websiteId) ? "websites" : "default"; + $scope = $this->getScopeName(); $this->configWriter->save( "pagarme_pagarme/hub/install_id", diff --git a/Model/Account.php b/Model/Account.php index f0950ce3..341d3bd2 100644 --- a/Model/Account.php +++ b/Model/Account.php @@ -287,7 +287,7 @@ private function initializeConfig($website = null) $websiteId = $this->session->getWebsiteId(); } - if (!$websiteId) { + if (!$websiteId && $websiteId !== 0) { $websiteId = $this->storeManager->getStore() ->getWebsiteId(); } diff --git a/Model/Api/HubCommand.php b/Model/Api/HubCommand.php index edb5abbf..8d445a0d 100644 --- a/Model/Api/HubCommand.php +++ b/Model/Api/HubCommand.php @@ -3,6 +3,7 @@ namespace Pagarme\Pagarme\Model\Api; use Magento\Framework\App\Cache\Manager; +use Magento\Framework\App\Cache\Type\Config; use Magento\Framework\App\Config\Storage\WriterInterface; use Magento\Framework\Webapi\Exception as MagentoException; use Magento\Framework\Webapi\Rest\Request; @@ -10,6 +11,7 @@ use Pagarme\Core\Hub\Services\HubIntegrationService; use Pagarme\Pagarme\Api\HubCommandInterface; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; +use Pagarme\Pagarme\Controller\Adminhtml\Hub\Index as HubControllerIndex; class HubCommand implements HubCommandInterface { @@ -38,16 +40,23 @@ class HubCommand implements HubCommandInterface */ protected $storeManager; + /** + * @var HubControllerIndex + */ + private $hubControllerIndex; + public function __construct( Request $request, WriterInterface $configWriter, Manager $cacheManager, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + HubControllerIndex $hubControllerIndex ) { $this->request = $request; $this->configWriter = $configWriter; $this->cacheManager = $cacheManager; $this->storeManager = $storeManager; + $this->hubControllerIndex = $hubControllerIndex; } /** @@ -87,74 +96,69 @@ public function execute() public function uninstallCommand() { -// if (!$this->websiteId) { -// $this->websiteId = 1; -// } -// $this->configWriter->save( -// "pagarme_pagarme/hub/install_id", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/hub/environment", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/global/secret_key", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/global/public_key", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/global/secret_key_test", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/global/public_key_test", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/hub/account_id", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/hub/merchant_id", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->configWriter->save( -// "pagarme_pagarme/hub/account_errors", -// null, -// 'websites', -// $this->websiteId -// ); -// -// $this->cacheManager->clean(['config']); -// -// return "Hub uninstalled successfully"; + $scope = $this->hubControllerIndex->getScopeName(); + $websiteId = $this->websiteId ?? Magento2CoreSetup::getCurrentStoreId(); + + if (!$websiteId) { + $websiteId = 0; + } + + $this->configWriter->delete( + "pagarme_pagarme/hub/install_id", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/hub/environment", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/global/secret_key", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/global/public_key", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/global/secret_key_test", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/global/public_key_test", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/hub/account_id", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/hub/merchant_id", + $scope, + $websiteId + ); + + $this->configWriter->delete( + "pagarme_pagarme/hub/account_errors", + $scope, + $websiteId + ); + + $this->cacheManager->clean([Config::TYPE_IDENTIFIER]); + + return "Hub uninstalled successfully"; } } diff --git a/Observer/DashConfigValidatorObserver.php b/Observer/DashConfigValidatorObserver.php index f33b2c1f..5618efc1 100644 --- a/Observer/DashConfigValidatorObserver.php +++ b/Observer/DashConfigValidatorObserver.php @@ -5,6 +5,7 @@ use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Pagarme\Pagarme\Model\Account; @@ -46,7 +47,7 @@ public function execute(Observer $observer) } $website = $observer->getRequest() - ->getParam('website', $this->storeManager->getStore()->getWebsiteId()); + ->getParam(ScopeInterface::SCOPE_WEBSITE, 0); $this->account->validateDashSettings($website); return $this; diff --git a/etc/adminhtml/system/global.xml b/etc/adminhtml/system/global.xml index f2f6b03c..ad5e0b58 100644 --- a/etc/adminhtml/system/global.xml +++ b/etc/adminhtml/system/global.xml @@ -3,9 +3,10 @@ - + Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field\HubIntegration + pagarme_pagarme/hub/install_id diff --git a/view/adminhtml/layout/adminhtml_system_config_edit.xml b/view/adminhtml/layout/adminhtml_system_config_edit.xml index 998a8f56..06c5e5db 100644 --- a/view/adminhtml/layout/adminhtml_system_config_edit.xml +++ b/view/adminhtml/layout/adminhtml_system_config_edit.xml @@ -5,6 +5,7 @@ + diff --git a/view/adminhtml/web/css/integration_buttons.css b/view/adminhtml/web/css/integration_buttons.css index 59b87f70..20f803b9 100644 --- a/view/adminhtml/web/css/integration_buttons.css +++ b/view/adminhtml/web/css/integration_buttons.css @@ -1,4 +1,8 @@ -#pagarme-hub-button, #pagarme-dash-button { +#row_payment_other_pagarme_pagarme_pagarme_pagarme_global_hub_integration .control-value { + display: none; +} + +a.pagarme-integration-button, #pagarme-dash-button { background-color: #65a300; border-color: #65a300; border-radius: 2px; @@ -17,7 +21,7 @@ color: #fff; user-select: none; transition: background-color .2s ease-in-out, border-color .2s ease-in-out; - margin: 0 1rem 1rem 0; + margin: 0 1rem 0 0; } #pagarme-dash-button { @@ -27,18 +31,35 @@ text-transform: none; } -#pagarme-hub-button:hover, #pagarme-hub-button:active, #pagarme-hub-button:focus { +a.pagarme-integration-button.hidden { + display: none !important; +} + +.is-disabled a.pagarme-integration-button { + background-color: #e9e9e9; + border-color: #adadad; + color: #303030; + pointer-events: none; + touch-action: none; + cursor: not-allowed; + opacity: 0.5; +} + +a.pagarme-integration-button:hover, a.pagarme-integration-button:active, a.pagarme-integration-button:focus { background-color: #7da300; border-color: #7da300; + color: #fff; + text-decoration: none; } #pagarme-dash-button:hover, #pagarme-dash-button:active, #pagarme-dash-button:focus { background-color: #dbdbdb; } -#pagarme-hub-button:after { +#pagarme-integrate-button:after, +#pagarme-view-integration-button:after{ content: ""; - background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAT3XpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZppdty4FYX/YxVZAuZhORjPyQ6y/HwXLMmyJNvdSVt2scRigcAb7gDa7P/8+5h/8Se5Ek1MpeaWs+VPbLH5zptqnz/9vjob7+vzy3x95n4+b94/8JwKHMPza82v69/Ou/cBnkPnXfowUH0N5MbPH7T4Gr9+Gsg/h6AZ6f16DdReAwX/fOBeA/RnWTa3Wj4uYezn+Pr+Ewb+Gb3E+vO0v/xeiN5K3Cd4v4MLllcf4jOBoH/OhM6bxCsnuNBx7Lw2XkOor8EIyHdxsh9mZT5n5f2d+8X5T0kJ+TlvOPFzMPP78dvzLn06/xrQ3BB/uHOY73f+6fwJzn9eztu/c1Y15+xndT1mQppfi3pbyn3HhYOQh/u1zE/hX+J9uT+Nn2qo3knKl5128DNdc560H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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz7JVoCNAAA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ICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOmRkMmI0OWM4LTVjYjQtNGYxZC04ZDFhLTBmNmE2YzcxNDRiOCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMS0wNS0yMFQxMjoxOTo0MCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz7JVoCNAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QUUDxMowsDBfAAAAo5JREFUSMe9lr1rFEEUwGf37nK5RKKQXAJBUUM0okiKEKy0sbAJ+QsCaayMVarYKdhpK1gKwoGIIiLEQiGYFMEvhBj01ETiHrmPvdzebnZ3dj7ejI0Qc97sfW185Qxvf/PezPxmNRQSmOy+TMS7RyWSVSnlLwC6iqm74lPn7dH+MY6iDsrwiqwTIHiJMHyv7OTORwokCuBeCMGAPq+4hbP/BSik+IMFRhi+s2a8Th5IS/fqg9pWf6x6xZMHBlQsorSLK5Oqb+qhRE2TQgJuZZGapqd7kodf2Z450VaVlpePlXeN44ThacL8+wxosclKi6ZjnOj4IC1nMylM3WtCgNkIyoG9/5xb6orkBOetjf6A+o8aQQPq3Y70rnqBc7NBa6npGKcjhtq3wqAM6OPINUgYfvq3EvZXKSBvbZxSJlfc/BAHdkVKOe0G1vizTwt6I2DJ3kqD4JV6QCmlJAzf/SfJ9ssXKQveCLlfIRzYtk+cG4XqZncDUcyr2gqCG5nV63sLpxwvSCkhbC8A+AfTMdIq4Hpu+RAHZqnyLbc4jhBCyCfO1WbVxYG9K9lbSkkzTh6qcr3AmUNG+euAEGC34ksvsOdDgDOqPMqDB/qR3qFZTdP7WjmRXYnUnGqOC7YW4tljendX7+VWr0BcT4x4xB6ta6Bq9ruUQtQFIn04riGtLcHG9cQQQuhH7fjI4IRPmL8Y0xOp2jkQzIgLKXZibQAlQkQ1l0z0TCnfQyFgvWWYlMR0tr60paSKW7jU6qtOGH7SqQcXm/+FEIHlFs91BCxYm4OMk2wTMKAMz0Zi+9xOdoDy4EWIC/NuYE11ytFqB0wnN9mX6p+J6bEzCGm9INhPysnStvUtMzZ8AXcK/A0UsGey2h9i1gAAAABJRU5ErkJggg=="); background-size: 16px 16px; background-repeat: no-repeat; display: inline-block; diff --git a/view/adminhtml/web/js/global.js b/view/adminhtml/web/js/global.js new file mode 100644 index 00000000..5c4b28d5 --- /dev/null +++ b/view/adminhtml/web/js/global.js @@ -0,0 +1,77 @@ +require([ + "jquery", + "jquery/ui", +], function ($) { + "use strict"; + $(document).ready(function () { + const + integrationButtonsRow = $('#row_payment_other_pagarme_pagarme_pagarme_pagarme_global_hub_integration'), + integrationButtons = $('a.pagarme-integration-button'), + integrateButton = $('#pagarme-integrate-button'), + viewIntegrationButton = $('#pagarme-view-integration-button'), + dashButton = $('#pagarme-dash-button'), + integrationUseDefault = $('#payment_other_pagarme_pagarme_pagarme_pagarme_global_hub_integration_inherit'), + integratedScope = $('[data-pagarme-integration-scope]').attr('data-pagarme-integration-scope'), + hasIntegration = + $('#row_payment_other_pagarme_pagarme_pagarme_pagarme_global_hub_integration .control-value') + .html() !== ''; + + if (integrationUseDefault.is(':checked') && hasIntegration) { + disableButtons(); + } + + integrationButtons.on('click', function(event) { + const isDisabled = integrationButtonsRow.hasClass('is-disabled'); + + if (isDisabled) { + event.preventDefault(); + } + }); + + integrationUseDefault.on('change', function() { + if ($(this).is(':checked')) { + disableButtons(); + showIntegratedButtons(); + return; + } + + enableButtons(); + hideIntegratedButtons(); + }) + + function disableButtons() { + if (!hasIntegration) { + return; + } + + integrationButtonsRow.addClass('is-disabled'); + } + + function enableButtons() { + integrationButtonsRow.removeClass('is-disabled'); + } + + function hideIntegratedButtons() { + if (integratedScope !== 'default') { + return; + } + + viewIntegrationButton.addClass('hidden'); + dashButton.addClass('hidden'); + integrateButton.removeClass('hidden'); + } + + function showIntegratedButtons() { + if ( + (integratedScope === 'default' && !integrationUseDefault.is(':checked')) + || !hasIntegration + ) { + return; + } + + integrateButton.addClass('hidden'); + viewIntegrationButton.removeClass('hidden'); + dashButton.removeClass('hidden'); + } + }); +}); From 3c48319b4b79ca98bbf84c68d56be146c0cc3980 Mon Sep 17 00:00:00 2001 From: RafaMelazzo Date: Wed, 17 Jul 2024 17:51:55 -0300 Subject: [PATCH 3/4] feat: remove integration from db when marking 'use default' option --- Concrete/Magento2CoreSetup.php | 78 +++++++++++------------- Controller/Adminhtml/Hub/Index.php | 2 +- Model/Account.php | 43 ++++++++----- Model/Notifications.php | 15 +---- Observer/DashConfigValidatorObserver.php | 31 +++++++--- Observer/HubIntegrationObserver.php | 48 +++++++++++++++ etc/adminhtml/system/global.xml | 2 +- etc/events.xml | 68 ++++++++++++--------- view/adminhtml/web/js/global.js | 22 ++++--- 9 files changed, 190 insertions(+), 119 deletions(-) create mode 100644 Observer/HubIntegrationObserver.php diff --git a/Concrete/Magento2CoreSetup.php b/Concrete/Magento2CoreSetup.php index 1b7801cc..06df61a4 100644 --- a/Concrete/Magento2CoreSetup.php +++ b/Concrete/Magento2CoreSetup.php @@ -2,37 +2,28 @@ namespace Pagarme\Pagarme\Concrete; -use Magento\Framework\App\Config as Magento2StoreConfig; +use DateTimeZone; use Magento\Config\Model\Config as Magento2ModelConfig; +use Magento\Framework\App\Config as Magento2StoreConfig; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -use Magento\Store\Model\ScopeInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Filesystem\DirectoryList; -use Magento\Store\Model\StoreManager as MagentoStoreManager; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Store\Model\Website\Interceptor; use Pagarme\Core\Kernel\Abstractions\AbstractModuleCoreSetup; use Pagarme\Core\Kernel\Aggregates\Configuration; use Pagarme\Core\Kernel\Factories\ConfigurationFactory; use Pagarme\Core\Kernel\Services\MoneyService; use Pagarme\Core\Kernel\ValueObjects\CardBrand; use Pagarme\Core\Kernel\ValueObjects\Configuration\CardConfig; -use Pagarme\Pagarme\Gateway\Transaction\Base\Config\Config; -use Pagarme\Pagarme\Gateway\Transaction\CreditCard\Config\ConfigInterface; -use Pagarme\Pagarme\Model\Installments\Config\ConfigInterface as InstallmentConfigInterface; use Pagarme\Pagarme\Helper\ModuleHelper; -use Pagarme\Pagarme\Model\Enum\CreditCardBrandEnum; -use Pagarme\Pagarme\Concrete\Magento2DatabaseDecorator; -use Pagarme\Pagarme\Concrete\Magento2PlatformOrderDecorator; -use Pagarme\Pagarme\Concrete\Magento2PlatformInvoiceDecorator; -use Pagarme\Pagarme\Concrete\Magento2PlatformCreditmemoDecorator; -use Pagarme\Pagarme\Concrete\Magento2DataService; -use Pagarme\Pagarme\Concrete\Magento2PlatformPaymentMethodDecorator; -use Pagarme\Pagarme\Concrete\Magento2PlatformProductDecorator; use Pagarme\Pagarme\Model\ConfigNotification; -use Magento\Store\Model\StoreManagerInterface; -use Magento\Store\Model\Website\Interceptor; +use Pagarme\Pagarme\Model\Enum\CreditCardBrandEnum; use stdClass; +use Throwable; final class Magento2CoreSetup extends AbstractModuleCoreSetup { @@ -134,7 +125,7 @@ public function loadModuleConfigurationFromPlatform($storeConfig = null) $storeConfig = $objectManager->get(Magento2StoreConfig::class); } - $configData = new \stdClass(); + $configData = new stdClass(); $storeId = self::getCurrentStoreId(); @@ -167,7 +158,7 @@ public function loadModuleConfigurationFromPlatform($storeConfig = null) self::$moduleConfig = $config; self::$instance->setApiBaseUrl(); - } catch (\Throwable $error) { + } catch (Throwable $error) { $configErrorNotify = new ConfigNotification(); $configErrorNotify->addNotify($error); } @@ -212,13 +203,13 @@ static private function fillWithVoucherConfig(&$dataObj, $storeConfig) $section = 'payment/pagarme_voucher/'; - $voucherObject = new \stdClass(); + $voucherObject = new stdClass(); $dataObj->voucherConfig = self::fillDataObj($storeConfig, $options, $voucherObject, $section); $operation = Configuration::CARD_OPERATION_AUTH_ONLY; if ($dataObj->voucherConfig->cardOperation === 'authorize_capture') { - $operation = Configuration::CARD_OPERATION_AUTH_AND_CAPTURE; + $operation = Configuration::CARD_OPERATION_AUTH_AND_CAPTURE; } $dataObj->voucherConfig->cardOperation = $operation; @@ -237,7 +228,7 @@ static private function fillWithDebitConfig(&$dataObj, $storeConfig) $section = 'payment/pagarme_debit/'; - $debitObject = new \stdClass(); + $debitObject = new stdClass(); $dataObj->debitConfig = self::fillDataObj($storeConfig, $options, $debitObject, $section); $dataObj->debitConfig->cardOperation = Configuration::CARD_OPERATION_AUTH_AND_CAPTURE; @@ -279,9 +270,10 @@ static private function fillWithCardConfig(&$dataObj, $storeConfig) } private static function fillWithPixConfig( - stdClass $configData, + stdClass $configData, ScopeConfigInterface $storeConfig - ) { + ) + { $options = [ 'enabled' => 'active', 'expirationQrCode' => 'expiration_qrcode', @@ -291,15 +283,16 @@ private static function fillWithPixConfig( $section = 'payment/pagarme_pix/'; - $pixObject = new \stdClass(); + $pixObject = new stdClass(); $configData->pixConfig = self::fillDataObj($storeConfig, $options, $pixObject, $section); } private static function fillWithGooglePayConfig( - stdClass $configData, + stdClass $configData, ScopeConfigInterface $storeConfig - ) { + ) + { $options = [ 'enabled' => 'active', 'title' => 'title', @@ -309,7 +302,7 @@ private static function fillWithGooglePayConfig( $section = 'payment/pagarme_googlepay/'; - $googlePayObject = new \stdClass(); + $googlePayObject = new stdClass(); $configData->googlePayConfig = self::fillDataObj($storeConfig, $options, $googlePayObject, $section); } @@ -380,7 +373,7 @@ static private function fillWithPagarmeKeys(&$dataObj, $storeConfig) $section = 'pagarme_pagarme/global/'; - $keys = new \stdClass; + $keys = new stdClass; $dataObj->keys = self::fillDataObj( @@ -415,7 +408,7 @@ static private function fillWithAddressConfig(&$dataObj, $storeConfig) ]; $section = 'payment/pagarme_customer_address/'; - $addressAttributes = new \stdClass(); + $addressAttributes = new stdClass(); $dataObj->addressAttributes = self::fillDataObj( $storeConfig, @@ -455,7 +448,7 @@ static private function getBrandConfig($storeConfig, $section) $scope = ScopeInterface::SCOPE_WEBSITES; $storeId = self::getCurrentStoreId(); - $selectedBrands = $storeConfig->getValue($section . 'cctypes', $scope, $storeId) ?? ''; + $selectedBrands = $storeConfig->getValue($section . 'cctypes', $scope, $storeId) ?? ''; $brands = array_merge([''], explode( ',', $selectedBrands @@ -482,12 +475,12 @@ static private function getBrandConfig($storeConfig, $section) $max = $storeConfig->getValue($section . 'installments_number' . $brand, $scope, $storeId); } - $minValue = $storeConfig->getValue($section . 'installment_min_amount' . $brand, $scope, $storeId); - $initial = $storeConfig->getValue($section . 'installments_interest_rate_initial' . $brand, $scope, $storeId); - $incremental = $storeConfig->getValue($section . 'installments_interest_rate_incremental' . $brand, $scope, $storeId); - $maxWithout = $storeConfig->getValue($section . 'installments_max_without_interest' . $brand, $scope, $storeId); + $minValue = $storeConfig->getValue($section . 'installment_min_amount' . $brand, $scope, $storeId); + $initial = $storeConfig->getValue($section . 'installments_interest_rate_initial' . $brand, $scope, $storeId); + $incremental = $storeConfig->getValue($section . 'installments_interest_rate_incremental' . $brand, $scope, $storeId); + $maxWithout = $storeConfig->getValue($section . 'installments_max_without_interest' . $brand, $scope, $storeId); - $interestByBrand = $storeConfig->getValue($section . 'installments_interest_by_issuer' . $brand, $scope, $storeId); + $interestByBrand = $storeConfig->getValue($section . 'installments_interest_by_issuer' . $brand, $scope, $storeId); if (empty($interestByBrand)) { $initial = 0; $incremental = 0; @@ -572,9 +565,9 @@ public static function getDefaultStoreId() } /** + * @return DateTimeZone * @since 1.7.1 * - * @return \DateTimeZone */ protected function getPlatformStoreTimezone() { @@ -586,7 +579,7 @@ protected function getPlatformStoreTimezone() $timezoneString = $timezone->getConfigTimezone( ScopeInterface::SCOPE_STORE ); - $dateTimeZone = new \DateTimeZone($timezoneString); + $dateTimeZone = new DateTimeZone($timezoneString); return $dateTimeZone; } @@ -616,7 +609,7 @@ static private function fillWithRecurrenceConfig(&$dataObj, $storeConfig) $section = 'pagarme_pagarme/recurrence/'; - $recurrenceConfig = new \stdClass(); + $recurrenceConfig = new stdClass(); $dataObj->recurrenceConfig = self::fillDataObj( $storeConfig, $options, @@ -626,9 +619,10 @@ static private function fillWithRecurrenceConfig(&$dataObj, $storeConfig) } static private function fillWithMarketplaceConfig( - stdClass $configData, + stdClass $configData, ScopeConfigInterface $storeConfig - ) { + ) + { $options = [ 'enabled' => 'active', 'responsibilityForProcessingFees' @@ -645,7 +639,7 @@ static private function fillWithMarketplaceConfig( $section = 'pagarme_pagarme/marketplace/'; - $marketplaceObject = new \stdClass(); + $marketplaceObject = new stdClass(); $configData->marketplaceConfig = self::fillDataObj($storeConfig, $options, $marketplaceObject, $section); } diff --git a/Controller/Adminhtml/Hub/Index.php b/Controller/Adminhtml/Hub/Index.php index 06fd2145..82c713c2 100644 --- a/Controller/Adminhtml/Hub/Index.php +++ b/Controller/Adminhtml/Hub/Index.php @@ -118,7 +118,7 @@ public function getScopeName(): string /** * @return string|null */ - private function getScopeUrl() + public function getScopeUrl() { $request = $this->requestObject; diff --git a/Model/Account.php b/Model/Account.php index 341d3bd2..f6aab4e2 100644 --- a/Model/Account.php +++ b/Model/Account.php @@ -9,11 +9,11 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Pagarme\Core\Kernel\Aggregates\Configuration; use Pagarme\Core\Middle\Model\Account as AccountMiddle; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; +use Pagarme\Pagarme\Controller\Adminhtml\Hub\Index as HubControllerIndex; use Pagarme\Pagarme\Model\Api\HubCommand; use Pagarme\Pagarme\Service\AccountService; use Psr\Log\LoggerInterface; @@ -70,6 +70,11 @@ class Account */ protected $pagarmeConfigProvider; + /** + * @var HubControllerIndex + */ + protected $hubControllerIndex; + /** * @param WriterInterface $configWriter * @param StoreManagerInterface $storeManager @@ -78,17 +83,21 @@ class Account * @param CollectionFactory $configCollectionFactory * @param LoggerInterface $logger * @param Session $session + * @param PagarmeConfigProvider $pagarmeConfigProvider + * @param HubControllerIndex $hubControllerIndex */ public function __construct( - WriterInterface $configWriter, + WriterInterface $configWriter, StoreManagerInterface $storeManager, - AccountService $accountService, - HubCommand $hubCommand, - CollectionFactory $configCollectionFactory, - LoggerInterface $logger, - Session $session, - PagarmeConfigProvider $pagarmeConfigProvider - ) { + AccountService $accountService, + HubCommand $hubCommand, + CollectionFactory $configCollectionFactory, + LoggerInterface $logger, + Session $session, + PagarmeConfigProvider $pagarmeConfigProvider, + HubControllerIndex $hubControllerIndex + ) + { $this->configWriter = $configWriter; $this->storeManager = $storeManager; $this->accountService = $accountService; @@ -97,11 +106,14 @@ public function __construct( $this->logger = $logger; $this->session = $session; $this->pagarmeConfigProvider = $pagarmeConfigProvider; + $this->hubControllerIndex = $hubControllerIndex; } /** * @param mixed $website * @return void + * @throws LocalizedException + * @throws NoSuchEntityException */ public function validateDashSettings($website) { @@ -119,7 +131,7 @@ public function validateDashSettings($website) $this->configWriter->save( PagarmeConfigProvider::PATH_DASH_ERRORS, json_encode($account->getErrors()), - ScopeInterface::SCOPE_WEBSITES, + $this->hubControllerIndex->getScopeName(), $website ); $this->savePaymentTypes($account, $website); @@ -145,9 +157,8 @@ public function saveAccountIdFromWebhook($account) $this->configWriter->save( PagarmeConfigProvider::PATH_ACCOUNT_ID, $account['id'], - ScopeInterface::SCOPE_WEBSITES, - $this->storeManager->getStore() - ->getWebsiteId() + $this->hubControllerIndex->getScopeName(), + $this->storeManager->getStore()->getWebsiteId() ); } @@ -161,7 +172,7 @@ public function getDashSettingsErrors() $this->initializeConfig(); $collection = $this->configCollectionFactory->create(); $collection->addFieldToFilter('path', ['eq' => PagarmeConfigProvider::PATH_DASH_ERRORS]); - $collection->addFieldToFilter('scope', ['eq' => ScopeInterface::SCOPE_WEBSITES]); + $collection->addFieldToFilter('scope', ['eq' => $this->hubControllerIndex->getScopeName()]); $collection->addFieldToFilter('scope_id', ['eq' => $this->session->getWebsiteId()]); if ($collection->count() === 0) { @@ -192,7 +203,7 @@ public function getPaymentType(string $paymentName, bool $gateway = true) : PagarmeConfigProvider::PATH_IS_PAYMENT_PSP_TYPE; $collection = $this->configCollectionFactory->create(); $collection->addFieldToFilter('path', ['eq' => sprintf($paymentType, $paymentName)]); - $collection->addFieldToFilter('scope', ['eq' => ScopeInterface::SCOPE_WEBSITES]); + $collection->addFieldToFilter('scope', ['eq' => $this->hubControllerIndex->getScopeName()]); $collection->addFieldToFilter('scope_id', ['eq' => $this->session->getWebsiteId()]); if ($collection->count() === 0) { @@ -374,7 +385,7 @@ private function saveConfig($path, $value, $website) $this->configWriter->save( $path, $value, - ScopeInterface::SCOPE_WEBSITES, + $this->hubControllerIndex->getScopeName(), $website ); } diff --git a/Model/Notifications.php b/Model/Notifications.php index 28a946b2..a55ffbc9 100644 --- a/Model/Notifications.php +++ b/Model/Notifications.php @@ -60,9 +60,11 @@ class Notifications extends Message * @param Registry $registry * @param Account $account * @param HubIntegration $hubIntegration + * @param UrlInterface $urlInterface * @param AbstractResource|null $resource * @param AbstractDb|null $resourceCollection * @param array $data + * @throws NoSuchEntityException */ public function __construct( ConfigInterface $config, @@ -271,18 +273,7 @@ private function addDashSettingsMessages() */ private function buildDashLink(string $label, string $dashPage = '') { - if (!$this->account->hasMerchantAndAccountIds()) { - return $label; - } - - $dashSettings = !empty($dashPage) ? "settings/{$dashPage}/" : ''; - $url = $this->account->getDashUrl() . $dashSettings; - - return sprintf( - '%s', - $url, - $label - ); + return $label; } /** diff --git a/Observer/DashConfigValidatorObserver.php b/Observer/DashConfigValidatorObserver.php index 5618efc1..41e970fa 100644 --- a/Observer/DashConfigValidatorObserver.php +++ b/Observer/DashConfigValidatorObserver.php @@ -4,9 +4,10 @@ use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; +use Pagarme\Pagarme\Controller\Adminhtml\Hub\Index as HubControllerIndex; use Pagarme\Pagarme\Model\Account; class DashConfigValidatorObserver implements ObserverInterface @@ -21,33 +22,45 @@ class DashConfigValidatorObserver implements ObserverInterface */ protected $storeManager; + /** + * @var HubControllerIndex + */ + protected $hubControllerIndex; + /** * @param Account $account * @param StoreManagerInterface $storeManager + * @param HubControllerIndex $hubControllerIndex */ public function __construct( - Account $account, - StoreManagerInterface $storeManager - ) { + Account $account, + StoreManagerInterface $storeManager, + HubControllerIndex $hubControllerIndex + ) + { $this->account = $account; $this->storeManager = $storeManager; + $this->hubControllerIndex = $hubControllerIndex; } /** * @param Observer $observer * @return $this - * @throws NoSuchEntityException + * @throws NoSuchEntityException|LocalizedException */ public function execute(Observer $observer) { - $section = $observer->getRequest() - ->getParam('section'); + $section = $observer->getRequest()->getParam('section'); if ($section !== 'payment') { return $this; } - $website = $observer->getRequest() - ->getParam(ScopeInterface::SCOPE_WEBSITE, 0); + $scopeUrl = $this->hubControllerIndex->getScopeUrl() ?? 'default'; + $websiteCode = $this->hubControllerIndex->getScopeUrl() ? $this->storeManager->getWebsite()->getId() : 0; + $website = $observer->getRequest()->getParam( + $scopeUrl, + $websiteCode + ); $this->account->validateDashSettings($website); return $this; diff --git a/Observer/HubIntegrationObserver.php b/Observer/HubIntegrationObserver.php new file mode 100644 index 00000000..8a15fd71 --- /dev/null +++ b/Observer/HubIntegrationObserver.php @@ -0,0 +1,48 @@ +hubCommand = $hubCommand; + } + + /** + * @param Observer $observer + * @return void + */ + public function execute(Observer $observer) + { + $configData = $observer->getData('event')->getData('configData'); + + if ($configData[ScopeInterface::SCOPE_WEBSITE] === null) { + return; + } + + $pagarmeGlobalFields = $configData['groups']['pagarme_pagarme']['groups']['pagarme_pagarme_global']['fields']; + $integrationUseDefault = 0; + + if (array_key_exists('hub_integration', $pagarmeGlobalFields)) { + $integrationUseDefault = $pagarmeGlobalFields['hub_integration']['inherit']; + } + + if ($integrationUseDefault === '1') { + $this->hubCommand->uninstallCommand(); + } + } +} diff --git a/etc/adminhtml/system/global.xml b/etc/adminhtml/system/global.xml index ad5e0b58..6fc46ead 100644 --- a/etc/adminhtml/system/global.xml +++ b/etc/adminhtml/system/global.xml @@ -3,7 +3,7 @@ - + Pagarme\Pagarme\Block\Adminhtml\System\Config\Form\Field\HubIntegration pagarme_pagarme/hub/install_id diff --git a/etc/events.xml b/etc/events.xml index 18e83e56..60172a18 100644 --- a/etc/events.xml +++ b/etc/events.xml @@ -1,75 +1,87 @@ - + - + - + - + - + - + - + - + - - + + - + - + - + + + + - + - + - + - + instance="Pagarme\Pagarme\Observer\OrderCancelAfter"/> - + instance="Pagarme\Pagarme\Observer\OrderCancelAfter"/> - + instance="Pagarme\Pagarme\Observer\CartAddProductAfterObserver"/> - + instance="Pagarme\Pagarme\Observer\UpdateProductPlanObserver"/> - + instance="Pagarme\Pagarme\Observer\CustomerLogin"/> - - + diff --git a/view/adminhtml/web/js/global.js b/view/adminhtml/web/js/global.js index 5c4b28d5..88bf0751 100644 --- a/view/adminhtml/web/js/global.js +++ b/view/adminhtml/web/js/global.js @@ -14,14 +14,16 @@ require([ integratedScope = $('[data-pagarme-integration-scope]').attr('data-pagarme-integration-scope'), hasIntegration = $('#row_payment_other_pagarme_pagarme_pagarme_pagarme_global_hub_integration .control-value') - .html() !== ''; + .html() !== '', + disabledClass = 'is-disabled', + hiddenClass = 'hidden'; if (integrationUseDefault.is(':checked') && hasIntegration) { disableButtons(); } integrationButtons.on('click', function(event) { - const isDisabled = integrationButtonsRow.hasClass('is-disabled'); + const isDisabled = integrationButtonsRow.hasClass(disabledClass); if (isDisabled) { event.preventDefault(); @@ -44,11 +46,11 @@ require([ return; } - integrationButtonsRow.addClass('is-disabled'); + integrationButtonsRow.addClass(disabledClass); } function enableButtons() { - integrationButtonsRow.removeClass('is-disabled'); + integrationButtonsRow.removeClass(disabledClass); } function hideIntegratedButtons() { @@ -56,9 +58,9 @@ require([ return; } - viewIntegrationButton.addClass('hidden'); - dashButton.addClass('hidden'); - integrateButton.removeClass('hidden'); + viewIntegrationButton.addClass(hiddenClass); + dashButton.addClass(hiddenClass); + integrateButton.removeClass(hiddenClass); } function showIntegratedButtons() { @@ -69,9 +71,9 @@ require([ return; } - integrateButton.addClass('hidden'); - viewIntegrationButton.removeClass('hidden'); - dashButton.removeClass('hidden'); + integrateButton.addClass(hiddenClass); + viewIntegrationButton.removeClass(hiddenClass); + dashButton.removeClass(hiddenClass); } }); }); From fdfea64d46242e96e7272aa3f1f636eb95493abd Mon Sep 17 00:00:00 2001 From: RafaMelazzo Date: Wed, 17 Jul 2024 18:20:24 -0300 Subject: [PATCH 4/4] fix: sonar issue --- Concrete/Magento2CoreSetup.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Concrete/Magento2CoreSetup.php b/Concrete/Magento2CoreSetup.php index 06df61a4..8874c0b6 100644 --- a/Concrete/Magento2CoreSetup.php +++ b/Concrete/Magento2CoreSetup.php @@ -3,6 +3,7 @@ namespace Pagarme\Pagarme\Concrete; use DateTimeZone; +use Exception; use Magento\Config\Model\Config as Magento2ModelConfig; use Magento\Framework\App\Config as Magento2StoreConfig; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -566,6 +567,7 @@ public static function getDefaultStoreId() /** * @return DateTimeZone + * @throws Exception * @since 1.7.1 * */ @@ -579,9 +581,8 @@ protected function getPlatformStoreTimezone() $timezoneString = $timezone->getConfigTimezone( ScopeInterface::SCOPE_STORE ); - $dateTimeZone = new DateTimeZone($timezoneString); - return $dateTimeZone; + return new DateTimeZone($timezoneString); } static private function fillWithRecurrenceConfig(&$dataObj, $storeConfig)