Skip to content

Commit

Permalink
Implement application info logic
Browse files Browse the repository at this point in the history
ISSUE: ACS0AIA-6
  • Loading branch information
AleksandarBoljanovic committed Oct 5, 2023
1 parent 25cc803 commit 031a144
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Bootstrap/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Adyen\Core\BusinessLogic\Domain\GeneralSettings\Services\GeneralSettingsService;
use Adyen\Core\BusinessLogic\Domain\Integration\Order\OrderService as OrderServiceInterface;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\AddressProcessor;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\ApplicationInfoProcessor;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\BasketItemsProcessor;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\BirthdayProcessor;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\L2L3DataProcessor;
Expand Down Expand Up @@ -65,6 +66,7 @@
use AdyenPayment\Components\Integration\PaymentProcessors\ShopperLocaleProcessor;
use AdyenPayment\Components\Integration\PaymentProcessors\ShopperNameProcessor as IntegrationShopperNameProcessor;
use AdyenPayment\Components\Integration\PaymentProcessors\ShopperReferenceProcessor as IntegrationShopperReferenceProcessor;
use AdyenPayment\Components\Integration\PaymentProcessors\ApplicationInfoProcessor as IntegrationApplicationInfoProcessor;
use AdyenPayment\Components\Integration\StoreService;
use AdyenPayment\Components\Integration\SystemInfoService;
use AdyenPayment\Components\LastOpenTimeService;
Expand Down Expand Up @@ -299,6 +301,13 @@ static function () {
}
);

ServiceRegister::registerService(
ApplicationInfoProcessor::class,
static function () {
return new IntegrationApplicationInfoProcessor();
}
);

ServiceRegister::registerService(
\Adyen\Core\BusinessLogic\Domain\Integration\Processors\ShopperLocaleProcessor::class,
static function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace AdyenPayment\Components\Integration\PaymentProcessors;

use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Factory\PaymentRequestBuilder;
use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\ApplicationInfo\ApplicationInfo;
use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\ApplicationInfo\ExternalPlatform;
use Adyen\Core\BusinessLogic\Domain\Checkout\PaymentRequest\Models\StartTransactionRequestContext;
use Adyen\Core\BusinessLogic\Domain\Integration\Processors\ApplicationInfoProcessor as ApplicationInfoProcessorInterface;
use AdyenPayment\Components\ShopwareVersionCheck;
use Exception;
use Shopware\Models\Plugin\Plugin;

/**
* Class ApplicationInfoProcessor.
*
* @package AdyenPayment\Components\Integration\PaymentProcessors
*/
class ApplicationInfoProcessor implements ApplicationInfoProcessorInterface
{
/**
* @param PaymentRequestBuilder $builder
* @param StartTransactionRequestContext $context
*
* @return void
*
* @throws Exception
*/
public function process(PaymentRequestBuilder $builder, StartTransactionRequestContext $context): void
{
$shopName = Shopware()->Shop()->getName();
$shopVersion = $this->getShopVersion();
$pluginVersion = $this->getPluginVersion();

$shopName && $builder->setApplicationInfo(
new ApplicationInfo(new ExternalPlatform($shopName, $shopVersion), $pluginVersion)
);
}

/**
* Returns Shopware5 version.
*
* @return string
*/
private function getShopVersion(): string
{
/** @var ShopwareVersionCheck $versionCheck */
$versionCheck = Shopware()->Container()->get('adyen_payment.components.shopware_version_check');

return $versionCheck->getShopwareVersion();
}

/**
* Returns Adyen plugin version.
*
* @return string
*/
private function getPluginVersion(): string
{
$pluginManager = Shopware()->Container()->get('shopware.plugin_manager');
/** @var Plugin $pluginInfo */
$pluginInfo = $pluginManager->getPluginByName('AdyenPayment');

return $pluginInfo->getVersion();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"php": "^7.2|^7.4|^8.0",
"ext-json": "*",
"ext-zip": "*",
"adyen/integration-core": "1.0.0",
"adyen/integration-core": "1.0.1",
"ext-simplexml": "*"
},
"minimum-stability": "dev",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 031a144

Please sign in to comment.