Skip to content

Commit

Permalink
Merge branch 'b-6.3.x' into PSPAYPAL_TakeOverChangesOXID7
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Dec 20, 2024
2 parents 7f58625 + b248dd3 commit 8c6fa41
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 54 deletions.
21 changes: 12 additions & 9 deletions src/Controller/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Core/Api/VaultingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}

Expand Down Expand Up @@ -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 = [];
}

Expand Down Expand Up @@ -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 = [];
}

Expand All @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Core/PayPalDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 6 additions & 7 deletions src/Service/ModuleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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']) ||
Expand Down
4 changes: 2 additions & 2 deletions src/Service/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion src/Service/StaticContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
60 changes: 30 additions & 30 deletions src/Traits/AccountControllerTrait.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidSolutionCatalysts\PayPal\Traits;

use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\PayPal\Core\ServiceFactory;

trait AccountControllerTrait
{
public function deleteVaultedPayment(): void
{
$paymentTokenId = Registry::getRequest()->getRequestEscapedParameter("paymentTokenId");
$vaultingService = Registry::get(ServiceFactory::class)->getVaultingService();

if (!$vaultingService->deleteVaultedPayment($paymentTokenId)) {
Registry::getUtilsView()->addErrorToDisplay(
Registry::getLang()->translateString('OSC_PAYPAL_DELETE_FAILED'),
false,
true
);
}
}
}
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidSolutionCatalysts\PayPal\Traits;

use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\PayPal\Core\ServiceFactory;

trait AccountControllerTrait
{
public function deleteVaultedPayment(): void
{
$paymentTokenId = Registry::getRequest()->getRequestEscapedParameter("paymentTokenId");
$vaultingService = Registry::get(ServiceFactory::class)->getVaultingService();

if (!$vaultingService->deleteVaultedPayment($paymentTokenId)) {
Registry::getUtilsView()->addErrorToDisplay(
Registry::getLang()->translateString('OSC_PAYPAL_DELETE_FAILED'),
false,
true
);
}
}
}

0 comments on commit 8c6fa41

Please sign in to comment.