custom/plugins/StripeShopwarePayment/src/PaymentMethods/DigitalWallets/Subscriber/DigitalWalletsSubscriber.php line 33

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\PaymentMethods\DigitalWallets\Subscriber;
  11. use Shopware\Storefront\Event\RouteRequest\HandlePaymentMethodRouteRequestEvent;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. class DigitalWalletsSubscriber implements EventSubscriberInterface
  14. {
  15.     public static function getSubscribedEvents(): array
  16.     {
  17.         return [HandlePaymentMethodRouteRequestEvent::class => 'onHandlePaymentMethodRoute'];
  18.     }
  19.     /**
  20.      * When updating for an order in order to pay for it a newly created request (StoreApiRequest) is used instead
  21.      * of the original storefront request (StorefrontRequest). Therefore the StoreApiRequest is missing some
  22.      * arguments (i.e. our 'stripeDigitalWalletsPaymentMethodId'). This subscriber adds the necessary request
  23.      * parameter from the StorefrontRequest to the StoreApiRequest in order to handle the payment correctly.
  24.      * See AccountOrderController::updateOrder().
  25.      *
  26.      * @param HandlePaymentMethodRouteRequestEvent $event
  27.      */
  28.     public function onHandlePaymentMethodRoute(HandlePaymentMethodRouteRequestEvent $event): void
  29.     {
  30.         $event->getStoreApiRequest()->request->set(
  31.             'stripeDigitalWalletsPaymentMethodId',
  32.             $event->getStorefrontRequest()->request->get('stripeDigitalWalletsPaymentMethodId')
  33.         );
  34.     }
  35. }