diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ca13177..22009946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - use PayPal-Request-ID in any API-Call (via Client, v3.0.10) - 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 diff --git a/metadata.php b/metadata.php index af7880f7..dd046d2f 100644 --- a/metadata.php +++ b/metadata.php @@ -149,6 +149,11 @@ 'block' => 'checkout_basket_emptyshippingcart', 'file' => 'views/smarty/frontend/blocks/page/checkout/basket__checkout_basket_emptyshippingcart.tpl', ], + [ + 'template' => 'payment_main.tpl', + 'block' => 'admin_payment_main_form', + 'file' => '/views/blocks/admin/admin_payment_main_form.tpl', + ], [ 'template' => 'page/checkout/payment.tpl', 'block' => 'select_payment', @@ -446,12 +451,6 @@ 'value' => 60, 'group' => null ], - [ - 'name' => 'oscPayPalActivePayments', - 'type' => 'arr', - 'value' => [], - 'group' => null - ], [ 'name' => 'oscPayPalSetVaulting', 'type' => 'bool', diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index e19c6917..6f20d5c4 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -61,6 +61,7 @@ public function getPaymentList() * check: * - all none PP-Payments * - payPalHealth + * - deprecated payment method * - currency * - country * - netto-mode @@ -71,6 +72,8 @@ public function getPaymentList() !isset($payPalDefinitions[$key]) || ( $payPalHealth && + // don't add payment that is deprecated + ( !PayPalDefinitions::isDeprecatedPayment($payment->getId()) ) && ( empty($payPalDefinitions[$key]['currencies']) || in_array($actShopCurrency->name, $payPalDefinitions[$key]['currencies'], true) diff --git a/src/Core/PayPalDefinitions.php b/src/Core/PayPalDefinitions.php index f0e0bc7c..e8023630 100644 --- a/src/Core/PayPalDefinitions.php +++ b/src/Core/PayPalDefinitions.php @@ -322,7 +322,8 @@ final class PayPalDefinitions 'constraints' => self::PAYMENT_CONSTRAINTS_UAPM, 'onlybrutto' => false, 'buttonpayment' => false, - 'defaulton' => true + 'defaulton' => false, + 'deprecated' => true, ], // uAPM iDEAL 'oscpaypal_ideal' => [ @@ -447,4 +448,18 @@ public static function isPayPalPayment(string $paymentId): bool { return (isset(self::PAYPAL_DEFINTIONS[$paymentId])); } + + /** + * Check if payment is deprecated + * + * @param string $paymentId + * @return bool + */ + public static function isDeprecatedPayment(string $paymentId): bool + { + if ( isset(self::PAYPAL_DEFINTIONS[$paymentId]['deprecated']) && self::PAYPAL_DEFINTIONS[$paymentId]['deprecated'] === true ) { + return true; + } + return false; + } } diff --git a/src/Model/Payment.php b/src/Model/Payment.php index 6050f491..f0bd8687 100644 --- a/src/Model/Payment.php +++ b/src/Model/Payment.php @@ -20,4 +20,24 @@ public function isUAPMPayment(): bool { return PayPalDefinitions::isUAPMPayment($this->getId()); } + + /** + * Check if payment method is PayPal payment + * + * @return bool + */ + public function isPayPalPayment(): bool + { + return PayPalDefinitions::isPayPalPayment($this->getId()); + } + + /** + * Check if payment method is deprecated + * + * @return bool + */ + public function isDeprecatedPayment(): bool + { + return PayPalDefinitions::isDeprecatedPayment($this->getId()); + } } diff --git a/src/Service/ModuleSettings.php b/src/Service/ModuleSettings.php index 73d4f90d..d9006953 100644 --- a/src/Service/ModuleSettings.php +++ b/src/Service/ModuleSettings.php @@ -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 */ @@ -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 */ diff --git a/src/Service/StaticContent.php b/src/Service/StaticContent.php index ed9d1ed9..16d59a18 100644 --- a/src/Service/StaticContent.php +++ b/src/Service/StaticContent.php @@ -25,23 +25,22 @@ 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 { foreach (PayPalDefinitions::getPayPalDefinitions() as $paymentId => $paymentDefinitions) { + // skip creation and activation of deprecated payments + if (PayPalDefinitions::isDeprecatedPayment($paymentId)) { + $this->deactivatePaymentMethod($paymentId); + continue; + } $paymentMethod = oxNew(EshopModelPayment::class); if ($paymentMethod->load($paymentId)) { - $this->reActivatePaymentMethod($paymentId); continue; } $this->createPaymentMethod($paymentId, $paymentDefinitions); @@ -104,20 +103,19 @@ 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 */ + /** + * Try to load payment model based on given id an set payment inactive + * + * @param string $paymentId + * @return void + * @throws \Exception + */ + protected function deactivatePaymentMethod(string $paymentId) : void { $paymentModel = oxNew(EshopModelPayment::class); - $paymentModel->load($paymentId); - - $paymentModel->oxpayments__oxactive = new Field(true); - - $paymentModel->save(); + if ($paymentModel->load($paymentId)) { + $paymentModel->oxpayments__oxactive = new Field(false); + $paymentModel->save(); + } } public function ensureStaticContents(): void diff --git a/views/de/admin_translations.php b/views/de/admin_translations.php index c6eba995..20d232b1 100644 --- a/views/de/admin_translations.php +++ b/views/de/admin_translations.php @@ -274,5 +274,6 @@ Kaufabwicklung ermöglichen. Mit ihren gespeicherten Zahlungsdaten können Kund:innen mit nur wenigen Klicks Wiederholungskäufe tätigen. Dies kann für Sie eine höhere Checkout-Conversion bedeuten.', - 'OSC_PAYPAL_INSTALLPROCESS_FAILED' => 'Because the module was not installed correctly via Composer, errors occurred during the (de)activation of the module. Please reinstall the module via composer and repeat the process.' + // PayPal Payment + 'OSC_PAYPAL_PAYMENT_DEPRECATED' => 'Diese PayPal Zahlungsart kann nicht mehr aktiviert werden, da diese demnächst entfernt wird!', ]; diff --git a/views/en/admin_translations.php b/views/en/admin_translations.php index 45c8f066..73c92aa4 100644 --- a/views/en/admin_translations.php +++ b/views/en/admin_translations.php @@ -275,5 +275,6 @@ Enable purchase processing. With their saved payment details, customers can make repeat purchases with just a few clicks. This can be for you mean higher checkout conversion.', - 'OSC_PAYPAL_INSTALLPROCESS_FAILED' => 'Because the module was not installed correctly via Composer, errors occurred during the (de)activation of the module. Please reinstall the module via composer and repeat the process.' + // PayPal Payment + 'OSC_PAYPAL_PAYMENT_DEPRECATED' => 'This PayPal payment method can no longer be activated as it will be removed soon!', ];