Skip to content

Commit

Permalink
Removing payment method deactivation during module deactivation. Merc…
Browse files Browse the repository at this point in the history
…hants must now do this themselves
  • Loading branch information
mariolorenz committed Oct 17, 2024
1 parent 3163cfe commit 4f0b89c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 60 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- add Default-Shippingcosts for PP-Express to prevent overcharge.
- use central logger like in v2 Branch
- mark GiroPay as deprecated
- [0007161](https://bugs.oxid-esales.com/view.php?id=7161): Removing payment method deactivation during module deactivation. Merchants must now do this themselves


## [3.3.4] - 2024-01-26

Expand Down
6 changes: 0 additions & 6 deletions metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,6 @@
'value' => 60,
'group' => null
],
[
'name' => 'oscPayPalActivePayments',
'type' => 'arr',
'value' => [],
'group' => null
],
[
'name' => 'oscPayPalSetVaulting',
'type' => 'bool',
Expand Down
18 changes: 0 additions & 18 deletions src/Core/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ public static function onActivate(): void
*/
public static function onDeactivate(): void
{
$activePayments = [];
foreach (PayPalDefinitions::getPayPalDefinitions() as $paymentId => $paymentDefinitions) {
$paymentMethod = oxNew(EshopModelPayment::class);
if (
$paymentMethod->load($paymentId) &&
(bool)$paymentMethod->oxpayments__oxactive->value
) {
if (!PayPalDefinitions::isDeprecatedPayment($paymentId)) {
$activePayments[] = $paymentId;
}
$paymentMethod->assign([
'oxactive' => false
]);
$paymentMethod->save();
}
}
$service = self::getModuleSettingsService();
$service->saveActivePayments($activePayments);
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/Service/ModuleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,6 @@ public function getIsVaultingActive(): bool
return (bool)$this->getSettingValue('oscPayPalSetVaulting');
}

public function getActivePayments(): array
{
/** @var array|null $activePayments */
$activePayments = $this->getSettingValue('oscPayPalActivePayments');
return $activePayments ?: [];
}

/**
* @throws ModuleSettingNotFountException
*/
Expand Down Expand Up @@ -464,11 +457,6 @@ public function saveWebhookId(string $webhookId): void
}
}

public function saveActivePayments(array $activePayments): void
{
$this->save('oscPayPalActivePayments', $activePayments);
}

/**
* add details controller to requireSession
*/
Expand Down
26 changes: 2 additions & 24 deletions src/Service/StaticContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ class StaticContent
/** @var QueryBuilderFactoryInterface */
private $queryBuilderFactory;

/** @var ModuleSettings */
private $moduleSettings;

public function __construct(
QueryBuilderFactoryInterface $queryBuilderFactory,
ModuleSettings $moduleSettings
QueryBuilderFactoryInterface $queryBuilderFactory
) {
$this->queryBuilderFactory = $queryBuilderFactory;
$this->moduleSettings = $moduleSettings;
}

public function ensurePayPalPaymentMethods(): void
Expand All @@ -46,7 +41,6 @@ public function ensurePayPalPaymentMethods(): void
}
$paymentMethod = oxNew(EshopModelPayment::class);
if ($paymentMethod->load($paymentId)) {
$this->reActivatePaymentMethod($paymentId);
continue;
}
$this->createPaymentMethod($paymentId, $paymentDefinitions);
Expand Down Expand Up @@ -109,25 +103,9 @@ protected function createPaymentMethod(string $paymentId, array $definitions): v
}
}

protected function reActivatePaymentMethod(string $paymentId): void
{
$activePayments = $this->moduleSettings->getActivePayments();
if (!in_array($paymentId, $activePayments, true)) {
return;
}

/** @var EshopModelPayment $paymentModel */
$paymentModel = oxNew(EshopModelPayment::class);
$paymentModel->load($paymentId);

$paymentModel->oxpayments__oxactive = new Field(true);

$paymentModel->save();
}

/**
* Try to load payment model based on given id an set payment inactive
*
*
* @param string $paymentId
* @return void
* @throws \Exception
Expand Down

0 comments on commit 4f0b89c

Please sign in to comment.