Exemplo n.º 1
0
 /**
  * @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);
 }
Exemplo 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;
         }
     }
 }
 /**
  * @covers \Magento\Braintree\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testVaultCaptureExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::VAULT_CAPTURE)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
Exemplo n.º 4
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;
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @covers \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  */
 public function testCloneExecute()
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->buildSearchCriteria();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn(1);
     $paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)->setMethods(['getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
     $paymentExtension->expects(static::once())->method('getVaultPaymentToken')->willReturn(null);
     $this->payment->expects(static::once())->method('getExtensionAttributes')->willReturn($paymentExtension);
     $this->commandPool->expects(static::once())->method('get')->with(CaptureStrategyCommand::CLONE_TRANSACTION)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
 /**
  * @param int $size
  * @param string $command
  * @covers       \Magento\BraintreeTwo\Gateway\Command\CaptureStrategyCommand::execute
  * @dataProvider captureDataProvider
  */
 public function testCaptureExecute($size, $command)
 {
     $paymentData = $this->getPaymentDataObjectMock();
     $subject['payment'] = $paymentData;
     $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData);
     $this->payment->expects(static::once())->method('getAuthorizationTransaction')->willReturn(true);
     $this->payment->expects(static::once())->method('getId')->willReturn(1);
     $this->filterBuilder->expects(static::exactly(2))->method('setField')->willReturnSelf();
     $this->filterBuilder->expects(static::exactly(2))->method('setValue')->willReturnSelf();
     $searchCriteria = new SearchCriteria();
     $this->searchCriteriaBuilder->expects(static::once())->method('addFilters')->willReturnSelf();
     $this->searchCriteriaBuilder->expects(static::once())->method('create')->willReturn($searchCriteria);
     $this->transactionRepository->expects(static::once())->method('getList')->with($searchCriteria)->willReturnSelf();
     $this->transactionRepository->expects(static::once())->method('getTotalCount')->willReturn($size);
     $this->commandPool->expects(static::once())->method('get')->with($command)->willReturn($this->command);
     $this->strategyCommand->execute($subject);
 }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 /**
  * Retrieves operation
  *
  * @param string $commandCode
  * @return CommandInterface
  * @throws NotFoundException
  */
 public function get($commandCode)
 {
     return $this->commandPool->get($commandCode);
 }