custom/plugins/StripeShopwarePayment/src/Config/ShowPaymentProviderLogosInStorefrontSubscriber.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (c) Pickware GmbH. All rights reserved.
  4.  * This file is part of software that is released under a proprietary license.
  5.  * You must not copy, modify, distribute, make publicly available, or execute
  6.  * its contents or parts thereof without express permission by the copyright
  7.  * holder, unless otherwise permitted by law.
  8.  */
  9. declare(strict_types=1);
  10. namespace Stripe\ShopwarePayment\Config;
  11. use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent;
  12. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  13. use Shopware\Storefront\Page\PageLoadedEvent;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. class ShowPaymentProviderLogosInStorefrontSubscriber implements EventSubscriberInterface
  16. {
  17.     private StripePluginConfigService $stripePluginConfigService;
  18.     public function __construct(
  19.         StripePluginConfigService $stripePluginConfigService
  20.     ) {
  21.         $this->stripePluginConfigService $stripePluginConfigService;
  22.     }
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             CheckoutConfirmPageLoadedEvent::class => 'onPageWithPaymentSelectionLoaded',
  27.             AccountEditOrderPageLoadedEvent::class => 'onPageWithPaymentSelectionLoaded',
  28.         ];
  29.     }
  30.     public function onPageWithPaymentSelectionLoaded(PageLoadedEvent $event): void
  31.     {
  32.         $salesChannelContext $event->getSalesChannelContext();
  33.         $salesChannel $salesChannelContext->getSalesChannel();
  34.         $stripePluginConfig $this->stripePluginConfigService->getStripePluginConfigForSalesChannel(
  35.             $salesChannel->getId()
  36.         );
  37.         $showPaymentProviderLogosPageExtension = new ShowPaymentProviderLogosPageExtension();
  38.         $showPaymentProviderLogosPageExtension->assign([
  39.             'showPaymentProviderLogos' => $stripePluginConfig->shouldShowPaymentProviderLogos(),
  40.         ]);
  41.         $event->getPage()->addExtension(
  42.             ShowPaymentProviderLogosPageExtension::PAGE_EXTENSION_NAME,
  43.             $showPaymentProviderLogosPageExtension
  44.         );
  45.     }
  46. }