Skip to content

Commit

Permalink
Merge pull request #111 from OXID-eSales/AM-111_Takeover_107_101
Browse files Browse the repository at this point in the history
Update adyen payment module and fix maintenance mode issue for oxid 7
  • Loading branch information
mariolorenz authored Jan 23, 2024
2 parents 7da4e13 + 3be444c commit fc959c4
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 86 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ composer.lock
tests/reports/
tests/.phpunit.result.cache
source/
/resources/node_modules/
/tests/.env
resources/node_modules/
tests/.env
var/
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.1.1] - 2023-??-??
## [2.1.4] - 2024-01-16

- [0007569](https://bugs.oxid-esales.com/view.php?id=7569): Fix Maintenance Mode after entering Sandbox Data
- Take over all changes from Version 1.1.2 to 1.1.4
- Split Version for OXID 7

## [1.1.1] - 2023-09-08
Expand Down
6 changes: 1 addition & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@
"adyen/php-api-library": "14.*"
},
"require-dev": {
"codeception/module-rest": "^2.0.2",
"codeception/module-phpbrowser": "^2.0.3",
"codeception/module-db": "^2.0.2",
"phpstan/phpstan": "^1.9.2",
"squizlabs/php_codesniffer": "3.*",
"phpmd/phpmd": "^2.11",
"dg/bypass-finals": "^1.4",
"oxid-esales/oxideshop-ce": "dev-b-7.0.x"
"oxid-esales/oxideshop-ce": "^7.0"
},
"conflicts": {
"oxid-esales/oxideshop-ce": "<7.0"
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Admin/AdminOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\Adyen\Model\AdyenHistoryList;
use OxidEsales\Eshop\Application\Model\Order;
use OxidSolutionCatalysts\Adyen\Core\Module;
use OxidSolutionCatalysts\Adyen\Model\Order as AdyenOrder;
use OxidSolutionCatalysts\Adyen\Service\OxNewService;
use OxidSolutionCatalysts\Adyen\Traits\ServiceContainer;
Expand All @@ -29,7 +30,7 @@ class AdminOrderController extends AdminDetailsController
* Current class template name.
* @var string
*/
protected $_sThisTemplate = '@' . \OxidSolutionCatalysts\Adyen\Core\Module::MODULE_ID . '/osc_adyen_order'; //NOSONAR
protected $_sThisTemplate = '@' . Module::MODULE_ID . '/osc_adyen_order'; //NOSONAR

/**
* Executes parent method parent::render()
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Admin/OrderList.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function render()
* @inheritDoc
* @SuppressWarnings(PHPMD.StaticAccess)
*/
protected function _buildSelectString($listObject = null)
protected function buildSelectString($listObject = null)
{
$request = Registry::getRequest();
/** @var null|string $searchField */
Expand All @@ -60,7 +60,7 @@ protected function _buildSelectString($listObject = null)
$tableName = Module::ADYEN_HISTORY_TABLE;

if ($tableName !== $searchField || is_null($listObject)) {
return parent::_buildSelectString($listObject);
return parent::buildSelectString($listObject);
}

/** @var BaseModel $listObject */
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class Module
{
public const MODULE_NAME_DE = 'Adyen Payment für OXID';
public const MODULE_NAME_EN = 'Adyen Payment for OXID';
public const MODULE_VERSION = '2.1.1.rc.1';
public const MODULE_VERSION = '2.1.4.rc.1';
public const MODULE_VERSION_FULL = self::MODULE_VERSION . ' SDK-Version ' . self::ADYEN_SDK_VERSION;
public const MODULE_PLATFORM_NAME = 'OXID';
public const MODULE_PLATFORM_VERSION = '1.0';
Expand Down
178 changes: 128 additions & 50 deletions src/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use OxidSolutionCatalysts\Adyen\Service\CountryRepository;
use OxidSolutionCatalysts\Adyen\Service\ModuleSettings;
use OxidSolutionCatalysts\Adyen\Service\PaymentMethods;
use OxidSolutionCatalysts\Adyen\Service\SessionSettings;
use OxidSolutionCatalysts\Adyen\Service\UserRepository;
use OxidSolutionCatalysts\Adyen\Traits\AdyenPayment;
use OxidSolutionCatalysts\Adyen\Traits\Json;
Expand All @@ -38,35 +37,29 @@ class ViewConfig extends ViewConfig_parent
use ServiceContainer;
use AdyenPayment;

protected ModuleSettings $moduleSettings;
protected Context $context;
protected PaymentMethods $adyenPaymentMethods;
protected CountryRepository $countryRepository;
protected SessionSettings $sessionSettings;
protected ?ModuleSettings $adyenModuleSettings = null;
protected ?Context $adyenContext = null;
protected ?PaymentMethods $adyenPaymentMethods = null;

/**
* @inheritDoc
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __construct()
public function getAdyen(): bool
{
parent::__construct();

$this->moduleSettings = $this->getServiceFromContainer(ModuleSettings::class);
$this->context = $this->getServiceFromContainer(Context::class);
$this->adyenPaymentMethods = $this->getServiceFromContainer(PaymentMethods::class);
$this->countryRepository = $this->getServiceFromContainer(CountryRepository::class);
$this->sessionSettings = $this->getServiceFromContainer(SessionSettings::class);
return $this->getModuleSettingsSrvc()->checkConfigHealth();
}

/**
* @throws AdyenException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function checkAdyenHealth(): bool
{
$isHealthy = false;

try {
$isHealthy = $this->moduleSettings->checkConfigHealth() && $this->existsAdyenPaymentMethods();
$isHealthy = $this->getModuleSettingsSrvc()->checkConfigHealth() && $this->existsAdyenPaymentMethods();
} catch (AdyenException $exception) {
$this->getServiceFromContainer(LoggerInterface::class)->error(
'ViewConfig::checkAdyenHealth could not prove existsAdyenPaymentMethods because of exception',
Expand All @@ -77,49 +70,85 @@ public function checkAdyenHealth(): bool
return $isHealthy;
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function checkAdyenConfigHealth(): bool
{
return $this->moduleSettings->checkConfigHealth();
return $this->getModuleSettingsSrvc()->checkConfigHealth();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenOperationMode(): string
{
return $this->moduleSettings->getOperationMode();
return $this->getModuleSettingsSrvc()->getOperationMode();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getGooglePayOperationMode(): string
{
return $this->moduleSettings->getGooglePayOperationMode();
return $this->getModuleSettingsSrvc()->getGooglePayOperationMode();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function isAdyenLoggingActive(): bool
{
return $this->moduleSettings->isLoggingActive();
return $this->getModuleSettingsSrvc()->isLoggingActive();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function isAdyenAnalyticsActive(): bool
{
return $this->moduleSettings->isAnalyticsActive();
return $this->getModuleSettingsSrvc()->isAnalyticsActive();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function isAdyenSandboxMode(): bool
{
return $this->moduleSettings->isSandBoxMode();
return $this->getModuleSettingsSrvc()->isSandBoxMode();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenClientKey(): string
{
return $this->moduleSettings->getClientKey();
return $this->getModuleSettingsSrvc()->getClientKey();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenPayPalMerchantId(): string
{
return $this->moduleSettings->getPayPalMerchantId();
return $this->getModuleSettingsSrvc()->getPayPalMerchantId();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenMerchantAccount(): string
{
return $this->moduleSettings->getMerchantAccount();
return $this->getModuleSettingsSrvc()->getMerchantAccount();
}

public function getAdyenSDKVersion(): string
Expand Down Expand Up @@ -177,26 +206,34 @@ public function getAdyenErrorInvalidSession(): string
return Module::ADYEN_ERROR_INVALIDSESSION_NAME;
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getWebhookControllerUrl(): string
{
return $this->context->getWebhookControllerUrl();
return $this->getContextSrvc()->getWebhookControllerUrl();
}

/**
* @throws AdyenException
* @throws Exception
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenPaymentMethods(): array
{
return $this->adyenPaymentMethods->getAdyenPaymentMethods();
return $this->getPaymentMethodsSrvc()->getAdyenPaymentMethods();
}

/**
* @throws AdyenException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function existsAdyenPaymentMethods(): bool
{
return (bool)count($this->adyenPaymentMethods->getAdyenPaymentMethods());
return (bool)count($this->getPaymentMethodsSrvc()->getAdyenPaymentMethods());
}

/**
Expand All @@ -208,27 +245,44 @@ public function getAdyenShopperLocale(): string
return $this->getServiceFromContainer(UserRepository::class)->getUserLocale();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenCountryIso(): string
{
return $this->countryRepository->getCountryIso();
return $this->getServiceFromContainer(CountryRepository::class)
->getCountryIso();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenAmountValue(): string
{
/** @var Basket $basket */
$basket = Registry::getSession()->getBasket();
$amount = $basket->getPrice()->getBruttoPrice();
return $this->getAdyenAmount(
$amount,
$this->context->getActiveCurrencyDecimals()
$this->getContextSrvc()->getActiveCurrencyDecimals()
);
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getAdyenAmountCurrency(): string
{
return $this->context->getActiveCurrencyName();
return $this->getContextSrvc()->getActiveCurrencyName();
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getTemplateConfiguration(
FrontendController $oView,
?Payment $payment
Expand All @@ -237,14 +291,10 @@ public function getTemplateConfiguration(
->getConfiguration($this, $oView, $payment);
}

public function isApplePay(
FrontendController $oView,
?Payment $payment
): bool {
return $this->getServiceFromContainer(JSAPITemplateConfiguration::class)
->isApplePay($oView, $payment);
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getTemplateCheckoutCreateId(?Payment $payment): string
{
return $payment ? $this->getServiceFromContainer(JSAPITemplateCheckoutCreate::class)
Expand All @@ -253,17 +303,9 @@ public function getTemplateCheckoutCreateId(?Payment $payment): string
}

/**
* added for apex theme to verify whether checkout submit button needs to be overwritten
* @param Payment|null $payment
* @return bool
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function hasTemplateCheckoutCreateId(?Payment $payment): bool
{
return $this->getServiceFromContainer(JSAPITemplateCheckoutCreate::class)
->getCreateId($payment->getId())
!== 'no_create_id_found';
}

public function getGooglePayTransactionInfo(): string
{
return $this->getServiceFromContainer(AdyenAPITransactionInfoService::class)
Expand All @@ -274,4 +316,40 @@ public function getTemplatePayButtonContainerId(?Payment $payment): string
{
return $payment ? $payment->getId() . '-container' : '';
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getModuleSettingsSrvc(): ModuleSettings
{
if (is_null($this->adyenModuleSettings)) {
$this->adyenModuleSettings = $this->getServiceFromContainer(ModuleSettings::class);
}
return $this->adyenModuleSettings;
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getContextSrvc(): Context
{
if (is_null($this->adyenContext)) {
$this->adyenContext = $this->getServiceFromContainer(Context::class);
}
return $this->adyenContext;
}

/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getPaymentMethodsSrvc(): PaymentMethods
{
if (is_null($this->adyenPaymentMethods)) {
$this->adyenPaymentMethods = $this->getServiceFromContainer(PaymentMethods::class);
}
return $this->adyenPaymentMethods;
}
}
Loading

0 comments on commit fc959c4

Please sign in to comment.