Skip to content

Commit

Permalink
Merge pull request #331 from OXID-eSales/PSPAYPAL-810_DeativatePaymen…
Browse files Browse the repository at this point in the history
…tMethods

Removing payment method deactivation
  • Loading branch information
HonkDerHase authored Sep 5, 2024
2 parents 13f60ed + 56a9f74 commit d5c0ca1
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### FIX

- [0007161](https://bugs.oxid-esales.com/view.php?id=7161): Removing payment method deactivation during module deactivation. Merchants must now do this themselves
- provide correct encoded Shopname to PayPal
- Fix order of closing brackets in applepay-template
- [0007711](https://bugs.oxid-esales.com/view.php?id=7711): Temporary orders that are no longer needed and already have an order number will be cancelled. Temporary orders without an order number will still be deleted
Expand Down
6 changes: 0 additions & 6 deletions metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,6 @@
'value' => 60,
'group' => null
],
[
'name' => 'oscPayPalActivePayments',
'type' => 'arr',
'value' => [],
'group' => null
],
[
'group' => null,
'name' => 'oscPayPalLocales',
Expand Down
22 changes: 0 additions & 22 deletions src/Core/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +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) &&
$paymentMethod->getFieldData('oxactive')
) {
if (PayPalDefinitions::isDeprecatedPayment($paymentId)) {
//dont set deprecated payments to active payment list
} else {
$activePayments[] = $paymentId;
}
$paymentMethod->assign([
'oxactive' => false
]);
$paymentMethod->save();
}
}
$service = self::getModuleSettingsService();
if ($service) {
$service->saveActivePayments($activePayments);
}
}

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

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

public function getShopName(): string
{
return Registry::getConfig()->getActiveShop()->getRawFieldData('oxname');
}

/**
* @throws ModuleSettingNotFountException
*/
Expand Down Expand Up @@ -510,10 +498,6 @@ public function saveWebhookId(string $webhookId): void
}
}

public function saveActivePayments(array $activePayments): void
{
$this->save('oscPayPalActivePayments', $activePayments);
}
public function saveGooglePayEligibility(bool $isGooglePayEligibility): void
{
if ($this->isSandbox()) {
Expand Down
19 changes: 1 addition & 18 deletions src/Service/StaticContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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 +108,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 d5c0ca1

Please sign in to comment.