Skip to content

Commit

Permalink
Merge pull request #315 from OXID-eSales/PSPAYPAL-801_Deactivate_Giropay
Browse files Browse the repository at this point in the history
Pspaypal 801 deactivate giropay
  • Loading branch information
mariolorenz authored Jul 19, 2024
2 parents 9f4ce41 + 9e61963 commit 85633e9
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions src/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function getPaymentList()
* check:
* - all none PP-Payments
* - payPalHealth
* - deprecated payment method
* - currency
* - country
* - netto-mode
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Events/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
Expand Down
17 changes: 16 additions & 1 deletion src/Core/PayPalDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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;
}
}
20 changes: 20 additions & 0 deletions src/Model/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
20 changes: 20 additions & 0 deletions src/Service/StaticContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion views/admin/de/admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!',
];
5 changes: 4 additions & 1 deletion views/admin/en/admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!',
];

0 comments on commit 85633e9

Please sign in to comment.