Skip to content

Commit

Permalink
Add compatibility with Shopware 6.4.11.0
Browse files Browse the repository at this point in the history
CS-6010
  • Loading branch information
MarijaIv committed Oct 11, 2024
1 parent dcc0c75 commit a136a52
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 28 deletions.
7 changes: 4 additions & 3 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public function __construct(
}

/**
* @Route(path="/api/_action/adyen/verify")
* @Route(path="/api/_action/adyen/verify",
* name="api.action.adyen.verify", methods={"GET", "POST"})
*
* @param RequestDataBag $dataBag
* @return JsonResponse
Expand Down Expand Up @@ -311,7 +312,7 @@ public function isManualCaptureEnabled(string $orderId)
if (is_null($orderTransaction)) {
return new JsonResponse(false);
}

$paymentMethodHandlerIdentifier = $orderTransaction->getPaymentMethod()->getHandlerIdentifier();

return new JsonResponse(
Expand Down Expand Up @@ -410,7 +411,7 @@ public function getRefunds(string $orderId): JsonResponse
* @Route(
* "/api/adyen/orders/{orderId}/notifications",
* methods={"GET"}
* )
* )
* @param string $orderId
* @return JsonResponse
*/
Expand Down
20 changes: 13 additions & 7 deletions src/Controller/StoreApi/Payment/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
use Shopware\Core\Checkout\Order\SalesChannel\SetPaymentOrderRouteResponse;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\StateMachine\Loader\InitialStateIdLoader;
use Shopware\Core\System\StateMachine\StateMachineRegistry;
use Shopware\Core\System\StateMachine\Transition;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand Down Expand Up @@ -114,9 +115,9 @@ class PaymentController
*/
private $orderTransactionStateHandler;
/**
* @var InitialStateIdLoader
* @var EntityRepository
*/
private $initialStateIdLoader;
private $stateMachineRepo;

/**
* StoreApiController constructor.
Expand All @@ -130,7 +131,7 @@ class PaymentController
* @param OrderRepository $orderRepository
* @param OrderService $orderService
* @param StateMachineRegistry $stateMachineRegistry
* @param InitialStateIdLoader $initialStateIdLoader
* @param EntityRepository $stateMachineRepo
* @param EntityRepository $orderTransactionRepository
* @param ConfigurationService $configurationService
* @param OrderTransactionStateHandler $orderTransactionStateHandler
Expand All @@ -146,7 +147,7 @@ public function __construct(
OrderRepository $orderRepository,
OrderService $orderService,
StateMachineRegistry $stateMachineRegistry,
InitialStateIdLoader $initialStateIdLoader,
EntityRepository $stateMachineRepo,
EntityRepository $orderTransactionRepository,
ConfigurationService $configurationService,
OrderTransactionStateHandler $orderTransactionStateHandler,
Expand All @@ -164,7 +165,7 @@ public function __construct(
$this->orderTransactionRepository = $orderTransactionRepository;
$this->configurationService = $configurationService;
$this->orderTransactionStateHandler = $orderTransactionStateHandler;
$this->initialStateIdLoader = $initialStateIdLoader;
$this->stateMachineRepo = $stateMachineRepo;
$this->logger = $logger;
}

Expand Down Expand Up @@ -346,7 +347,12 @@ private function setPaymentMethod(
SalesChannelContext $salesChannelContext
): void {
$context = $salesChannelContext->getContext();
$initialStateId = $this->initialStateIdLoader->get(OrderTransactionStates::STATE_MACHINE);
$criteria = new Criteria();
$criteria->addFilter(
new EqualsFilter('technicalName', OrderTransactionStates::STATE_MACHINE)
);

$initialStateId = $this->stateMachineRepo->search($criteria, $context)->first()->getInitialStateId();

/** @var OrderEntity $order */
$order = $this->orderRepository->getOrder($orderId, $context, ['transactions']);
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/controllers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<argument type="service" id="Adyen\Shopware\Service\Repository\OrderRepository"/>
<argument type="service" id="Shopware\Core\Checkout\Order\SalesChannel\OrderService"/>
<argument type="service" id="Shopware\Core\System\StateMachine\StateMachineRegistry"/>
<argument type="service" id="Shopware\Core\System\StateMachine\Loader\InitialStateIdLoader"/>
<argument type="service" id="state_machine.repository"/>
<argument type="service" id="order_transaction.repository"/>
<argument type="service" id="Adyen\Shopware\Service\ConfigurationService"/>
<argument type="service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
name="paymentMethodId"
value="{{ payment.id }}"
{% if payment.id is same as(selectedPaymentMethodId) %}checked="checked"{% endif %}
{% if page.isPaymentChangeable is defined and not page.isPaymentChangeable %}
disabled="disabled"
{% endif %}
class="{{ formCheckInputClass ?? 'form-check-input' }} payment-method-input {% if 'handler_adyen_' in payment.formattedHandlerIdentifier %}adyen-payment-method-input-radio{% endif %}">
{% if page.isPaymentChangeable is defined and not page.isPaymentChangeable %}
disabled="disabled"
{% endif %}
class="{{ formCheckInputClass ?? 'form-check-input' }} custom-control-input payment-method-input {% if 'handler_adyen_' in payment.formattedHandlerIdentifier %}adyen-payment-method-input-radio{% endif %}">
{% endblock %}

{% block component_payment_method_description %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{% block page_account_order_item_detail_table_labels_summary %}
{{ parent() }}
{% if actionType === 'voucher' %}
{% if actionType == 'voucher' %}
<dl class="adyen-voucher-details" data-orderId = "{{ orderId }}">
<div class="voucher-detail">
<dt>Voucher reference:</dt>
Expand Down
8 changes: 4 additions & 4 deletions src/Service/PaymentMethodsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use Adyen\Shopware\Util\Currency;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Framework\Adapter\Cache\CacheValueCompressor;
use Shopware\Core\Framework\Adapter\Cache\CacheCompressor;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Symfony\Contracts\Cache\CacheInterface;

Expand Down Expand Up @@ -96,7 +96,7 @@ public function __construct(
ConfigurationService $configurationService,
Currency $currency,
CartService $cartService,
CacheInterface $cache,
$cache,
SalesChannelRepository $salesChannelRepository,
OrderRepository $orderRepository
) {
Expand Down Expand Up @@ -124,7 +124,7 @@ public function getPaymentMethods(SalesChannelContext $context, $orderId = ''):
$paymentMethodsResponseCache = $this->cache->getItem($cacheKey);

if ($paymentMethodsResponseCache->isHit() && $paymentMethodsResponseCache->get()) {
return CacheValueCompressor::uncompress($paymentMethodsResponseCache->get());
return CacheCompressor::uncompress($paymentMethodsResponseCache);
}

$responseData = new PaymentMethodsResponse();
Expand All @@ -135,7 +135,7 @@ public function getPaymentMethods(SalesChannelContext $context, $orderId = ''):

$responseData = $paymentsApiService->paymentMethods(new PaymentMethodsRequest($requestData));

$paymentMethodsResponseCache->set(CacheValueCompressor::compress($responseData));
$paymentMethodsResponseCache = CacheCompressor::compress($paymentMethodsResponseCache, $responseData);
$this->cache->save($paymentMethodsResponseCache);
} catch (AdyenException $e) {
$this->logger->error($e->getMessage());
Expand Down
4 changes: 2 additions & 2 deletions src/Service/RefundService.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ public function getAdyenOrderTransactionForRefund(OrderEntity $order, array $sta
* @return array
*/
public function getRefundRequest(
mixed $requestRefundAmount,
$requestRefundAmount,
string $currencyCode,
mixed $merchantAccount,
$merchantAccount,
string $pspReference,
array $idempotencyExtraData = null
): array {
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Repository/SalesChannelRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SalesChannelRepository
*/
public function __construct(
EntityRepository $domainRepository,
EntityRepository $salesChannelRepository,
$salesChannelRepository,
ConfigurationService $configurationService,
EntityRepository $languageRepository
) {
Expand Down
7 changes: 3 additions & 4 deletions src/Subscriber/ContextSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Adyen\Shopware\Service\PaymentStateDataService;
use Adyen\Shopware\Struct\AdyenContextDataStruct;
use Adyen\Shopware\Util\Currency;
use Shopware\Core\Checkout\Cart\AbstractCartPersister;
use Shopware\Core\Checkout\Cart\CartCalculator;
use Shopware\Core\Framework\Routing\Event\SalesChannelContextResolvedEvent;
use Shopware\Core\System\SalesChannel\Event\SalesChannelContextRestoredEvent;
Expand All @@ -41,7 +40,7 @@ class ContextSubscriber implements EventSubscriberInterface
private ConfigurationService $configurationService;
private PaymentStateDataService $paymentStateDataService;
private AbstractContextSwitchRoute $contextSwitchRoute;
private AbstractCartPersister $cartPersister;
private $cartPersister;
private CartCalculator $cartCalculator;
private Currency $currency;

Expand All @@ -50,7 +49,7 @@ public function __construct(
ConfigurationService $configurationService,
PaymentStateDataService $paymentStateDataService,
AbstractContextSwitchRoute $contextSwitchRoute,
AbstractCartPersister $cartPersister,
$cartPersister,
CartCalculator $cartCalculator,
Currency $currency
) {
Expand All @@ -74,7 +73,7 @@ public static function getSubscribedEvents()
public function onContextRestored(SalesChannelContextRestoredEvent $event): void
{
$token = $event->getRestoredSalesChannelContext()->getToken();
$oldToken = $event->getCurrentSalesChannelContext()->getToken();
$oldToken = $_SESSION['_sf2_attributes']['sw-context-token'];

$stateData = $this->paymentStateDataService->fetchRedeemedGiftCardsFromContextToken($oldToken);
foreach ($stateData->getElements() as $statedataArray) {
Expand Down
2 changes: 1 addition & 1 deletion src/Subscriber/PaymentSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function __construct(
ConfigurationService $configurationService,
PaymentMethodsService $paymentMethodsService,
RequestStack $requestStack,
AbstractCartPersister $cartPersister,
$cartPersister,
CartCalculator $cartCalculator,
AbstractContextSwitchRoute $contextSwitchRoute,
AbstractSalesChannelContextFactory $salesChannelContextFactory,
Expand Down

0 comments on commit a136a52

Please sign in to comment.