-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Components/Integration/PaymentProcessors/ApplicationInfoProcessor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.