diff --git a/CHANGELOG.md b/CHANGELOG.md index fca6d43e..f398aa01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Introduce ApplePay-Payment - use PayPal-Client v2.0.14 - add Default-Shippingcosts for PP-Express to prevent overcharge. +- mark GiroPay as deprecated ## [2.4.0] - 2024-04-04 diff --git a/metadata.php b/metadata.php index 438cd812..ed80afd4 100755 --- a/metadata.php +++ b/metadata.php @@ -201,6 +201,11 @@ 'block' => 'dd_layout_page_header_icon_menu_minibasket_functions', 'file' => '/views/blocks/widget/minibasket/dd_layout_page_header_icon_menu_minibasket_functions.tpl', ], + [ + 'template' => 'payment_main.tpl', + 'block' => 'admin_payment_main_form', + 'file' => '/views/blocks/admin/admin_payment_main_form.tpl', + ], // @Todo PAYPAL-486: Using the same file, with 2 themes. Should be more generic, if possible. [ 'template' => 'page/checkout/payment.tpl', diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 90d6ce86..e5217d97 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -134,6 +134,7 @@ public function getPaymentList() * check: * - all none PP-Payments * - payPalHealth + * - deprecated payment method * - currency * - country * - netto-mode @@ -144,6 +145,8 @@ public function getPaymentList() !isset($payPalDefinitions[$key]) || ( $payPalHealth && + //dont 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/Events/Events.php b/src/Core/Events/Events.php index ddf93145..6cc98b11 100644 --- a/src/Core/Events/Events.php +++ b/src/Core/Events/Events.php @@ -60,7 +60,11 @@ public static function onDeactivate(): void $paymentMethod->load($paymentId) && $paymentMethod->getFieldData('oxactive') ) { - $activePayments[] = $paymentId; + if (PayPalDefinitions::isDeprecatedPayment($paymentId)) { + //dont set deprecated payments to active payment list + } else { + $activePayments[] = $paymentId; + } $paymentMethod->assign([ 'oxactive' => false ]); diff --git a/src/Core/PayPalDefinitions.php b/src/Core/PayPalDefinitions.php index 10ddb92c..193cf022 100644 --- a/src/Core/PayPalDefinitions.php +++ b/src/Core/PayPalDefinitions.php @@ -380,7 +380,8 @@ final class PayPalDefinitions 'constraints' => self::PAYMENT_CONSTRAINTS_UAPM, 'onlybrutto' => false, 'buttonpayment' => false, - 'defaulton' => true + 'defaulton' => false, + 'deprecated' => true, ], // uAPM iDEAL 'oscpaypal_ideal' => [ @@ -513,4 +514,18 @@ public static function isPayPalVaultingPossible(string $paymentId, string $paypa && self::PAYPAL_DEFINTIONS[$paymentId]['vaultingtype'] === $paypalPaymentType ); } + + /** + * 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..20a1fefa 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/StaticContent.php b/src/Service/StaticContent.php index ed9d1ed9..e12c317c 100644 --- a/src/Service/StaticContent.php +++ b/src/Service/StaticContent.php @@ -39,6 +39,11 @@ public function __construct( 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); @@ -120,6 +125,21 @@ protected function reActivatePaymentMethod(string $paymentId): void $paymentModel->save(); } + /** + * 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); + if ($paymentModel->load($paymentId)) { + $paymentModel->oxpayments__oxactive = new Field(false); + $paymentModel->save(); + } + } + public function ensureStaticContents(): void { foreach (PayPalDefinitions::getPayPalStaticContents() as $content) { diff --git a/views/admin/de/admin_lang.php b/views/admin/de/admin_lang.php index 931503d2..89ac4b50 100755 --- a/views/admin/de/admin_lang.php +++ b/views/admin/de/admin_lang.php @@ -283,5 +283,8 @@ 'OSC_PAYPAL_GOOGLEPAY_ADDRESS_ACTIVATE' => 'Speicherung der Adresse aktivieren', 'HELP_OSC_OSC_PAYPAL_GOOGLEPAY_ADRESS_ACTIVATE' => 'Übernahme der Lieferadresse von GooglePay', - 'OSC_PAYPAL_INSTALLPROCESS_FAILED' => 'Da das Modul nicht korrekt per Composer installiert ist, sind Fehler bei der (De-)Aktivierung des Moduls aufgetreten. Bitte installieren Sie das Modul via Composer frisch und wiederholen den Vorgang.' + 'OSC_PAYPAL_INSTALLPROCESS_FAILED' => 'Da das Modul nicht korrekt per Composer installiert ist, sind Fehler bei der (De-)Aktivierung des Moduls aufgetreten. Bitte installieren Sie das Modul via Composer frisch und wiederholen den Vorgang.', + + // PayPal Payment + 'OSC_PAYPAL_PAYMENT_DEPRECATED' => 'Diese PayPal Zahlungsart kann nicht mehr aktiviert werden, da diese demnächst entfernt wird!', ]; diff --git a/views/admin/en/admin_lang.php b/views/admin/en/admin_lang.php index 56e59217..1391c290 100755 --- a/views/admin/en/admin_lang.php +++ b/views/admin/en/admin_lang.php @@ -283,5 +283,8 @@ 'OSC_PAYPAL_GOOGLEPAY_ADDRESS_ACTIVATE' => 'Google Pay address active', 'HELP_OSC_OSC_PAYPAL_GOOGLEPAY_ADRESS_ACTIVATE' => 'Takeover delivery address from googlepay', - '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.' + '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!', ];