custom/plugins/CrehlerTpay-1.0.23/src/TpayShopwarePayment.php line 36

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @copyright 2020 Tpay Krajowy Integrator Płatności S.A. <https://tpay.com/>
  4.  *
  5.  * @author    Jakub Medyński <jme@crehler.com>
  6.  * @support   Tpay <pt@tpay.com>
  7.  * @created   23 kwi 2020
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Tpay\ShopwarePayment;
  13. use Doctrine\DBAL\Connection;
  14. use Shopware\Core\Framework\Plugin;
  15. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  16. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  17. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  18. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  19. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  20. use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
  21. use Symfony\Component\Config\FileLocator;
  22. use Symfony\Component\DependencyInjection\ContainerBuilder;
  23. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  24. use Tpay\ShopwarePayment\Util\Lifecycle\ActivateDeactivate;
  25. use Tpay\ShopwarePayment\Util\Lifecycle\InstallUninstall;
  26. use Tpay\ShopwarePayment\Util\Lifecycle\Update;
  27. use tpayLibs\src\_class_tpay\Utilities\Util;
  28. // SWAG-133666
  29. if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
  30.     require_once dirname(__DIR__) . '/vendor/autoload.php';
  31. }
  32. class TpayShopwarePayment extends Plugin
  33. {
  34.     public const ORDER_TRANSACTION_CUSTOM_FIELDS_TPAY_TRANSACTION_ID 'tpay_shopware_payment_transaction_id';
  35.     public const CUSTOMER_CUSTOM_FIELDS_TPAY_SELECTED_BANK 'tpay_default_payment_selected_bank';
  36.     /**
  37.      * @var ActivateDeactivate
  38.      */
  39.     private $activateDeactivate;
  40.     /**
  41.      * @Required
  42.      *
  43.      * @param ActivateDeactivate $activateDeactivate
  44.      */
  45.     public function setActivateDeactivate(ActivateDeactivate $activateDeactivate): void
  46.     {
  47.         $this->activateDeactivate $activateDeactivate;
  48.     }
  49.     public function build(ContainerBuilder $container): void
  50.     {
  51.         parent::build($container);
  52.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection/'));
  53.         $loader->load('util.xml');
  54.         $loader->load('payment.xml');
  55.         $loader->load('config.xml');
  56.         $loader->load('subscriber.xml');
  57.         $loader->load('component.xml');
  58.         $loader->load('webhook.xml');
  59.         $loader->load('entity.xml');
  60.     }
  61.     public function install(InstallContext $installContext): void
  62.     {
  63.         (new InstallUninstall(
  64.             $this->container->get(Connection::class),
  65.             $this->container->get('payment_method.repository'),
  66.             $this->container->get('rule.repository'),
  67.             $this->container->get('currency.repository'),
  68.             $this->container->get('language.repository'),
  69.             $this->container->get(PluginIdProvider::class),
  70.             \get_class($this)))->install($installContext->getContext());
  71.     }
  72.     public function uninstall(UninstallContext $uninstallContext): void
  73.     {
  74.         (new InstallUninstall(
  75.             $this->container->get(Connection::class),
  76.             $this->container->get('payment_method.repository'),
  77.             $this->container->get('rule.repository'),
  78.             $this->container->get('currency.repository'),
  79.             $this->container->get('language.repository'),
  80.             $this->container->get(PluginIdProvider::class),
  81.             \get_class($this)))->uninstall($uninstallContext);
  82.     }
  83.     public function activate(ActivateContext $activateContext): void
  84.     {
  85.         $this->activateDeactivate->activate($activateContext->getContext());
  86.     }
  87.     public function deactivate(DeactivateContext $deactivateContext): void
  88.     {
  89.         $this->activateDeactivate->deactivate($deactivateContext->getContext());
  90.     }
  91.     public function update(UpdateContext $updateContext): void
  92.     {
  93.         (new Update(
  94.             $this->container->get('payment_method.repository'),
  95.             $this->container->get('language.repository'),
  96.         ))->update($updateContext->getContext());
  97.     }
  98.     public function executeComposerCommands(): bool
  99.     {
  100.         return true;
  101.     }
  102. }