Skip to content

Commit

Permalink
Add support for ESD items
Browse files Browse the repository at this point in the history
ISSUE: CS-4357
  • Loading branch information
goran-stamenkovski-logeecom committed Jun 8, 2023
1 parent 78977ec commit 7e8f418
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion AdyenPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace AdyenPayment;

use AdyenPayment\Components\CompilerPass\NotificationProcessorCompilerPass;
use AdyenPayment\Components\ShopwareVersionCheck;
use AdyenPayment\Models\Enum\PaymentMethod\SourceType;
use AdyenPayment\Models\Notification;
use AdyenPayment\Models\PaymentInfo;
Expand Down Expand Up @@ -73,6 +74,7 @@ private function loadServices(ContainerBuilder $container): void

$loader->load(__DIR__.'/Resources/services/*.xml');

/** @var ShopwareVersionCheck $versionCheck */
$versionCheck = $container->get('adyen_payment.components.shopware_version_check');
if ($versionCheck && $versionCheck->isHigherThanShopwareVersion('v5.6.2')) {
$loader->load(__DIR__.'/Resources/services/version/563/*.xml');
Expand All @@ -99,11 +101,16 @@ public function update(UpdateContext $context): void
$this->installAttributes();
$this->installStoredPaymentUmbrella($context);

if (version_compare($context->getCurrentVersion(), '3.9.7', '<=')) {
$this->activatePaymentsForEsd();
}

$tool = new SchemaTool($this->container->get('models'));
$classes = $this->getModelMetaData();
$tool->updateSchema($classes, true);

$context->scheduleClearCache(InstallContext::CACHE_LIST_FRONTEND);

parent::update($context);
}

Expand Down Expand Up @@ -204,6 +211,7 @@ private function installStoredPaymentUmbrella(InstallContext $context): void

$payment = new Payment();
$payment->setActive(true);
$payment->setEsdActive(true);
$payment->setName(self::ADYEN_STORED_PAYMENT_UMBRELLA_CODE);
$payment->setSource(SourceType::adyen()->getType());
$payment->setHide(true);
Expand All @@ -227,11 +235,21 @@ private function installStoredPaymentUmbrella(InstallContext $context): void
if (null !== $paymentId && !$paymentInDb['active']) {
$database->update(
's_core_paymentmeans',
['active' => true],
['active' => true, 'esdactive' => true],
['id = ?' => $paymentId]
);
}
}

private function activatePaymentsForEsd(): void
{
$database = $this->container->get('db');
$database->update(
's_core_paymentmeans',
['esdactive' => true],
['source = ?' => SourceType::adyen()->getType()]
);
}
}

if (AdyenPayment::isPackage()) {
Expand Down
1 change: 1 addition & 0 deletions Models/Payment/PaymentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function createFromAdyen(PaymentMethod $paymentMethod, Shop $shop): Payme
{
$new = new Payment();
$new->setActive(true);
$new->setEsdActive(true);
$new->setName($paymentMethod->code());
$new->setDescription($paymentMethod->name());
$new->setAdditionalDescription($this->provideAdditionalDescription($paymentMethod));
Expand Down

0 comments on commit 7e8f418

Please sign in to comment.