Beispiel #1
0
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return void
  */
 public function execute(array $commandSubject)
 {
     // @TODO implement exceptions catching
     $transferO = $this->transferBuilder->build($this->requestBuilder->build($commandSubject));
     $response = $this->gateway->placeRequest($transferO);
     $this->responseHandler->handle($commandSubject, $response);
 }
Beispiel #2
0
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return null
  */
 public function execute(array $commandSubject)
 {
     // @TODO implement exceptions catching
     $transferO = $this->transferFactory->create($this->requestBuilder->build($commandSubject));
     $response = $this->client->placeRequest($transferO);
     $result = $this->validator->validate(array_merge($commandSubject, ['response' => $response]));
     if ($result !== null && !$result->isValid()) {
         $commandSubject['payment']->getPayment()->setIsTransactionPending(true);
         return;
     }
     $this->handler->handle($commandSubject, $response);
 }
Beispiel #3
0
 public function testExecute()
 {
     $commandSubject = ['authorize'];
     $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2'];
     $response = ['response_field1' => 'response_value1'];
     $transferO = $this->getMockBuilder('Magento\\Payment\\Gateway\\Http\\TransferInterface')->getMockForAbstractClass();
     $this->requestBuilderMock->expects($this->once())->method('build')->with($commandSubject)->willReturn($request);
     $this->transferBuilderMock->expects($this->once())->method('build')->with($request)->willReturn($transferO);
     $this->gatewayMock->expects($this->once())->method('placeRequest')->with($transferO)->willReturn($response);
     $this->responseHandlerMock->expects($this->once())->method('handle')->with($commandSubject, $response);
     $this->model->execute($commandSubject);
 }
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return null
  * @throws \Exception
  */
 public function execute(array $commandSubject)
 {
     // @TODO implement exceptions catching
     $transferO = $this->transferFactory->create($this->requestBuilder->build($commandSubject));
     $response = $this->client->placeRequest($transferO);
     if ($this->validator) {
         $result = $this->validator->validate(array_merge($commandSubject, ['response' => $response]));
         if (!$result->isValid()) {
             throw new CommandException(__(implode("\n", $result->getFailsDescription())));
         }
     }
     if ($this->handler) {
         $this->handler->handle($commandSubject, $response);
     }
 }
Beispiel #5
0
 public function testExecute()
 {
     $commandSubject = ['authorize'];
     $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2'];
     $response = ['response_field1' => 'response_value1'];
     $validationResult = $this->getMockBuilder('Magento\\Payment\\Gateway\\Validator\\ResultInterface')->getMockForAbstractClass();
     $transferO = $this->getMockBuilder('Magento\\Payment\\Gateway\\Http\\TransferInterface')->getMockForAbstractClass();
     $this->requestBuilderMock->expects(static::once())->method('build')->with($commandSubject)->willReturn($request);
     $this->transferFactoryMock->expects(static::once())->method('create')->with($request)->willReturn($transferO);
     $this->clientMock->expects(static::once())->method('placeRequest')->with($transferO)->willReturn($response);
     $this->validatorMock->expects(static::once())->method('validate')->with(array_merge($commandSubject, ['response' => $response]))->willReturn($validationResult);
     $validationResult->expects(static::once())->method('isValid')->willReturn(true);
     $this->responseHandlerMock->expects(static::once())->method('handle')->with($commandSubject, $response);
     $this->model->execute($commandSubject);
 }
 /**
  * Executes command basing on business object
  *
  * @param array $commandSubject
  * @return void
  * @throws CommandException
  */
 public function execute(array $commandSubject)
 {
     // @TODO implement exceptions catching
     $transferO = $this->transferFactory->create($this->requestBuilder->build($commandSubject));
     $response = $this->client->placeRequest($transferO);
     if ($this->validator !== null) {
         $result = $this->validator->validate(array_merge($commandSubject, ['response' => $response]));
         if (!$result->isValid()) {
             $this->logExceptions($result->getFailsDescription());
             throw new CommandException(__('Transaction has been declined. Please try again later.'));
         }
     }
     if ($this->handler) {
         $this->handler->handle($commandSubject, $response);
     }
 }
 public function testExecuteValidationFail()
 {
     $this->setExpectedException('Magento\\Payment\\Gateway\\Command\\CommandException');
     $commandSubject = ['authorize'];
     $request = ['request_field1' => 'request_value1', 'request_field2' => 'request_value2'];
     $response = ['response_field1' => 'response_value1'];
     $validationFailures = [__('Failure #1'), __('Failure #2')];
     $validationResult = $this->getMockBuilder('Magento\\Payment\\Gateway\\Validator\\ResultInterface')->getMockForAbstractClass();
     $transferO = $this->getMockBuilder('Magento\\Payment\\Gateway\\Http\\TransferInterface')->getMockForAbstractClass();
     $this->requestBuilderMock->expects(static::once())->method('build')->with($commandSubject)->willReturn($request);
     $this->transferFactoryMock->expects(static::once())->method('create')->with($request)->willReturn($transferO);
     $this->clientMock->expects(static::once())->method('placeRequest')->with($transferO)->willReturn($response);
     $this->validatorMock->expects(static::once())->method('validate')->with(array_merge($commandSubject, ['response' => $response]))->willReturn($validationResult);
     $validationResult->expects(static::once())->method('isValid')->willReturn(false);
     $validationResult->expects(static::once())->method('getFailsDescription')->willReturn($validationFailures);
     $this->logger->expects(static::exactly(count($validationFailures)))->method('critical')->withConsecutive([$validationFailures[0]], [$validationFailures[1]]);
     $this->command->execute($commandSubject);
 }