Skip to content

Commit

Permalink
Add v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkielb committed Feb 9, 2024
1 parent cbe7791 commit ca811a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "PayU integration for Shopware 6",
"type": "shopware-platform-plugin",
"license": "proprietary",
"version": "2.0.0",
"version": "2.0.1",
"authors": [
{
"name": "Crehler Sp. z o. o.",
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<argument type="service" id="Crehler\PayU\Util\VendorLoader" />
<argument type="service" id="parameter_bag"/>
<argument type="service" id="crehler_payu.logger"/>
<argument type="service" id="request_stack"/>
</service>
<service id="Crehler\PayU\Service\PaymentDetailsReader">
<argument type="service" id="language.repository"/>
Expand Down
44 changes: 25 additions & 19 deletions src/Service/PayU/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* Class ConfigurationFactor
Expand All @@ -44,7 +45,7 @@ class ConfigurationService
/**
* ConfigurationFactor constructor.
*/
public function __construct(private readonly SystemConfigService $configurationService, VendorLoader $vendorLoader, private readonly ParameterBagInterface $parameterBag, private readonly Logger $logger)
public function __construct(private readonly SystemConfigService $configurationService, VendorLoader $vendorLoader, private readonly ParameterBagInterface $parameterBag, private readonly Logger $logger, private readonly RequestStack $request)
{
$vendorLoader->loadOpenPayU();
}
Expand All @@ -54,24 +55,25 @@ public function __construct(private readonly SystemConfigService $configurationS
*/
public function initialize(?bool $sandbox = null)
{
$salesChannel = $this->request->getCurrentRequest()?->get('sw-sales-channel-id');
if ($sandbox === null) {
$sandbox = (int) $this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX);
$sandbox = (int) $this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX, $salesChannel);
}
if ($sandbox) {
$this->initializePayUStaticConfiguration(
true,
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_POS_ID),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX__MD5_KEY),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_ID),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_SECRET)
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_POS_ID, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX__MD5_KEY, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_ID, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_SECRET, $salesChannel)
);
} else {
$this->initializePayUStaticConfiguration(
false,
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_POS_ID),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_MD5_KEY),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_ID),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_SECRET)
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_POS_ID, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_MD5_KEY, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_ID, $salesChannel),
$this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_SECRET, $salesChannel)
);
}
}
Expand All @@ -81,19 +83,21 @@ public function initialize(?bool $sandbox = null)
*/
public function isCompleteConfiguration()
{
$salesChannel = $this->request->getCurrentRequest()?->get('sw-sales-channel-id');

if ($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX)) {
if (strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_POS_ID)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX__MD5_KEY)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_ID)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_SECRET)) == 0
if (strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_POS_ID, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX__MD5_KEY, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_ID, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX_CLIENT_SECRET, $salesChannel)) == 0
) {
return false;
}
} else {
if (strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_POS_ID)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_MD5_KEY)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_ID)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_SECRET)) == 0
if (strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_POS_ID, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_MD5_KEY, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_ID, $salesChannel)) == 0 ||
strlen($this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_CLIENT_SECRET, $salesChannel)) == 0
) {
return false;
}
Expand All @@ -107,7 +111,9 @@ public function isCompleteConfiguration()
*/
public function isSadBox()
{
return (bool) $this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX);
$salesChannel = $this->request->getCurrentRequest()?->get('sw-sales-channel-id');

return (bool) $this->configurationService->get(self::CONFIG_PLUGIN_PREFIX . self::CONFIG_SANDBOX, $salesChannel);
}

/**
Expand Down

0 comments on commit ca811a3

Please sign in to comment.