/**
  * @inheritdoc
  */
 public function execute(array $commandSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObjectInterface $paymentDO */
     $paymentDO = $this->subjectReader->readPayment($commandSubject);
     /** @var \Magento\Sales\Api\Data\OrderPaymentInterface $paymentInfo */
     $paymentInfo = $paymentDO->getPayment();
     ContextHelper::assertOrderPayment($paymentInfo);
     $command = $this->getCommand($paymentInfo);
     return $this->commandPool->get($command)->execute($commandSubject);
 }
Esempio n. 2
0
 /**
  * Performs command
  *
  * @param string $commandCode
  * @param InfoInterface $payment
  * @param array $arguments
  * @return void
  * @throws NotFoundException
  * @throws \Exception
  */
 private function executeCommand($commandCode, InfoInterface $payment, array $arguments = [])
 {
     if ($this->canPerformCommand($commandCode)) {
         try {
             $command = $this->commandPool->get($commandCode);
             $arguments['payment'] = $this->paymentDataObjectFactory->create($payment);
             $command->execute($arguments);
         } catch (NotFoundException $e) {
             throw $e;
         }
     }
 }
Esempio n. 3
0
 /**
  * Performs command
  *
  * @param string $commandCode
  * @param InfoInterface $payment
  * @param array $arguments
  * @return void
  * @throws NotFoundException
  * @throws \Exception
  * @throws \DomainException
  */
 private function executeCommand($commandCode, InfoInterface $payment, array $arguments = [])
 {
     if ($this->canPerformCommand($commandCode)) {
         if ($this->commandPool === null) {
             throw new \DomainException('Command pool is not configured for use.');
         }
         try {
             $command = $this->commandPool->get($commandCode);
             $arguments['payment'] = $this->paymentDataObjectFactory->create($payment);
             $command->execute($arguments);
         } catch (NotFoundException $e) {
             throw $e;
         }
     }
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 private function executeCommand($commandCode, array $arguments = [])
 {
     if (!$this->canPerformCommand($commandCode)) {
         return null;
     }
     if (isset($arguments['payment'])) {
         $arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']);
     }
     if ($this->commandExecutor !== null) {
         return $this->commandExecutor->executeByCode($commandCode, $arguments);
     }
     if ($this->commandPool === null) {
         throw new \DomainException('Command pool is not configured for use.');
     }
     $command = $this->commandPool->get($commandCode);
     return $command->execute($arguments);
 }
Esempio n. 5
0
 /**
  * @inheritdoc
  */
 public function executeCommand($commandCode, array $arguments = [])
 {
     if ($this->canPerformCommand($commandCode)) {
         if ($this->commandPool === null) {
             throw new \DomainException('Command pool is not configured for use.');
         }
         try {
             $command = $this->commandPool->get($commandCode);
             if (isset($arguments['payment'])) {
                 $arguments['payment'] = $this->paymentDataObjectFactory->create($arguments['payment']);
             }
             return $command->execute($arguments);
         } catch (NotFoundException $e) {
             throw $e;
         }
     }
     return null;
 }
Esempio n. 6
0
 /**
  * Retrieves operation
  *
  * @param string $commandCode
  * @return CommandInterface
  * @throws NotFoundException
  */
 public function get($commandCode)
 {
     return $this->commandPool->get($commandCode);
 }