diff --git a/src/Controller/ProxyController.php b/src/Controller/ProxyController.php index 40ae9ee6..dd53b19c 100644 --- a/src/Controller/ProxyController.php +++ b/src/Controller/ProxyController.php @@ -418,17 +418,20 @@ public function setPayPalPaymentMethod($defaultPayPalPaymentId = PayPalDefinitio $requestedPayPalPaymentId = $this->getRequestedPayPalPaymentId($defaultPayPalPaymentId); if ($session->getVariable('paymentid') !== $requestedPayPalPaymentId) { $basket->setPayment($requestedPayPalPaymentId); + $session->setVariable('paymentid', $requestedPayPalPaymentId); + } + $this->getActiveShippingSetId($session, $user, $basket); + } - // get the active shippingSetId - /** @psalm-suppress InvalidArgument */ - [, $shippingSetId,] = - Registry::get(DeliverySetList::class)->getDeliverySetData('', $user, $basket); + private function getActiveShippingSetId($session, $user, $basket): void + { + /** @psalm-suppress InvalidArgument */ + [, $shippingSetId,] = + Registry::get(DeliverySetList::class)->getDeliverySetData('', $user, $basket); - if ($shippingSetId) { - $basket->setShipping($shippingSetId); - $session->setVariable('sShipSet', $shippingSetId); - } - $session->setVariable('paymentid', $requestedPayPalPaymentId); + if ($shippingSetId) { + $basket->setShipping($shippingSetId); + $session->setVariable('sShipSet', $shippingSetId); } } diff --git a/src/Core/Api/VaultingService.php b/src/Core/Api/VaultingService.php index 25c6bd30..ff506e75 100644 --- a/src/Core/Api/VaultingService.php +++ b/src/Core/Api/VaultingService.php @@ -45,7 +45,7 @@ public function generateUserIdToken($payPalCustomerId = false): array $body = $response->getBody(); } $result = json_decode((string)$body, true, 512, JSON_THROW_ON_ERROR); - } catch (ApiException|JsonException $e) { + } catch (ApiException | JsonException $e) { $result = []; } @@ -98,7 +98,7 @@ public function createVaultSetupToken(bool $card = false): array $body = $response->getBody(); } $result = json_decode((string)$body, true, 512, JSON_THROW_ON_ERROR); - } catch (ApiException|JsonException $e) { + } catch (ApiException | JsonException $e) { $result = []; } @@ -215,7 +215,7 @@ public function createVaultPaymentToken(string $setupToken): array $body = $response->getBody(); } $result = json_decode((string)$body, true, 512, JSON_THROW_ON_ERROR); - } catch (ApiException|JsonException $e) { + } catch (ApiException | JsonException $e) { $result = []; } @@ -242,7 +242,7 @@ public function getVaultPaymentTokens(string $paypalCustomerId): array $body = $response->getBody(); } $result = json_decode((string)$body, true, 512, JSON_THROW_ON_ERROR); - } catch (ApiException|JsonException $e) { + } catch (ApiException | JsonException $e) { $this->getServiceFromContainer(Logger::class) ->log('error', __CLASS__ . ' ' . __FUNCTION__ . ' : ' . $e->getMessage()); $result = []; diff --git a/src/Core/PayPalDefinitions.php b/src/Core/PayPalDefinitions.php index 17842325..46b8f0f6 100644 --- a/src/Core/PayPalDefinitions.php +++ b/src/Core/PayPalDefinitions.php @@ -520,7 +520,7 @@ public static function isPayPalVaultingPossible(string $paymentId, ?string $payp */ public static function isDeprecatedPayment(string $paymentId): bool { - if ( isset(self::PAYPAL_DEFINTIONS[$paymentId]['deprecated']) && self::PAYPAL_DEFINTIONS[$paymentId]['deprecated'] === true ) { + if (isset(self::PAYPAL_DEFINTIONS[$paymentId]['deprecated']) && self::PAYPAL_DEFINTIONS[$paymentId]['deprecated'] === true) { return true; } return false; diff --git a/src/Service/ModuleSettings.php b/src/Service/ModuleSettings.php index add9a2b4..11ea9123 100755 --- a/src/Service/ModuleSettings.php +++ b/src/Service/ModuleSettings.php @@ -415,8 +415,7 @@ public function getShopName(): string $shop = Registry::getConfig()->getActiveShop(); if (isset($shop->oxshops__oxname->rawValue)) { $value = $shop->oxshops__oxname->rawValue; - } - elseif(isset($shop->oxshops__oxname->value)) { + } elseif (isset($shop->oxshops__oxname->value)) { $value = $shop->oxshops__oxname->value; } return $value; @@ -432,8 +431,7 @@ public function getInfoEMail(): string $shop = Registry::getConfig()->getActiveShop(); if (isset($shop->oxshops__oxinfoemail->rawValue)) { $value = $shop->oxshops__oxinfoemail->rawValue; - } - elseif(isset($shop->oxshops__oxinfoemail->value)) { + } elseif (isset($shop->oxshops__oxinfoemail->value)) { $value = $shop->oxshops__oxinfoemail->value; } return $value; @@ -630,9 +628,9 @@ public function isVaultingAllowedForPayment(string $paymentId): bool $payment = oxNew(Payment::class); $payment->load($paymentId); $paymentEnabled = (bool)$payment->oxpayments__oxactive->value; - $paymentType = PayPalDefinitions::getPayPalDefinitions()[$paymentId]["vaultingtype"]; + $vaultingType = PayPalDefinitions::getPayPalDefinitions()[$paymentId]["vaultingtype"]; - $session = Registry::getSession(); + $session = Registry::getSession(); $actShipSet = $session->getVariable('sShipSet'); $basket = $session->getBasket(); $user = $session->getUser(); @@ -649,7 +647,8 @@ public function isVaultingAllowedForPayment(string $paymentId): bool return $paymentEnabled && $this->getIsVaultingActive() && - PayPalDefinitions::isPayPalVaultingPossible($paymentId, $paymentType) && + $vaultingType && + PayPalDefinitions::isPayPalVaultingPossible($paymentId, $vaultingType) && array_key_exists($paymentId, $paymentList) && ( empty($payPalDefinitions[$paymentId]['currencies']) || diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 36aab501..754c9ff1 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -305,7 +305,7 @@ public function doCapturePayPalOrder( } elseif ($payPalOrder->status !== Constants::PAYPAL_STATUS_COMPLETED) { $request = new OrderCaptureRequest(); //order number must be resolved before order patching - if (!$order->hasOrderNumber()){ + if (!$order->hasOrderNumber()) { $order->setOrderNumber(); } @@ -808,7 +808,7 @@ public function getCustomIdParameter(?EshopModelOrder $order): string $module->load(Module::MODULE_ID); $orderNumber = $order instanceof EshopModelOrder ? $order->getFieldData('oxordernr') : null; - if($moduleSettings->isCustomIdSchemaStructural()){ + if ($moduleSettings->isCustomIdSchemaStructural()) { $customID = [ 'oxordernr' => $orderNumber, 'moduleVersion' => $module->getInfo('version'), diff --git a/src/Service/StaticContent.php b/src/Service/StaticContent.php index 41f49d21..6e70634f 100644 --- a/src/Service/StaticContent.php +++ b/src/Service/StaticContent.php @@ -115,7 +115,8 @@ protected function createPaymentMethod(string $paymentId, array $definitions): v * @return void * @throws \Exception */ - protected function deactivatePaymentMethod(string $paymentId) : void { + protected function deactivatePaymentMethod(string $paymentId): void + { $paymentModel = oxNew(EshopModelPayment::class); if ($paymentModel->load($paymentId)) { $paymentModel->oxpayments__oxactive = new Field(false); diff --git a/src/Traits/AccountControllerTrait.php b/src/Traits/AccountControllerTrait.php index 51dfea57..e3782bfc 100644 --- a/src/Traits/AccountControllerTrait.php +++ b/src/Traits/AccountControllerTrait.php @@ -1,30 +1,30 @@ -getRequestEscapedParameter("paymentTokenId"); - $vaultingService = Registry::get(ServiceFactory::class)->getVaultingService(); - - if (!$vaultingService->deleteVaultedPayment($paymentTokenId)) { - Registry::getUtilsView()->addErrorToDisplay( - Registry::getLang()->translateString('OSC_PAYPAL_DELETE_FAILED'), - false, - true - ); - } - } -} +getRequestEscapedParameter("paymentTokenId"); + $vaultingService = Registry::get(ServiceFactory::class)->getVaultingService(); + + if (!$vaultingService->deleteVaultedPayment($paymentTokenId)) { + Registry::getUtilsView()->addErrorToDisplay( + Registry::getLang()->translateString('OSC_PAYPAL_DELETE_FAILED'), + false, + true + ); + } + } +}