Skip to content

Commit

Permalink
Merge branch 'hotfix/3.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadjer Chabane committed Jun 7, 2023
2 parents 8a626db + b3a105b commit b5dc33a
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.0.3, 2023-05-30:
- Replace deprecated code.
- Some code fixes.

# 3.0.2, 2023-04-06:
- Bug fix: Fix return Url in case of multiple domains for a saleschannel.

Expand Down
8 changes: 4 additions & 4 deletions LyranetworkLyra/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "lyranetwork/lyra",
"description" : "This plugin enables you to setup the Lyra Collect payment gateway on your Shopware website.",
"version" : "3.0.2",
"version" : "3.0.3",
"type" : "shopware-platform-plugin",
"license" : "MIT",
"authors" : [{
Expand Down Expand Up @@ -33,9 +33,9 @@
},
"require" : {
"php" : "^7.4.3 || ^8.0",
"shopware/core" : ">=6.4",
"shopware/administration" : ">=6.4",
"shopware/storefront" : ">=6.4"
"shopware/core" : "6.4.*",
"shopware/administration" : "6.4.*",
"shopware/storefront" : "6.4.*"
},
"minimum-stability" : "RC",
"prefer-stable" : true
Expand Down
5 changes: 2 additions & 3 deletions LyranetworkLyra/src/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PaymentController extends StorefrontController
* @var AccountService
*/
private $accountService;

/**
* @var RouterInterface
*/
Expand Down Expand Up @@ -105,7 +105,7 @@ public function finalize(Request $request, SalesChannelContext $salesChannelCont
/**
* @var null|OrderTransactionEntity $orderTransaction
*/
$orderTransaction = $this->transactionRepository->search($criteria, Context::createDefaultContext())->first();
$orderTransaction = $this->transactionRepository->search($criteria, $salesChannelContext->getContext())->first();

if ($orderTransaction) {
/**
Expand Down Expand Up @@ -149,7 +149,6 @@ public function finalize(Request $request, SalesChannelContext $salesChannelCont

/**
* @param RouterInterface $router
* @return string
*/
public function addFlashMessages(array $messages)
{
Expand Down
6 changes: 3 additions & 3 deletions LyranetworkLyra/src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function getPaymentStatuses(Request $request, Context $context): JsonResp
$criteria->addAssociation('stateMachine');
$criteria->addFilter(new EqualsFilter('stateMachine.technicalName', 'order_transaction.state'));

$entities = $this->stateMachineStateRepository->search($criteria, Context::createDefaultContext())->getEntities();
$entities = $this->stateMachineStateRepository->search($criteria, $context)->getEntities();

$paymentStatuses = [];
if($entities instanceof StateMachineStateCollection) {
Expand Down Expand Up @@ -190,9 +190,9 @@ public function isFlow(Request $request, Context $context): JsonResponse
*/
public function setOrderPlacedFlow(Request $request, Context $context): JsonResponse
{
$shopwareVersion = (string) $request->get('shopwareVersion');
$shopwareVersion = $request->request->has('shopwareVersion') ? (string) $request->request->get('shopwareVersion') : null;
if (! empty($shopwareVersion) && version_compare($shopwareVersion, '6.4.6.0', '>=')) {
$salesChannelId = empty((string) $request->get('salesChannelId')) ? null : (string) $request->get('salesChannelId');
$salesChannelId = $request->request->has('salesChannelId') ? (string) $request->request->get('salesChannelId') : null;
$active = ($this->configService->get('order_placed_flow_enabled', $salesChannelId) == 'true') ? true : false;
$this->flowService->updateFlowActive('Order placed', $active, $context);
}
Expand Down
20 changes: 10 additions & 10 deletions LyranetworkLyra/src/Installer/ConfigInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class ConfigInstaller
*/
private $defaultValues;

public function __construct(ContainerInterface $container)
public function __construct(ContainerInterface $container, Context $context)
{
$this->container = $container;
$this->systemConfigService = $this->container->get(SystemConfigService::class);
$this->initTranslations();
$this->initDefaults();
$this->initDefaults($context);
}

private function initDefaults()
private function initDefaults(Context $context)
{
$lang = Tools::getDefault('LANGUAGE');

Expand All @@ -71,7 +71,7 @@ private function initDefaults()
'lyraKeyProd' => Tools::getDefault('KEY_PROD'),
'lyraCtxMode' => Tools::getDefault('CTX_MODE'),
'lyraSignAlgo' => Tools::getDefault('SIGN_ALGO'),
'lyraCheckUrl' => $this->getBaseUrl() . '/lyra/finalize',
'lyraCheckUrl' => $this->getBaseUrl($context) . '/lyra/finalize',
'lyraPlatformUrl' => Tools::getDefault('GATEWAY_URL'),
'lyraLanguage' => Tools::getDefault('LANGUAGE'),
'lyraRedirectSuccessTimeout' => '5',
Expand All @@ -81,7 +81,7 @@ private function initDefaults()
'lyraRedirectErrorMessage' => $this->translations[$lang]['lyraRedirectErrorMessageDefault'],
'lyraReturnMode' => 'GET',
'lyraPaymentStatusOnSuccess' => 'paid',
'lyraOrderPlacedFlowEnabled' => $this->getShopwareOrderPlacedFlowActive()
'lyraOrderPlacedFlowEnabled' => $this->getShopwareOrderPlacedFlowActive($context)
];
}

Expand Down Expand Up @@ -169,7 +169,7 @@ private function setDefaultValues()
}
}

private function getBaseUrl(): ?string
private function getBaseUrl(Context $context): ?string
{
/**
* @var EntityRepository $domainRepository
Expand All @@ -182,19 +182,19 @@ private function getBaseUrl(): ?string
$criteria->addFilter(new EqualsFilter('salesChannel.active', '1'));
$criteria->addFilter(new ContainsFilter('url', 'https'));

$domains = $domainRepository->search($criteria, Context::createDefaultContext());
$domains = $domainRepository->search($criteria, $context);
if ($domains->count() === 0) {
$criteria = new Criteria();
$criteria->addAssociation('salesChannel');
$criteria->addFilter(new EqualsFilter('salesChannel.active', '1'));

$domains = $domainRepository->search($criteria, Context::createDefaultContext());
$domains = $domainRepository->search($criteria, $context);
}

return ($domains->count() > 0) ? $domains->first()->getUrl() : '';
}

private function getShopwareOrderPlacedFlowActive(): bool
private function getShopwareOrderPlacedFlowActive(Context $context): bool
{
$shopwareVersion = $this->container->getParameter('kernel.shopware_version');
if (version_compare($shopwareVersion, '6.4.6.0', '>=')) {
Expand All @@ -205,7 +205,7 @@ private function getShopwareOrderPlacedFlowActive(): bool

$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('name', 'Order placed'));
$orderPlacedFlow = $flowRepository->search($criteria, Context::createDefaultContext());
$orderPlacedFlow = $flowRepository->search($criteria, $context);

return ($orderPlacedFlow->count() > 0) ? $orderPlacedFlow->first()->isActive() : false;
}
Expand Down
17 changes: 9 additions & 8 deletions LyranetworkLyra/src/Installer/PaymentMethodInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ public function __construct(ContainerInterface $container) {
$this->paymentMethodSalesChannelRepository = $this->container->get('sales_channel_payment_method.repository');
}

public function install(InstallContext $context): void
public function install(InstallContext $installContext): void
{
$paymentMethodExists = $this->getPaymentMethodId();
$context = $installContext->getContext();
$paymentMethodExists = $this->getPaymentMethodId($context);

// Payment method exists already, no need to continue here.
if ($paymentMethodExists) {
return;
}

$pluginId = $this->pluginIdProvider->getPluginIdByBaseClass('Lyranetwork\\Lyra\\LyranetworkLyra', $context->getContext());
$pluginId = $this->pluginIdProvider->getPluginIdByBaseClass('Lyranetwork\\Lyra\\LyranetworkLyra', $context);

$data = [
// Payment handler will be selected by the identifier.
Expand All @@ -82,9 +83,9 @@ public function install(InstallContext $context): void
'pluginId' => $pluginId
];

$this->paymentMethodRepository->create([$data], $context->getContext());
$this->paymentMethodRepository->create([$data], $context);

$this->enablePaymentMethodForSaleChannels($this->getPaymentMethodId(), $context->getContext());
$this->enablePaymentMethodForSaleChannels($this->getPaymentMethodId($context), $context);
}

public function update(UpdateContext $context): void
Expand All @@ -106,11 +107,11 @@ public function deactivate(DeactivateContext $context): void
$this->setPaymentMethodStatus(false, $context->getContext());
}

private function getPaymentMethodId(): ?string
private function getPaymentMethodId(Context $context): ?string
{
// Fetch ID for update.
$paymentCriteria = (new Criteria())->addFilter(new EqualsFilter('handlerIdentifier', Standard::class));
$paymentIds = $this->paymentMethodRepository->searchIds($paymentCriteria, Context::createDefaultContext());
$paymentIds = $this->paymentMethodRepository->searchIds($paymentCriteria, $context);

if ($paymentIds->getTotal() === 0) {
return null;
Expand All @@ -121,7 +122,7 @@ private function getPaymentMethodId(): ?string

private function setPaymentMethodStatus(bool $active, Context $context): void
{
$paymentMethodId = $this->getPaymentMethodId();
$paymentMethodId = $this->getPaymentMethodId($context);

// Payment does not even exist, so nothing to (de-)activate here.
if (! $paymentMethodId) {
Expand Down
2 changes: 1 addition & 1 deletion LyranetworkLyra/src/LyranetworkLyra.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LyranetworkLyra extends Plugin
{
public function install(InstallContext $context): void
{
(new ConfigInstaller($this->container))->install($context);
(new ConfigInstaller($this->container, $context->getContext()))->install($context);

(new PaymentMethodInstaller($this->container))->install($context);
(new CustomFieldInstaller($this->container))->install($context);
Expand Down
18 changes: 9 additions & 9 deletions LyranetworkLyra/src/PaymentMethods/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouterInterface;

use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
Expand Down Expand Up @@ -89,6 +90,11 @@ class Standard implements AsynchronousPaymentHandlerInterface
*/
private $translator;

/**
* @var RouterInterface
*/
private $router;

/**
* @var string
*/
Expand All @@ -108,6 +114,7 @@ public function __construct(
LocaleCodeService $localeCodeService,
CsrfTokenManagerInterface $csrfTokenManager,
TranslatorInterface $translator,
RouterInterface $router,
string $shopwareVersion
) {
$this->transactionStateHandler = $transactionStateHandler;
Expand All @@ -118,6 +125,7 @@ public function __construct(
$this->localeCodeService = $localeCodeService;
$this->csrfTokenManager = $csrfTokenManager;
$this->translator = $translator;
$this->router = $router;
$this->shopwareVersion = $shopwareVersion;
$this->paymentResult = array(
'lyraIsCancelledPayment' => false,
Expand Down Expand Up @@ -163,14 +171,6 @@ public function pay(

$version = Tools::getDefault('CMS_IDENTIFIER') . '_v' . Tools::getDefault('PLUGIN_VERSION');

$transactionReturnUrl = $transaction->getReturnUrl();
if (strpos($transactionReturnUrl, '/payment/finalize-transaction') !== false) {
$returnurl = explode('/payment/finalize-transaction', $transactionReturnUrl);
$transactionReturnUrl = $returnurl[0] . '/lyra/finalize';
} else {
$transactionReturnUrl = $this->getConfig('check_url', $salesChannelId);
}

$params = [
'amount' => $currency->convertAmountToInteger($transaction->getOrderTransaction()->getAmount()->getTotalPrice()),
'currency' => $currency->getNum(),
Expand Down Expand Up @@ -200,7 +200,7 @@ public function pay(

'threeds_mpi' => $threedsMpi,

'url_return' => $transactionReturnUrl
'url_return' => $this->router->generate('lyra_finalize', [], $this->router::ABSOLUTE_URL)
];

$request->setFromArray($params);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lyranetworklyra-admin",
"version": "3.0.2",
"version": "3.0.3",
"description": "Administration for Lyra Collect",
"main": "index.js",
"author": "Lyra Network",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
#}

{% block lyranetwork_lyra_icon %}
<img class="lyranetwork-lyra-icon" :src="'lyranetworklyra/images/lyra_icon.png' | asset">
<img class="lyranetwork-lyra-icon" :src="'lyranetworklyra/images/lyra_icon.png' | asset" alt="Lyra Collect payment plugin icon">
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,36 @@
<template v-if="isLyraPayment(transaction)">
<sw-container columns="1fr 1fr">
<sw-description-list>
<dt>{{ $tc('lyraTransactionId') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_id }}</dd>

<dt>{{ $tc('lyraTransactionUuid') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_uuid }}</dd>

<dt>{{ $tc('lyraTransactionType') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_type }}</dd>
<dl>
<div>
<dt>{{ $tc('lyraTransactionId') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_id }}</dd>
</div>
<div>
<dt>{{ $tc('lyraTransactionUuid') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_uuid }}</dd>
</div>
<div>
<dt>{{ $tc('lyraTransactionType') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_transaction_type }}</dd>
</div>
</dl>
</sw-description-list>
<sw-description-list>
<dt>{{ $tc('lyraMeansOfPayment') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_means_of_payment }}</dd>

<dt>{{ $tc('lyraCardNumber') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_card_number }}</dd>

<dt>{{ $tc('lyraCardExpirationDate') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_card_expiration_date }}</dd>
<dl>
<div>
<dt>{{ $tc('lyraMeansOfPayment') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_means_of_payment }}</dd>
</div>
<div>
<dt>{{ $tc('lyraCardNumber') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_card_number }}</dd>
</div>
<div>
<dt>{{ $tc('lyraCardExpirationDate') }}</dt>
<dd class="sw-order-base__label-sales-channel">{{ transaction.customFields.lyra_card_expiration_date }}</dd>
</div>
</dl>
</sw-description-list>
</sw-container>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:to="{ name: 'lyranetwork.lyra.index' }"
:backgroundEnabled="false">
<template #icon>
<img class="sw-settings-index__lyra-icon" :src="'lyranetworklyra/images/lyra_icon.png' | asset">
<img class="sw-settings-index__lyra-icon" :src="'lyranetworklyra/images/lyra_icon.png' | asset" alt="Lyra Collect payment plugin icon">
</template>
</sw-settings-item>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let configuration = {
name: 'Lyra Collect',
title: 'lyraTitle',
description: 'lyraGeneral.descriptionTextModule',
version: '3.0.2',
version: '3.0.3',
icon: 'default-action-settings',

snippets: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<sw-container columns="1fr">
<div class="lyra-doc__col">
<div class="lyra-doc__icon">
<img class="lyra-doc__lyra-icon" :src="'lyranetworklyra/images/lyra_logo.png' | asset">
<img class="lyra-doc__lyra-icon" :src="'lyranetworklyra/images/lyra_logo.png' | asset" alt="Lyra Collect payment plugin logo">
</div>
<p class="lyra-doc__desc">
{{ $tc('lyraDescription') }}
Expand Down
1 change: 1 addition & 0 deletions LyranetworkLyra/src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<argument type="service" id="Lyranetwork\Lyra\Service\LocaleCodeService" />
<argument type="service" id="Symfony\Component\Security\Csrf\CsrfTokenManagerInterface" />
<argument type="service" id="translator" />
<argument type="service" id="Shopware\Storefront\Framework\Routing\Router" />
<argument>%kernel.shopware_version%</argument>
<tag name="shopware.payment.method.async" />
</service>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LyranetworkLyra/src/Sdk/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Tools

private static $CMS_IDENTIFIER = 'Shopware_6.4.x';
private static $SUPPORT_EMAIL = '[email protected]';
private static $PLUGIN_VERSION = '3.0.2';
private static $PLUGIN_VERSION = '3.0.3';
private static $GATEWAY_VERSION = 'V2';

public static $pluginFeatures = [
Expand Down
Loading

0 comments on commit b5dc33a

Please sign in to comment.